Mercurial > babel > old > babel-test
comparison babel/core.py @ 534:e8da49740876
catch exception if environment contains an invalid locale setting (fixes #200)
author | fschwarz |
---|---|
date | Fri, 11 Mar 2011 16:20:57 +0000 |
parents | 85e1beadacb0 |
children | 423bb50cb8af |
comparison
equal
deleted
inserted
replaced
533:8262aa9c73da | 534:e8da49740876 |
---|---|
657 locale = locale.split(':')[0] | 657 locale = locale.split(':')[0] |
658 if locale in ('C', 'POSIX'): | 658 if locale in ('C', 'POSIX'): |
659 locale = 'en_US_POSIX' | 659 locale = 'en_US_POSIX' |
660 elif aliases and locale in aliases: | 660 elif aliases and locale in aliases: |
661 locale = aliases[locale] | 661 locale = aliases[locale] |
662 return '_'.join(filter(None, parse_locale(locale))) | 662 try: |
663 return '_'.join(filter(None, parse_locale(locale))) | |
664 except ValueError: | |
665 pass | |
663 | 666 |
664 def negotiate_locale(preferred, available, sep='_', aliases=LOCALE_ALIASES): | 667 def negotiate_locale(preferred, available, sep='_', aliases=LOCALE_ALIASES): |
665 """Find the best match between available and requested locale strings. | 668 """Find the best match between available and requested locale strings. |
666 | 669 |
667 >>> negotiate_locale(['de_DE', 'en_US'], ['de_DE', 'de_AT']) | 670 >>> negotiate_locale(['de_DE', 'en_US'], ['de_DE', 'de_AT']) |