Fix a regression in get_trnaslator

d1f94b510c meant that English null translator was not being returned for
lang when language included country code.
This commit is contained in:
Kovid Goyal 2019-05-09 16:17:12 +05:30
parent 87b54360f3
commit 96429111a1
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -155,7 +155,7 @@ def get_translator(bcp_47_code):
lang = {'pt':'pt_BR', 'zh':'zh_CN'}.get(lang, lang) lang = {'pt':'pt_BR', 'zh':'zh_CN'}.get(lang, lang)
available = available_translations() available = available_translations()
found = True found = True
if lang == 'en': if lang == 'en' or lang.startswith('en_'):
return found, lang, NullTranslations() return found, lang, NullTranslations()
if lang not in available: if lang not in available:
lang = {'pt':'pt_BR', 'zh':'zh_CN'}.get(parts[0], parts[0]) lang = {'pt':'pt_BR', 'zh':'zh_CN'}.get(parts[0], parts[0])
@ -164,6 +164,8 @@ def get_translator(bcp_47_code):
if lang not in available: if lang not in available:
lang = 'en' lang = 'en'
found = False found = False
if lang == 'en':
return True, lang, NullTranslations()
return found, lang, get_single_translator(lang) return found, lang, get_single_translator(lang)