3 Convert the X11 locale.alias file into a mapping dictionary suitable
6 Written by Marc-Andre Lemburg <mal@genix.com>, 2004-12-10.
11 # Location of the alias file
12 LOCALE_ALIAS
= '/usr/lib/X11/locale/locale.alias'
17 lines
= f
.read().splitlines()
25 locale
, alias
= line
.split()
30 locale
= locale
.lower()
31 # Ignore one letter locale mappings (except for 'c')
32 if len(locale
) == 1 and locale
!= 'c':
34 # Normalize encoding, if given
36 lang
, encoding
= locale
.split('.')[:2]
37 encoding
= encoding
.replace('-', '')
38 encoding
= encoding
.replace('_', '')
39 locale
= lang
+ '.' + encoding
40 if encoding
.lower() == 'utf8':
41 # Ignore UTF-8 mappings - this encoding should be
42 # available for all locales
52 print ' %-40s%r,' % ('%r:' % k
, v
)
54 def print_differences(data
, olddata
):
56 items
= olddata
.items()
59 if not data
.has_key(k
):
60 print '# removed %r' % k
61 elif olddata
[k
] != data
[k
]:
62 print '# updated %r -> %r to %r' % \
63 (k
, olddata
[k
], data
[k
])
64 # Additions are not mentioned
66 if __name__
== '__main__':
67 data
= locale
.locale_alias
.copy()
68 data
.update(parse(LOCALE_ALIAS
))
69 print_differences(data
, locale
.locale_alias
)
71 print 'locale_alias = {'