Skip to content

Commit

Permalink
Normalize locale codes to xx_YY
Browse files Browse the repository at this point in the history
closes #3969
  • Loading branch information
ThiefMaster committed Jun 12, 2019
1 parent 159ce50 commit bbfea69
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions indico/util/i18n.py
Expand Up @@ -223,6 +223,11 @@ def set_best_lang(check_session=True):
# fall back to server default
resolved_lang = config.DEFAULT_LOCALE

# normalize to xx_YY capitalization
resolved_lang = re.sub(r'^([a-zA-Z]+)_([a-zA-Z]+)$',
lambda m: '{}_{}'.format(m.group(1).lower(), m.group(2).upper()),
resolved_lang)

# As soon as we looked up a language, cache it during the request.
# This will be returned when accessing `session.lang` since there's code
# which reads the language from there and might fail (e.g. by returning
Expand Down

0 comments on commit bbfea69

Please sign in to comment.