explicit is better than implicit
This commit is contained in:
Родитель
31c2288bb5
Коммит
5cac981b71
|
@ -210,11 +210,9 @@ def url_fix(s, charset='utf-8'):
|
|||
|
||||
def lang_from_accept_header(header):
|
||||
# Map all our lang codes and any prefixes to the locale code.
|
||||
langs = [(k.lower(), v) for k, v in
|
||||
sorted(settings.LANGUAGE_URL_MAP.items())]
|
||||
# Start with prefixes so any real matches override them.
|
||||
lang_url_map = dict((k.split('-')[0], v) for k, v in langs)
|
||||
lang_url_map.update(langs)
|
||||
lang_url_map = settings.SHORTER_LANGUAGES.copy()
|
||||
lang_url_map.update((k.lower(), v) for k, v in
|
||||
settings.LANGUAGE_URL_MAP.items())
|
||||
|
||||
# If we have a lang or a prefix of the lang, return the locale code.
|
||||
for lang, _ in parse_accept_lang_header(header.lower()):
|
||||
|
|
|
@ -122,6 +122,11 @@ AMO_LANGUAGES = (
|
|||
'zh-CN', 'zh-TW',
|
||||
)
|
||||
|
||||
# Explicit conversion of a shorter language code into a more specific one.
|
||||
SHORTER_LANGUAGES = {
|
||||
'en': 'en-US', 'ga': 'ga-IE', 'pt': 'pt-PT', 'sv': 'sv-SE', 'zh': 'zh-CN'
|
||||
}
|
||||
|
||||
# Not shown on the site, but .po files exist and these are available on the
|
||||
# L10n dashboard. Generally languages start here and move into AMO_LANGUAGES.
|
||||
HIDDEN_LANGUAGES = ('cy', 'sr', 'sr-Latn', 'tr')
|
||||
|
|
Загрузка…
Ссылка в новой задаче