INNER CODE UNIT · Python
find_locale
Julow/Unexpected-Keyboard · gen_method_xml.py:131
def find_locale(locs, name):
for loc in locs:
if loc["name"] == name: return loc
return None
def find_default_locale_in_group(l, locs):
for loc in locs:
if "default_for_lang" in loc and loc["default_for_lang"]:
return loc
# Set the language with a country code equal to the lang as the first
# in order (eg. "de_DE" comes before "de_BE")
def_loc = find_locale(locs, f"{l}_{l.upper()}")
if def_loc is not None:
def_loc["default_for_lang"] = True
else:
def_loc = find_locale(locs, l)
if def_loc is None and len(locs) == 1:
def_loc = locs[0]
return def_loc