Avoid exceptions by first checking language code validity