From d551b2857145b189c7288f9c78b5d2e9dab5ffe8 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Thu, 26 Dec 2013 21:20:46 +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 4ca7d567e9e..96af6ddc3c7 100644 --- a/Lib/locale.py +++ b/Lib/locale.py @@ -1311,7 +1311,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', @@ -1476,8 +1476,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 b554d7774c3..3ca1aa046ac 100644 --- a/Lib/test/test_locale.py +++ b/Lib/test/test_locale.py @@ -428,6 +428,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 efe1cdd25a4..04f27701706 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -27,6 +27,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 5b3631edab3..d75892b73b8 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]