зеркало из https://github.com/mozilla/bedrock.git
Fix bug 1130285: Treat hsb/dsb locales as de for number formatting.
This commit is contained in:
Родитель
7a2d079a8b
Коммит
64c4f17758
|
@ -15,6 +15,12 @@ from dotlang import translate, lang_file_has_tag
|
|||
from gettext import template_has_tag
|
||||
|
||||
|
||||
babel_format_locale_map = {
|
||||
'hsb': 'de',
|
||||
'dsb': 'de',
|
||||
}
|
||||
|
||||
|
||||
def install_lang_files(ctx):
|
||||
"""Install the initial set of .lang files"""
|
||||
req = ctx['request']
|
||||
|
@ -81,6 +87,7 @@ def l10n_has_tag(ctx, tag, langfile=None):
|
|||
|
||||
def get_locale(lang):
|
||||
"""Return a babel Locale object for lang. defaults to LANGUAGE_CODE."""
|
||||
lang = babel_format_locale_map.get(lang) or lang
|
||||
try:
|
||||
return Locale.parse(lang, sep='-')
|
||||
except (UnknownLocaleError, ValueError):
|
||||
|
|
|
@ -11,6 +11,19 @@ from bedrock.mozorg.tests import TestCase
|
|||
from l10n_utils import helpers
|
||||
|
||||
|
||||
def test_get_locale():
|
||||
"""Test that the get_locale() helper works."""
|
||||
eq_(helpers.get_locale('pt-BR').language, 'pt')
|
||||
eq_(helpers.get_locale('not-a-lang').language, 'en')
|
||||
|
||||
|
||||
def test_get_locale_hsb():
|
||||
"""Should treat hsb and dsb as de."""
|
||||
# bug 1130285
|
||||
eq_(helpers.get_locale('dsb').language, 'de')
|
||||
eq_(helpers.get_locale('hsb').language, 'de')
|
||||
|
||||
|
||||
@patch.object(helpers, 'lang_file_has_tag')
|
||||
class TestL10nHasTag(TestCase):
|
||||
def test_uses_langfile(self, lfht_mock):
|
||||
|
|
Загрузка…
Ссылка в новой задаче