From 5eb01530b2bfba81b09e5129caabeada2d8dc487 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Thu, 26 Dec 2013 21:20:59 +0200 Subject: [PATCH] Issue #20027: Fixed locale aliases for devanagari locales. --- Lib/locale.py | 7 ++++--- Lib/test/test_locale.py | 14 ++++++++++++++ Misc/NEWS | 2 ++ Tools/i18n/makelocalealias.py | 6 ++++++ 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/Lib/locale.py b/Lib/locale.py index f9bceaf559a..7cfea618d77 100644 --- a/Lib/locale.py +++ b/Lib/locale.py @@ -1320,7 +1320,7 @@ locale_alias = { 'korean.euc': 'ko_KR.eucKR', 'ks': 'ks_IN.UTF-8', 'ks_in': 'ks_IN.UTF-8', - 'ks_in@devanagari': 'ks_IN@devanagari.UTF-8', + 'ks_in@devanagari': 'ks_IN.UTF-8@devanagari', 'kw': 'kw_GB.ISO8859-1', 'kw_gb': 'kw_GB.ISO8859-1', 'kw_gb.iso88591': 'kw_GB.ISO8859-1', @@ -1485,8 +1485,9 @@ locale_alias = { 'rw_rw': 'rw_RW.ISO8859-1', 'rw_rw.iso88591': 'rw_RW.ISO8859-1', 'sd': 'sd_IN.UTF-8', - 'sd@devanagari': 'sd_IN@devanagari.UTF-8', - 'sd_in@devanagari': 'sd_IN@devanagari.UTF-8', + 'sd@devanagari': 'sd_IN.UTF-8@devanagari', + 'sd_in': 'sd_IN.UTF-8', + 'sd_in@devanagari': 'sd_IN.UTF-8@devanagari', 'se_no': 'se_NO.UTF-8', 'serbocroatian': 'sr_RS.UTF-8@latin', 'sh': 'sr_RS.UTF-8@latin', diff --git a/Lib/test/test_locale.py b/Lib/test/test_locale.py index 45c0149f3b1..76347b7746d 100644 --- a/Lib/test/test_locale.py +++ b/Lib/test/test_locale.py @@ -421,6 +421,20 @@ class NormalizeTest(unittest.TestCase): self.check('ca_ES@valencia', 'ca_ES.ISO8859-1@valencia') self.check('ca@valencia', 'ca_ES.ISO8859-1@valencia') + def test_devanagari_modifier(self): + self.check('ks_IN.UTF-8@devanagari', 'ks_IN.UTF-8@devanagari') + self.check('ks_IN@devanagari', 'ks_IN.UTF-8@devanagari') + self.check('ks@devanagari', 'ks_IN.UTF-8@devanagari') + self.check('ks_IN.UTF-8', 'ks_IN.UTF-8') + self.check('ks_IN', 'ks_IN.UTF-8') + self.check('ks', 'ks_IN.UTF-8') + self.check('sd_IN.UTF-8@devanagari', 'sd_IN.UTF-8@devanagari') + self.check('sd_IN@devanagari', 'sd_IN.UTF-8@devanagari') + self.check('sd@devanagari', 'sd_IN.UTF-8@devanagari') + self.check('sd_IN.UTF-8', 'sd_IN.UTF-8') + self.check('sd_IN', 'sd_IN.UTF-8') + self.check('sd', 'sd_IN.UTF-8') + class TestMiscellaneous(unittest.TestCase): def test_getpreferredencoding(self): diff --git a/Misc/NEWS b/Misc/NEWS index c6f58334ba0..85b53543ab1 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -29,6 +29,8 @@ Core and Builtins Library ------- +- Issue #20027: Fixed locale aliases for devanagari locales. + - Issue #20067: Tkinter variables now work when wantobjects is false. - Issue #19020: Tkinter now uses splitlist() instead of split() in configure diff --git a/Tools/i18n/makelocalealias.py b/Tools/i18n/makelocalealias.py index 3445ec8020a..8b92ae1fc36 100644 --- a/Tools/i18n/makelocalealias.py +++ b/Tools/i18n/makelocalealias.py @@ -23,6 +23,12 @@ def parse(filename): if line[:1] == '#': continue locale, alias = line.split() + # Fix non-standard locale names, e.g. ks_IN@devanagari.UTF-8 + if '@' in alias: + alias_lang, _, alias_mod = alias.partition('@') + if '.' in alias_mod: + alias_mod, _, alias_enc = alias_mod.partition('.') + alias = alias_lang + '.' + alias_enc + '@' + alias_mod # Strip ':' if locale[-1] == ':': locale = locale[:-1]