explicit is better than implicit

This commit is contained in:
Andy McKay 2012-09-05 16:11:54 -07:00
Родитель 31c2288bb5
Коммит 5cac981b71
2 изменённых файлов: 8 добавлений и 5 удалений

Просмотреть файл

@ -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')