Skip to content

Commit

Permalink
Merge pull request #2711 from pmclanahan/fix-dsb-hsb-number-formattin…
Browse files Browse the repository at this point in the history
…g-1130285

Fix bug 1130285: Treat hsb/dsb locales as de for number formatting.
  • Loading branch information
jgmize committed Feb 6, 2015
2 parents 7a2d079 + 64c4f17 commit 01db764
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/l10n_utils/helpers.py
Expand Up @@ -15,6 +15,12 @@
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']
Expand Down Expand Up @@ -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):
Expand Down
13 changes: 13 additions & 0 deletions lib/l10n_utils/tests/test_helpers.py
Expand Up @@ -11,6 +11,19 @@
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):
Expand Down

0 comments on commit 01db764

Please sign in to comment.