]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Fixed a bug in the subtag resolving
authorArmin Ronacher <armin.ronacher@active-4.com>
Wed, 24 Jul 2013 19:08:41 +0000 (21:08 +0200)
committerArmin Ronacher <armin.ronacher@active-4.com>
Wed, 24 Jul 2013 19:08:41 +0000 (21:08 +0200)
babel/core.py
tests/test_core.py

index e5fe4bd0bcf03114aea70ef92045066b03db7e79..92a2f4fd05111a131fcc3228b8fc526b745c994c 100644 (file)
@@ -208,7 +208,12 @@ class Locale(object):
         Locale('de', territory='DE')
 
         This also can perform resolving of likely subtags which it does
-        by default.
+        by default.  This is for instance useful to figure out the most
+        likely locale for a territory you can use ``'und'`` as the
+        language tag:
+
+        >>> Locale.parse('und_AT')
+        Locale('de', territory='AT')
 
         :param identifier: the locale identifier string
         :param sep: optional component separator
@@ -291,11 +296,10 @@ class Locale(object):
             return locale
 
         # Now try without script and variant
-        lcoale = _try_load(parts2[:2])
+        locale = _try_load(parts2[:2])
         if locale is not None:
             return locale
 
-        # Give up.
         raise UnknownLocaleError(input_id)
 
     def __eq__(self, other):
index 7e13bf6b75459e1e15c97c2c91c815cede7546a7..ccc30fa62ff93789c5cfe69f648366180a14c175 100644 (file)
@@ -97,6 +97,10 @@ class TestLocaleClass:
         assert l.territory == 'TW'
         assert l.script == 'Hant'
 
+        l = Locale.parse('und_AT')
+        assert l.language == 'de'
+        assert l.territory == 'AT'
+
     def test_get_display_name(self):
         zh_CN = Locale('zh', 'CN', script='Hans')
         assert zh_CN.get_display_name('en') == 'Chinese (Simplified, China)'