From: Alex Morega Date: Wed, 8 Jan 2014 11:24:40 +0000 (+0200) Subject: correctly handle 'C.UTF-8' locale X-Git-Tag: 2.0~3^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c21a3323d27f17556cd997a0f9279c6d0ec65be3;p=thirdparty%2Fbabel.git correctly handle 'C.UTF-8' locale fixes #57 --- diff --git a/babel/core.py b/babel/core.py index 4ada4661..df385729 100644 --- a/babel/core.py +++ b/babel/core.py @@ -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] diff --git a/tests/test_core.py b/tests/test_core.py index ec3f9ea9..ac2611dc 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -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']) ==