Mercurial > babel > mirror
comparison babel/core.py @ 592:e6b1efa9a255 trunk
fix Locale.default to return Locales with correct territory information
author | fschwarz |
---|---|
date | Thu, 09 Aug 2012 07:47:09 +0000 |
parents | d1618dfaf114 |
children |
comparison
equal
deleted
inserted
replaced
591:d1618dfaf114 | 592:e6b1efa9a255 |
---|---|
142 | 142 |
143 >>> for name in ['LANGUAGE', 'LC_ALL', 'LC_CTYPE']: | 143 >>> for name in ['LANGUAGE', 'LC_ALL', 'LC_CTYPE']: |
144 ... os.environ[name] = '' | 144 ... os.environ[name] = '' |
145 >>> os.environ['LANG'] = 'fr_FR.UTF-8' | 145 >>> os.environ['LANG'] = 'fr_FR.UTF-8' |
146 >>> Locale.default('LC_MESSAGES') | 146 >>> Locale.default('LC_MESSAGES') |
147 Locale('fr_FR') | 147 Locale('fr', territory='FR') |
148 | 148 |
149 :param category: one of the ``LC_XXX`` environment variable names | 149 :param category: one of the ``LC_XXX`` environment variable names |
150 :param aliases: a dictionary of aliases for locale identifiers | 150 :param aliases: a dictionary of aliases for locale identifiers |
151 :return: the value of the variable, or any of the fallbacks | 151 :return: the value of the variable, or any of the fallbacks |
152 (``LANGUAGE``, ``LC_ALL``, ``LC_CTYPE``, and ``LANG``) | 152 (``LANGUAGE``, ``LC_ALL``, ``LC_CTYPE``, and ``LANG``) |
153 :rtype: `Locale` | 153 :rtype: `Locale` |
154 :see: `default_locale` | 154 :see: `default_locale` |
155 """ | 155 """ |
156 return cls(default_locale(category, aliases=aliases)) | 156 locale_string = default_locale(category, aliases=aliases) |
157 return cls.parse(locale_string) | |
157 | 158 |
158 @classmethod | 159 @classmethod |
159 def negotiate(cls, preferred, available, sep='_', aliases=LOCALE_ALIASES): | 160 def negotiate(cls, preferred, available, sep='_', aliases=LOCALE_ALIASES): |
160 """Find the best match between available and requested locale strings. | 161 """Find the best match between available and requested locale strings. |
161 | 162 |