Skip to content

Commit

Permalink
Merge pull request #34740 from dimagi/baa/deet/unsupported-languages-fix
Browse files Browse the repository at this point in the history
fix language menu for languages not showing in native script
  • Loading branch information
biyeun authored Aug 26, 2024
2 parents 6d9e608 + 1a6e0c2 commit 6e85957
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions corehq/apps/app_manager/app_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
from corehq.util.translation import localize


# If the language name is not showing up properly in the language menu, you can
# define those languages here, mapped to their two-letter language codes.
CUSTOM_LANGUAGE_NAMES = {
'km': "ខ្មែរ",
}


def non_empty_only(dct):
return {key: value for key, value in dct.items() if value}

Expand Down Expand Up @@ -60,8 +67,16 @@ def _create_custom_app_strings(app, lang, for_default=False, build_profile_id=No
name = langcodes.get_name(lc) or lc
if not name:
continue
with localize(convert_to_two_letter_code(lc)):
name = gettext(name)
letter_code = convert_to_two_letter_code(lc)

if letter_code in CUSTOM_LANGUAGE_NAMES.keys():
# These are languages not installed on our machines, so localize does not understand them.
# Though we don't want to install these langauges, we still want to support projects
# who want to see the name written properly.
name = CUSTOM_LANGUAGE_NAMES[letter_code]
else:
with localize(letter_code):
name = gettext(name)
yield lc, name

yield id_strings.current_language(), lang
Expand Down

0 comments on commit 6e85957

Please sign in to comment.