diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-12-26 22:56:53 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-12-26 22:56:53 (GMT) |
commit | 8c4f57d1d5b3550a859397f3bab54f560ad21074 (patch) | |
tree | c17975ec4141fbe7d2b748847e11d67bff98abfe /Tools/i18n | |
parent | 0e814634e5b279b3d8eb4987dc5039a0e8ec270e (diff) | |
download | cpython-8c4f57d1d5b3550a859397f3bab54f560ad21074.zip cpython-8c4f57d1d5b3550a859397f3bab54f560ad21074.tar.gz cpython-8c4f57d1d5b3550a859397f3bab54f560ad21074.tar.bz2 |
Issue #20046: Locale alias table no longer contains entities which can be
calculated. Generalized support of the euro modifier.
Diffstat (limited to 'Tools/i18n')
-rw-r--r-- | Tools/i18n/makelocalealias.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Tools/i18n/makelocalealias.py b/Tools/i18n/makelocalealias.py index 8b92ae1..10887ce 100644 --- a/Tools/i18n/makelocalealias.py +++ b/Tools/i18n/makelocalealias.py @@ -7,6 +7,7 @@ """ import locale +import sys # Location of the alias file LOCALE_ALIAS = '/usr/share/X11/locale/locale.alias' @@ -65,9 +66,35 @@ def print_differences(data, olddata): (k, olddata[k], data[k])) # Additions are not mentioned +def optimize(data): + locale_alias = locale.locale_alias + locale.locale_alias = data.copy() + for k, v in data.items(): + del locale.locale_alias[k] + if locale.normalize(k) != v: + locale.locale_alias[k] = v + newdata = locale.locale_alias + errors = check(data) + locale.locale_alias = locale_alias + if errors: + sys.exit(1) + return newdata + +def check(data): + # Check that all alias definitions from the X11 file + # are actually mapped to the correct alias locales. + errors = 0 + for k, v in data.items(): + if locale.normalize(k) != v: + print('ERROR: %a -> %a != %a' % (k, locale.normalize(k), v), + file=sys.stderr) + errors += 1 + return errors + if __name__ == '__main__': data = locale.locale_alias.copy() data.update(parse(LOCALE_ALIAS)) + data = optimize(data) print_differences(data, locale.locale_alias) print() print('locale_alias = {') |