]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
correctly handle 'C.UTF-8' locale
authorAlex Morega <alex@grep.ro>
Wed, 8 Jan 2014 11:24:40 +0000 (13:24 +0200)
committerAlex Morega <alex@grep.ro>
Wed, 8 Jan 2014 11:26:29 +0000 (13:26 +0200)
fixes #57

babel/core.py
tests/test_core.py

index 4ada4661f0280ee31609b32719db94b5c326a450..df385729564fd819e4a4d3162efecb9b18366b7d 100644 (file)
@@ -777,7 +777,7 @@ def default_locale(category=None, aliases=LOCALE_ALIASES):
                 # the LANGUAGE variable may contain a colon-separated list of
                 # language codes; we just pick the language on the list
                 locale = locale.split(':')[0]
-            if locale in ('C', 'POSIX'):
+            if locale.split('.')[0] in ('C', 'POSIX'):
                 locale = 'en_US_POSIX'
             elif aliases and locale in aliases:
                 locale = aliases[locale]
index ec3f9ea9d4d372c4af2735d3dec074f61283c44a..ac2611dced3a6a7358ce436583e3c7befaffd98b 100644 (file)
@@ -238,6 +238,10 @@ def test_default_locale(os_environ):
     os_environ['LC_MESSAGES'] = 'POSIX'
     assert default_locale('LC_MESSAGES') == 'en_US_POSIX'
 
+    for value in ['C', 'C.UTF-8', 'POSIX']:
+        os_environ['LANGUAGE'] = value
+        assert default_locale() == 'en_US_POSIX'
+
 
 def test_negotiate_locale():
     assert (core.negotiate_locale(['de_DE', 'en_US'], ['de_DE', 'de_AT']) ==