There can be 3 letter full lang names (i.e https://github.com/ace20022/xbmc/blob/4843334254a61893c27a676390eacaf5131ddca9/xbmc/utils/LangCodeExpander.cpp#L764 ) and this check will fail for them.

IMO You should lookup full names and if not found lookup lang codes to validate that passed string is really a language.

Same goes to similliar check below