Skip to content

Commit

Permalink
i18n: handle missing babel locale in formatter
Browse files Browse the repository at this point in the history
Fixes:
    'UnknownLocaleError: unknown locale 'son'
  • Loading branch information
dwaynebailey committed Jan 3, 2017
1 parent 6630527 commit 84c44f3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pootle/i18n/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@

from __future__ import absolute_import

from babel import support as babel_support
from babel import core as babel_core
from babel import (UnknownLocaleError, core as babel_core,
support as babel_support)

from django.conf import settings
from django.utils.translation import get_language, to_locale


def _get_locale_formats():
locale = babel_core.Locale.parse(to_locale(get_language()))
try:
locale = babel_core.Locale.parse(to_locale(get_language()))
except UnknownLocaleError:
locale = settings.LANGUAGE_CODE
return babel_support.Format(locale)


Expand Down

0 comments on commit 84c44f3

Please sign in to comment.