Skip to content

Commit

Permalink
feat: map_locale_display_names(): skip (hide) unusable locales
Browse files Browse the repository at this point in the history
We can't iterate directly over USABLE_LOCALES: Set(Locale) because
Locales aren't sortable.  Instead, we parse config.SUPPORTED_LOCALES in
order and skip those that aren't in USABLE_LOCALES.
  • Loading branch information
cfm committed May 2, 2022
1 parent 9c11950 commit 20c59fd
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions securedrop/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,17 @@ def map_locale_display_names(config: SDConfig) -> None:
"""
language_locale_counts = collections.defaultdict(int) # type: Dict[str, int]
for l in sorted(config.SUPPORTED_LOCALES):
if Locale.parse(l) not in USABLE_LOCALES:
continue

locale = RequestLocaleInfo(l)
language_locale_counts[locale.language] += 1

locale_map = collections.OrderedDict()
for l in sorted(config.SUPPORTED_LOCALES):
if Locale.parse(l) not in USABLE_LOCALES:
continue

locale = RequestLocaleInfo(l)
if language_locale_counts[locale.language] > 1:
locale.use_display_name = True
Expand Down

0 comments on commit 20c59fd

Please sign in to comment.