Don't consider empty language codes when selecting language (fixes #540)