blob: bf799529a46034ee4d11d2a0e5905e716457ff01 [file] [log] [blame]
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001""" Locale support.
Guido van Rossum4b8c6ea2000-02-04 15:39:30 +00002
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00003 The module provides low-level access to the C lib's locale APIs
4 and adds high level number formatting APIs as well as a locale
5 aliasing engine to complement these.
6
7 The aliasing engine includes support for many commonly used locale
8 names and maps them to values suitable for passing to the C lib's
9 setlocale() function. It also includes default encodings for all
10 supported locale names.
11
12"""
13
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +000014import sys, encodings, encodings.aliases
Marc-André Lemburg5431bc32000-06-07 09:11:40 +000015
Fredrik Lundh6c86b992000-07-09 17:12:58 +000016# Try importing the _locale module.
17#
18# If this fails, fall back on a basic 'C' locale emulation.
Guido van Rossumeef1d4e1997-11-19 19:01:43 +000019
Tim Peters1baf8292001-01-24 10:13:46 +000020# Yuck: LC_MESSAGES is non-standard: can't tell whether it exists before
21# trying the import. So __all__ is also fiddled at the end of the file.
Skip Montanaro17ab1232001-01-24 06:27:27 +000022__all__ = ["setlocale","Error","localeconv","strcoll","strxfrm",
23 "format","str","atof","atoi","LC_CTYPE","LC_COLLATE",
Tim Peters1baf8292001-01-24 10:13:46 +000024 "LC_TIME","LC_MONETARY","LC_NUMERIC", "LC_ALL","CHAR_MAX"]
Skip Montanaro17ab1232001-01-24 06:27:27 +000025
Marc-André Lemburg23481142000-06-08 17:49:41 +000026try:
Fredrik Lundh6c86b992000-07-09 17:12:58 +000027
Marc-André Lemburg23481142000-06-08 17:49:41 +000028 from _locale import *
29
30except ImportError:
31
Fredrik Lundh6c86b992000-07-09 17:12:58 +000032 # Locale emulation
33
Marc-André Lemburg23481142000-06-08 17:49:41 +000034 CHAR_MAX = 127
35 LC_ALL = 6
36 LC_COLLATE = 3
37 LC_CTYPE = 0
38 LC_MESSAGES = 5
39 LC_MONETARY = 4
40 LC_NUMERIC = 1
41 LC_TIME = 2
42 Error = ValueError
43
44 def localeconv():
Fredrik Lundh6c86b992000-07-09 17:12:58 +000045 """ localeconv() -> dict.
Marc-André Lemburg23481142000-06-08 17:49:41 +000046 Returns numeric and monetary locale-specific parameters.
47 """
48 # 'C' locale default values
49 return {'grouping': [127],
50 'currency_symbol': '',
51 'n_sign_posn': 127,
Fredrik Lundh6c86b992000-07-09 17:12:58 +000052 'p_cs_precedes': 127,
53 'n_cs_precedes': 127,
54 'mon_grouping': [],
Marc-André Lemburg23481142000-06-08 17:49:41 +000055 'n_sep_by_space': 127,
56 'decimal_point': '.',
57 'negative_sign': '',
58 'positive_sign': '',
Fredrik Lundh6c86b992000-07-09 17:12:58 +000059 'p_sep_by_space': 127,
Marc-André Lemburg23481142000-06-08 17:49:41 +000060 'int_curr_symbol': '',
Fredrik Lundh6c86b992000-07-09 17:12:58 +000061 'p_sign_posn': 127,
Marc-André Lemburg23481142000-06-08 17:49:41 +000062 'thousands_sep': '',
Fredrik Lundh6c86b992000-07-09 17:12:58 +000063 'mon_thousands_sep': '',
64 'frac_digits': 127,
Marc-André Lemburg23481142000-06-08 17:49:41 +000065 'mon_decimal_point': '',
66 'int_frac_digits': 127}
Fredrik Lundh6c86b992000-07-09 17:12:58 +000067
Marc-André Lemburg23481142000-06-08 17:49:41 +000068 def setlocale(category, value=None):
Fredrik Lundh6c86b992000-07-09 17:12:58 +000069 """ setlocale(integer,string=None) -> string.
Marc-André Lemburg23481142000-06-08 17:49:41 +000070 Activates/queries locale processing.
71 """
Martin v. Löwis103d6e72003-03-30 15:42:13 +000072 if value not in (None, '', 'C'):
Fredrik Lundh6c86b992000-07-09 17:12:58 +000073 raise Error, '_locale emulation only supports "C" locale'
Marc-André Lemburg23481142000-06-08 17:49:41 +000074 return 'C'
75
76 def strcoll(a,b):
Fredrik Lundh6c86b992000-07-09 17:12:58 +000077 """ strcoll(string,string) -> int.
Marc-André Lemburg23481142000-06-08 17:49:41 +000078 Compares two strings according to the locale.
79 """
80 return cmp(a,b)
81
82 def strxfrm(s):
Fredrik Lundh6c86b992000-07-09 17:12:58 +000083 """ strxfrm(string) -> string.
Marc-André Lemburg23481142000-06-08 17:49:41 +000084 Returns a string that behaves for cmp locale-aware.
85 """
86 return s
Marc-André Lemburg5431bc32000-06-07 09:11:40 +000087
88### Number formatting APIs
89
90# Author: Martin von Loewis
Guido van Rossumeef1d4e1997-11-19 19:01:43 +000091
92#perform the grouping from right to left
93def _group(s):
94 conv=localeconv()
95 grouping=conv['grouping']
Guido van Rossum67addfe2001-04-16 16:04:10 +000096 if not grouping:return (s, 0)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +000097 result=""
Martin v. Löwis88ad12a2001-04-13 08:09:50 +000098 seps = 0
99 spaces = ""
100 if s[-1] == ' ':
101 sp = s.find(' ')
102 spaces = s[sp:]
103 s = s[:sp]
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000104 while s and grouping:
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000105 # if grouping is -1, we are done
Guido van Rossum45e2fbc1998-03-26 21:13:24 +0000106 if grouping[0]==CHAR_MAX:
107 break
108 # 0: re-use last group ad infinitum
109 elif grouping[0]!=0:
110 #process last group
111 group=grouping[0]
112 grouping=grouping[1:]
113 if result:
114 result=s[-group:]+conv['thousands_sep']+result
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000115 seps += 1
Guido van Rossum45e2fbc1998-03-26 21:13:24 +0000116 else:
117 result=s[-group:]
118 s=s[:-group]
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000119 if s and s[-1] not in "0123456789":
120 # the leading string is only spaces and signs
121 return s+result+spaces,seps
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000122 if not result:
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000123 return s+spaces,seps
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000124 if s:
Guido van Rossum45e2fbc1998-03-26 21:13:24 +0000125 result=s+conv['thousands_sep']+result
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000126 seps += 1
127 return result+spaces,seps
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000128
129def format(f,val,grouping=0):
130 """Formats a value in the same way that the % formatting would use,
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000131 but takes the current locale into account.
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000132 Grouping is applied if the third parameter is true."""
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000133 result = f % val
Martin v. Löwisdb786872001-01-21 18:52:33 +0000134 fields = result.split(".")
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000135 seps = 0
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000136 if grouping:
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000137 fields[0],seps=_group(fields[0])
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000138 if len(fields)==2:
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000139 result = fields[0]+localeconv()['decimal_point']+fields[1]
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000140 elif len(fields)==1:
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000141 result = fields[0]
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000142 else:
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000143 raise Error, "Too many decimal points in result string"
144
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000145 while seps:
146 # If the number was formatted for a specific width, then it
147 # might have been filled with spaces to the left or right. If
148 # so, kill as much spaces as there where separators.
149 # Leading zeroes as fillers are not yet dealt with, as it is
150 # not clear how they should interact with grouping.
151 sp = result.find(" ")
152 if sp==-1:break
153 result = result[:sp]+result[sp+1:]
154 seps -= 1
155
156 return result
Martin v. Löwisdb786872001-01-21 18:52:33 +0000157
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000158def str(val):
159 """Convert float to integer, taking the locale into account."""
160 return format("%.12g",val)
161
Brett Cannonaaeffaf2004-03-23 23:50:17 +0000162def atof(string,func=float):
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000163 "Parses a string as a float according to the locale settings."
164 #First, get rid of the grouping
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000165 ts = localeconv()['thousands_sep']
166 if ts:
Skip Montanaro249369c2004-04-10 16:39:32 +0000167 string = string.replace(ts, '')
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000168 #next, replace the decimal point with a dot
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000169 dd = localeconv()['decimal_point']
170 if dd:
Skip Montanaro249369c2004-04-10 16:39:32 +0000171 string = string.replace(dd, '.')
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000172 #finally, parse the string
Skip Montanaro249369c2004-04-10 16:39:32 +0000173 return func(string)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000174
175def atoi(str):
176 "Converts a string to an integer according to the locale settings."
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000177 return atof(str, int)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000178
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000179def _test():
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000180 setlocale(LC_ALL, "")
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000181 #do grouping
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000182 s1=format("%d", 123456789,1)
183 print s1, "is", atoi(s1)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000184 #standard formatting
185 s1=str(3.14)
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000186 print s1, "is", atof(s1)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000187
188### Locale name aliasing engine
189
190# Author: Marc-Andre Lemburg, mal@lemburg.com
Fredrik Lundh37a09822002-10-19 20:19:10 +0000191# Various tweaks by Fredrik Lundh <fredrik@pythonware.com>
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000192
193# store away the low-level version of setlocale (it's
194# overridden below)
195_setlocale = setlocale
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000196
197def normalize(localename):
198
199 """ Returns a normalized locale code for the given locale
200 name.
201
202 The returned locale code is formatted for use with
203 setlocale().
204
205 If normalization fails, the original name is returned
206 unchanged.
207
208 If the given encoding is not known, the function defaults to
209 the default encoding for the locale code just like setlocale()
210 does.
211
212 """
213 # Normalize the locale name and extract the encoding
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000214 fullname = localename.lower()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000215 if ':' in fullname:
216 # ':' is sometimes used as encoding delimiter.
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000217 fullname = fullname.replace(':', '.')
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000218 if '.' in fullname:
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000219 langname, encoding = fullname.split('.')[:2]
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000220 fullname = langname + '.' + encoding
221 else:
222 langname = fullname
223 encoding = ''
224
225 # First lookup: fullname (possibly with encoding)
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000226 norm_encoding = encoding.replace('-', '')
227 norm_encoding = norm_encoding.replace('_', '')
228 lookup_name = langname + '.' + encoding
229 code = locale_alias.get(lookup_name, None)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000230 if code is not None:
231 return code
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000232 #print 'first lookup failed'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000233
234 # Second try: langname (without encoding)
235 code = locale_alias.get(langname, None)
236 if code is not None:
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000237 #print 'langname lookup succeeded'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000238 if '.' in code:
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000239 langname, defenc = code.split('.')
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000240 else:
241 langname = code
242 defenc = ''
243 if encoding:
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000244 # Convert the encoding to a C lib compatible encoding string
245 norm_encoding = encodings.normalize_encoding(encoding)
246 #print 'norm encoding: %r' % norm_encoding
247 norm_encoding = encodings.aliases.aliases.get(norm_encoding,
248 norm_encoding)
249 #print 'aliased encoding: %r' % norm_encoding
250 encoding = locale_encoding_alias.get(norm_encoding,
251 norm_encoding)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000252 else:
253 encoding = defenc
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000254 #print 'found encoding %r' % encoding
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000255 if encoding:
256 return langname + '.' + encoding
257 else:
258 return langname
259
260 else:
261 return localename
262
263def _parse_localename(localename):
264
265 """ Parses the locale code for localename and returns the
266 result as tuple (language code, encoding).
267
268 The localename is normalized and passed through the locale
269 alias engine. A ValueError is raised in case the locale name
270 cannot be parsed.
271
272 The language code corresponds to RFC 1766. code and encoding
273 can be None in case the values cannot be determined or are
Jeremy Hyltona05e2932000-06-28 14:48:01 +0000274 unknown to this implementation.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000275
276 """
277 code = normalize(localename)
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000278 if '@' in localename:
279 # Deal with locale modifiers
280 code, modifier = code.split('@')
281 if modifier == 'euro' and '.' not in code:
282 # Assume Latin-9 for @euro locales. This is bogus,
283 # since some systems may use other encodings for these
284 # locales. Also, we ignore other modifiers.
285 return code, 'iso-8859-15'
Tim Peters230a60c2002-11-09 05:08:07 +0000286
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000287 if '.' in code:
Raymond Hettinger346e67f2005-01-01 06:10:26 +0000288 return tuple(code.split('.')[:2])
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000289 elif code == 'C':
290 return None, None
Andrew M. Kuchling1f877ef2001-08-13 14:50:44 +0000291 raise ValueError, 'unknown locale: %s' % localename
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000292
293def _build_localename(localetuple):
294
295 """ Builds a locale code from the given tuple (language code,
296 encoding).
297
298 No aliasing or normalizing takes place.
299
300 """
301 language, encoding = localetuple
302 if language is None:
303 language = 'C'
304 if encoding is None:
305 return language
306 else:
307 return language + '.' + encoding
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000308
309def getdefaultlocale(envvars=('LANGUAGE', 'LC_ALL', 'LC_CTYPE', 'LANG')):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000310
311 """ Tries to determine the default locale settings and returns
312 them as tuple (language code, encoding).
313
314 According to POSIX, a program which has not called
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000315 setlocale(LC_ALL, "") runs using the portable 'C' locale.
316 Calling setlocale(LC_ALL, "") lets it use the default locale as
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000317 defined by the LANG variable. Since we don't want to interfere
Thomas Wouters7e474022000-07-16 12:04:32 +0000318 with the current locale setting we thus emulate the behavior
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000319 in the way described above.
320
321 To maintain compatibility with other platforms, not only the
322 LANG variable is tested, but a list of variables given as
323 envvars parameter. The first found to be defined will be
324 used. envvars defaults to the search path used in GNU gettext;
325 it must always contain the variable name 'LANG'.
326
327 Except for the code 'C', the language code corresponds to RFC
328 1766. code and encoding can be None in case the values cannot
329 be determined.
330
331 """
Fredrik Lundh04661322000-07-09 23:16:10 +0000332
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000333 try:
334 # check if it's supported by the _locale module
335 import _locale
336 code, encoding = _locale._getdefaultlocale()
Fredrik Lundh04661322000-07-09 23:16:10 +0000337 except (ImportError, AttributeError):
338 pass
339 else:
Fredrik Lundh663809e2000-07-10 19:32:19 +0000340 # make sure the code/encoding values are valid
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000341 if sys.platform == "win32" and code and code[:2] == "0x":
342 # map windows language identifier to language name
343 code = windows_locale.get(int(code, 0))
Fredrik Lundh663809e2000-07-10 19:32:19 +0000344 # ...add other platform-specific processing here, if
345 # necessary...
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000346 return code, encoding
Fredrik Lundh04661322000-07-09 23:16:10 +0000347
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000348 # fall back on POSIX behaviour
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000349 import os
350 lookup = os.environ.get
351 for variable in envvars:
352 localename = lookup(variable,None)
Martin v. Löwisc8ae31d2004-07-26 12:45:18 +0000353 if localename:
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000354 break
355 else:
356 localename = 'C'
357 return _parse_localename(localename)
358
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000359
360def getlocale(category=LC_CTYPE):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000361
362 """ Returns the current setting for the given locale category as
363 tuple (language code, encoding).
364
365 category may be one of the LC_* value except LC_ALL. It
366 defaults to LC_CTYPE.
367
368 Except for the code 'C', the language code corresponds to RFC
369 1766. code and encoding can be None in case the values cannot
370 be determined.
371
372 """
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000373 localename = _setlocale(category)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000374 if category == LC_ALL and ';' in localename:
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000375 raise TypeError, 'category LC_ALL is not supported'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000376 return _parse_localename(localename)
377
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000378def setlocale(category, locale=None):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000379
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000380 """ Set the locale for the given category. The locale can be
381 a string, a locale tuple (language code, encoding), or None.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000382
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000383 Locale tuples are converted to strings the locale aliasing
384 engine. Locale strings are passed directly to the C lib.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000385
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000386 category may be given as one of the LC_* values.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000387
388 """
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000389 if locale and type(locale) is not type(""):
390 # convert to string
391 locale = normalize(_build_localename(locale))
392 return _setlocale(category, locale)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000393
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000394def resetlocale(category=LC_ALL):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000395
396 """ Sets the locale for category to the default setting.
397
398 The default setting is determined by calling
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000399 getdefaultlocale(). category defaults to LC_ALL.
400
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000401 """
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000402 _setlocale(category, _build_localename(getdefaultlocale()))
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000403
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000404if sys.platform in ('win32', 'darwin', 'mac'):
405 # On Win32, this will return the ANSI code page
406 # On the Mac, it should return the system encoding;
407 # it might return "ascii" instead
408 def getpreferredencoding(do_setlocale = True):
409 """Return the charset that the user is likely using."""
410 import _locale
Tim Petersa326f472002-11-05 03:49:09 +0000411 return _locale._getdefaultlocale()[1]
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000412else:
413 # On Unix, if CODESET is available, use that.
414 try:
415 CODESET
416 except NameError:
417 # Fall back to parsing environment variables :-(
418 def getpreferredencoding(do_setlocale = True):
419 """Return the charset that the user is likely using,
420 by looking at environment variables."""
421 return getdefaultlocale()[1]
422 else:
423 def getpreferredencoding(do_setlocale = True):
424 """Return the charset that the user is likely using,
425 according to the system configuration."""
426 if do_setlocale:
427 oldloc = setlocale(LC_CTYPE)
428 setlocale(LC_CTYPE, "")
429 result = nl_langinfo(CODESET)
430 setlocale(LC_CTYPE, oldloc)
431 return result
432 else:
433 return nl_langinfo(CODESET)
Tim Peters230a60c2002-11-09 05:08:07 +0000434
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000435
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000436### Database
437#
438# The following data was extracted from the locale.alias file which
439# comes with X11 and then hand edited removing the explicit encoding
440# definitions and adding some more aliases. The file is usually
441# available as /usr/lib/X11/locale/locale.alias.
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000442#
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000443
444#
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000445# The local_encoding_alias table maps lowercase encoding alias names
446# to C locale encoding names (case-sensitive). Note that normalize()
447# first looks up the encoding in the encodings.aliases dictionary and
448# then applies this mapping to find the correct C lib name for the
449# encoding.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000450#
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000451locale_encoding_alias = {
452
453 # Mappings for non-standard encoding names used in locale names
454 '437': 'C',
455 'c': 'C',
456 'en': 'ISO8859-1',
457 'jis': 'JIS7',
458 'jis7': 'JIS7',
459 'ajec': 'eucJP',
460
461 # Mappings from Python codec names to C lib encoding names
462 'ascii': 'ISO8859-1',
463 'latin_1': 'ISO8859-1',
464 'iso8859_1': 'ISO8859-1',
465 'iso8859_10': 'ISO8859-10',
466 'iso8859_11': 'ISO8859-11',
467 'iso8859_13': 'ISO8859-13',
468 'iso8859_14': 'ISO8859-14',
469 'iso8859_15': 'ISO8859-15',
470 'iso8859_2': 'ISO8859-2',
471 'iso8859_3': 'ISO8859-3',
472 'iso8859_4': 'ISO8859-4',
473 'iso8859_5': 'ISO8859-5',
474 'iso8859_6': 'ISO8859-6',
475 'iso8859_7': 'ISO8859-7',
476 'iso8859_8': 'ISO8859-8',
477 'iso8859_9': 'ISO8859-9',
478 'iso2022_jp': 'JIS7',
479 'shift_jis': 'SJIS',
480 'tactis': 'TACTIS',
481 'euc_jp': 'eucJP',
482 'euc_kr': 'eucKR',
Marc-André Lemburgb4cebd42004-12-13 19:56:01 +0000483 'utf_8': 'UTF8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000484 'koi8_r': 'KOI8-R',
485 'koi8_u': 'KOI8-U',
486 # XXX This list is still incomplete. If you know more
487 # mappings, please file a bug report. Thanks.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000488}
489
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000490#
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000491# The locale_alias table maps lowercase alias names to C locale names
492# (case-sensitive). Encodings are always separated from the locale
493# name using a dot ('.'); they should only be given in case the
494# language name is needed to interpret the given encoding alias
495# correctly (CJK codes often have this need).
496#
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000497# Note that the normalize() function which uses this tables
498# removes '_' and '-' characters from the encoding part of the
499# locale name before doing the lookup. This saves a lot of
500# space in the table.
501#
502# MAL 2004-12-10:
503# Updated alias mapping to most recent locale.alias file
504# from X.org distribution using makelocalealias.py.
505#
506# These are the differences compared to the old mapping (Python 2.4
507# and older):
508#
509# updated 'bg' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
510# updated 'bg_bg' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
511# updated 'bulgarian' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
512# updated 'cz' -> 'cz_CZ.ISO8859-2' to 'cs_CZ.ISO8859-2'
513# updated 'cz_cz' -> 'cz_CZ.ISO8859-2' to 'cs_CZ.ISO8859-2'
514# updated 'czech' -> 'cs_CS.ISO8859-2' to 'cs_CZ.ISO8859-2'
515# updated 'dutch' -> 'nl_BE.ISO8859-1' to 'nl_NL.ISO8859-1'
516# updated 'et' -> 'et_EE.ISO8859-4' to 'et_EE.ISO8859-15'
517# updated 'et_ee' -> 'et_EE.ISO8859-4' to 'et_EE.ISO8859-15'
518# updated 'fi' -> 'fi_FI.ISO8859-1' to 'fi_FI.ISO8859-15'
519# updated 'fi_fi' -> 'fi_FI.ISO8859-1' to 'fi_FI.ISO8859-15'
520# updated 'iw' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
521# updated 'iw_il' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
522# updated 'japanese' -> 'ja_JP.SJIS' to 'ja_JP.eucJP'
523# updated 'lt' -> 'lt_LT.ISO8859-4' to 'lt_LT.ISO8859-13'
524# updated 'lv' -> 'lv_LV.ISO8859-4' to 'lv_LV.ISO8859-13'
525# updated 'sl' -> 'sl_CS.ISO8859-2' to 'sl_SI.ISO8859-2'
526# updated 'slovene' -> 'sl_CS.ISO8859-2' to 'sl_SI.ISO8859-2'
527# updated 'th_th' -> 'th_TH.TACTIS' to 'th_TH.ISO8859-11'
528# updated 'zh_cn' -> 'zh_CN.eucCN' to 'zh_CN.gb2312'
529# updated 'zh_cn.big5' -> 'zh_TW.eucTW' to 'zh_TW.big5'
530# updated 'zh_tw' -> 'zh_TW.eucTW' to 'zh_TW.big5'
531#
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000532locale_alias = {
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000533 'a3': 'a3_AZ.KOI8-C',
534 'a3_az': 'a3_AZ.KOI8-C',
535 'a3_az.koi8c': 'a3_AZ.KOI8-C',
536 'af': 'af_ZA.ISO8859-1',
537 'af_za': 'af_ZA.ISO8859-1',
538 'af_za.iso88591': 'af_ZA.ISO8859-1',
539 'am': 'am_ET.UTF-8',
540 'american': 'en_US.ISO8859-1',
541 'american.iso88591': 'en_US.ISO8859-1',
542 'ar': 'ar_AA.ISO8859-6',
543 'ar_aa': 'ar_AA.ISO8859-6',
544 'ar_aa.iso88596': 'ar_AA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000545 'ar_ae': 'ar_AE.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000546 'ar_bh': 'ar_BH.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000547 'ar_dz': 'ar_DZ.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000548 'ar_eg': 'ar_EG.ISO8859-6',
549 'ar_eg.iso88596': 'ar_EG.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000550 'ar_iq': 'ar_IQ.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000551 'ar_jo': 'ar_JO.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000552 'ar_kw': 'ar_KW.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000553 'ar_lb': 'ar_LB.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000554 'ar_ly': 'ar_LY.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000555 'ar_ma': 'ar_MA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000556 'ar_om': 'ar_OM.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000557 'ar_qa': 'ar_QA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000558 'ar_sa': 'ar_SA.ISO8859-6',
559 'ar_sa.iso88596': 'ar_SA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000560 'ar_sd': 'ar_SD.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000561 'ar_sy': 'ar_SY.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000562 'ar_tn': 'ar_TN.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000563 'ar_ye': 'ar_YE.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000564 'arabic': 'ar_AA.ISO8859-6',
565 'arabic.iso88596': 'ar_AA.ISO8859-6',
566 'az': 'az_AZ.ISO8859-9E',
567 'az_az': 'az_AZ.ISO8859-9E',
568 'az_az.iso88599e': 'az_AZ.ISO8859-9E',
569 'be': 'be_BY.CP1251',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000570 'be_by': 'be_BY.CP1251',
571 'be_by.cp1251': 'be_BY.CP1251',
572 'be_by.microsoftcp1251': 'be_BY.CP1251',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000573 'bg': 'bg_BG.CP1251',
574 'bg_bg': 'bg_BG.CP1251',
575 'bg_bg.cp1251': 'bg_BG.CP1251',
576 'bg_bg.iso88595': 'bg_BG.ISO8859-5',
577 'bg_bg.koi8r': 'bg_BG.KOI8-R',
578 'bg_bg.microsoftcp1251': 'bg_BG.CP1251',
579 'bokmal': 'nb_NO.ISO8859-1',
580 'bokm\xe5l': 'nb_NO.ISO8859-1',
581 'br': 'br_FR.ISO8859-1',
582 'br_fr': 'br_FR.ISO8859-1',
583 'br_fr.iso88591': 'br_FR.ISO8859-1',
584 'br_fr.iso885914': 'br_FR.ISO8859-14',
585 'br_fr.iso885915': 'br_FR.ISO8859-15',
586 'br_fr@euro': 'br_FR.ISO8859-15',
587 'bulgarian': 'bg_BG.CP1251',
588 'c': 'C',
589 'c-french': 'fr_CA.ISO8859-1',
590 'c-french.iso88591': 'fr_CA.ISO8859-1',
591 'c.en': 'C',
592 'c.iso88591': 'en_US.ISO8859-1',
593 'c_c': 'C',
594 'c_c.c': 'C',
595 'ca': 'ca_ES.ISO8859-1',
596 'ca_es': 'ca_ES.ISO8859-1',
597 'ca_es.iso88591': 'ca_ES.ISO8859-1',
598 'ca_es.iso885915': 'ca_ES.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000599 'ca_es@euro': 'ca_ES.ISO8859-15',
600 'catalan': 'ca_ES.ISO8859-1',
601 'cextend': 'en_US.ISO8859-1',
602 'cextend.en': 'en_US.ISO8859-1',
603 'chinese-s': 'zh_CN.eucCN',
604 'chinese-t': 'zh_TW.eucTW',
605 'croatian': 'hr_HR.ISO8859-2',
606 'cs': 'cs_CZ.ISO8859-2',
607 'cs_cs': 'cs_CZ.ISO8859-2',
608 'cs_cs.iso88592': 'cs_CZ.ISO8859-2',
609 'cs_cz': 'cs_CZ.ISO8859-2',
610 'cs_cz.iso88592': 'cs_CZ.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000611 'cy': 'cy_GB.ISO8859-1',
612 'cy_gb': 'cy_GB.ISO8859-1',
613 'cy_gb.iso88591': 'cy_GB.ISO8859-1',
614 'cy_gb.iso885914': 'cy_GB.ISO8859-14',
615 'cy_gb.iso885915': 'cy_GB.ISO8859-15',
616 'cy_gb@euro': 'cy_GB.ISO8859-15',
617 'cz': 'cs_CZ.ISO8859-2',
618 'cz_cz': 'cs_CZ.ISO8859-2',
619 'czech': 'cs_CZ.ISO8859-2',
620 'da': 'da_DK.ISO8859-1',
621 'da_dk': 'da_DK.ISO8859-1',
622 'da_dk.88591': 'da_DK.ISO8859-1',
623 'da_dk.885915': 'da_DK.ISO8859-15',
624 'da_dk.iso88591': 'da_DK.ISO8859-1',
625 'da_dk.iso885915': 'da_DK.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000626 'da_dk@euro': 'da_DK.ISO8859-15',
627 'danish': 'da_DK.ISO8859-1',
628 'danish.iso88591': 'da_DK.ISO8859-1',
629 'dansk': 'da_DK.ISO8859-1',
630 'de': 'de_DE.ISO8859-1',
631 'de_at': 'de_AT.ISO8859-1',
632 'de_at.iso88591': 'de_AT.ISO8859-1',
633 'de_at.iso885915': 'de_AT.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000634 'de_at@euro': 'de_AT.ISO8859-15',
635 'de_be': 'de_BE.ISO8859-1',
636 'de_be.iso88591': 'de_BE.ISO8859-1',
637 'de_be.iso885915': 'de_BE.ISO8859-15',
638 'de_be@euro': 'de_BE.ISO8859-15',
639 'de_ch': 'de_CH.ISO8859-1',
640 'de_ch.iso88591': 'de_CH.ISO8859-1',
641 'de_ch.iso885915': 'de_CH.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000642 'de_ch@euro': 'de_CH.ISO8859-15',
643 'de_de': 'de_DE.ISO8859-1',
644 'de_de.88591': 'de_DE.ISO8859-1',
645 'de_de.885915': 'de_DE.ISO8859-15',
646 'de_de.885915@euro': 'de_DE.ISO8859-15',
647 'de_de.iso88591': 'de_DE.ISO8859-1',
648 'de_de.iso885915': 'de_DE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000649 'de_de@euro': 'de_DE.ISO8859-15',
650 'de_lu': 'de_LU.ISO8859-1',
651 'de_lu.iso88591': 'de_LU.ISO8859-1',
652 'de_lu.iso885915': 'de_LU.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000653 'de_lu@euro': 'de_LU.ISO8859-15',
654 'deutsch': 'de_DE.ISO8859-1',
655 'dutch': 'nl_NL.ISO8859-1',
656 'dutch.iso88591': 'nl_BE.ISO8859-1',
657 'ee': 'ee_EE.ISO8859-4',
658 'ee_ee': 'ee_EE.ISO8859-4',
659 'ee_ee.iso88594': 'ee_EE.ISO8859-4',
660 'eesti': 'et_EE.ISO8859-1',
661 'el': 'el_GR.ISO8859-7',
662 'el_gr': 'el_GR.ISO8859-7',
663 'el_gr.iso88597': 'el_GR.ISO8859-7',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000664 'el_gr@euro': 'el_GR.ISO8859-15',
665 'en': 'en_US.ISO8859-1',
666 'en.iso88591': 'en_US.ISO8859-1',
667 'en_au': 'en_AU.ISO8859-1',
668 'en_au.iso88591': 'en_AU.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000669 'en_be': 'en_BE.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000670 'en_be@euro': 'en_BE.ISO8859-15',
671 'en_bw': 'en_BW.ISO8859-1',
672 'en_ca': 'en_CA.ISO8859-1',
673 'en_ca.iso88591': 'en_CA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000674 'en_gb': 'en_GB.ISO8859-1',
675 'en_gb.88591': 'en_GB.ISO8859-1',
676 'en_gb.iso88591': 'en_GB.ISO8859-1',
677 'en_gb.iso885915': 'en_GB.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000678 'en_gb@euro': 'en_GB.ISO8859-15',
679 'en_hk': 'en_HK.ISO8859-1',
680 'en_ie': 'en_IE.ISO8859-1',
681 'en_ie.iso88591': 'en_IE.ISO8859-1',
682 'en_ie.iso885915': 'en_IE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000683 'en_ie@euro': 'en_IE.ISO8859-15',
684 'en_in': 'en_IN.ISO8859-1',
685 'en_nz': 'en_NZ.ISO8859-1',
686 'en_nz.iso88591': 'en_NZ.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000687 'en_ph': 'en_PH.ISO8859-1',
688 'en_sg': 'en_SG.ISO8859-1',
689 'en_uk': 'en_GB.ISO8859-1',
690 'en_us': 'en_US.ISO8859-1',
691 'en_us.88591': 'en_US.ISO8859-1',
692 'en_us.885915': 'en_US.ISO8859-15',
693 'en_us.iso88591': 'en_US.ISO8859-1',
694 'en_us.iso885915': 'en_US.ISO8859-15',
695 'en_us.iso885915@euro': 'en_US.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000696 'en_us@euro': 'en_US.ISO8859-15',
697 'en_us@euro@euro': 'en_US.ISO8859-15',
698 'en_za': 'en_ZA.ISO8859-1',
699 'en_za.88591': 'en_ZA.ISO8859-1',
700 'en_za.iso88591': 'en_ZA.ISO8859-1',
701 'en_za.iso885915': 'en_ZA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000702 'en_za@euro': 'en_ZA.ISO8859-15',
703 'en_zw': 'en_ZW.ISO8859-1',
704 'eng_gb': 'en_GB.ISO8859-1',
705 'eng_gb.8859': 'en_GB.ISO8859-1',
706 'english': 'en_EN.ISO8859-1',
707 'english.iso88591': 'en_EN.ISO8859-1',
708 'english_uk': 'en_GB.ISO8859-1',
709 'english_uk.8859': 'en_GB.ISO8859-1',
710 'english_united-states': 'en_US.ISO8859-1',
711 'english_united-states.437': 'C',
712 'english_us': 'en_US.ISO8859-1',
713 'english_us.8859': 'en_US.ISO8859-1',
714 'english_us.ascii': 'en_US.ISO8859-1',
715 'eo': 'eo_XX.ISO8859-3',
716 'eo_eo': 'eo_EO.ISO8859-3',
717 'eo_eo.iso88593': 'eo_EO.ISO8859-3',
718 'eo_xx': 'eo_XX.ISO8859-3',
719 'eo_xx.iso88593': 'eo_XX.ISO8859-3',
720 'es': 'es_ES.ISO8859-1',
721 'es_ar': 'es_AR.ISO8859-1',
722 'es_ar.iso88591': 'es_AR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000723 'es_bo': 'es_BO.ISO8859-1',
724 'es_bo.iso88591': 'es_BO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000725 'es_cl': 'es_CL.ISO8859-1',
726 'es_cl.iso88591': 'es_CL.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000727 'es_co': 'es_CO.ISO8859-1',
728 'es_co.iso88591': 'es_CO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000729 'es_cr': 'es_CR.ISO8859-1',
730 'es_cr.iso88591': 'es_CR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000731 'es_do': 'es_DO.ISO8859-1',
732 'es_do.iso88591': 'es_DO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000733 'es_ec': 'es_EC.ISO8859-1',
734 'es_ec.iso88591': 'es_EC.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000735 'es_es': 'es_ES.ISO8859-1',
736 'es_es.88591': 'es_ES.ISO8859-1',
737 'es_es.iso88591': 'es_ES.ISO8859-1',
738 'es_es.iso885915': 'es_ES.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000739 'es_es@euro': 'es_ES.ISO8859-15',
740 'es_gt': 'es_GT.ISO8859-1',
741 'es_gt.iso88591': 'es_GT.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000742 'es_hn': 'es_HN.ISO8859-1',
743 'es_hn.iso88591': 'es_HN.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000744 'es_mx': 'es_MX.ISO8859-1',
745 'es_mx.iso88591': 'es_MX.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000746 'es_ni': 'es_NI.ISO8859-1',
747 'es_ni.iso88591': 'es_NI.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000748 'es_pa': 'es_PA.ISO8859-1',
749 'es_pa.iso88591': 'es_PA.ISO8859-1',
750 'es_pa.iso885915': 'es_PA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000751 'es_pa@euro': 'es_PA.ISO8859-15',
752 'es_pe': 'es_PE.ISO8859-1',
753 'es_pe.iso88591': 'es_PE.ISO8859-1',
754 'es_pe.iso885915': 'es_PE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000755 'es_pe@euro': 'es_PE.ISO8859-15',
756 'es_pr': 'es_PR.ISO8859-1',
757 'es_pr.iso88591': 'es_PR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000758 'es_py': 'es_PY.ISO8859-1',
759 'es_py.iso88591': 'es_PY.ISO8859-1',
760 'es_py.iso885915': 'es_PY.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000761 'es_py@euro': 'es_PY.ISO8859-15',
762 'es_sv': 'es_SV.ISO8859-1',
763 'es_sv.iso88591': 'es_SV.ISO8859-1',
764 'es_sv.iso885915': 'es_SV.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000765 'es_sv@euro': 'es_SV.ISO8859-15',
766 'es_us': 'es_US.ISO8859-1',
767 'es_uy': 'es_UY.ISO8859-1',
768 'es_uy.iso88591': 'es_UY.ISO8859-1',
769 'es_uy.iso885915': 'es_UY.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000770 'es_uy@euro': 'es_UY.ISO8859-15',
771 'es_ve': 'es_VE.ISO8859-1',
772 'es_ve.iso88591': 'es_VE.ISO8859-1',
773 'es_ve.iso885915': 'es_VE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000774 'es_ve@euro': 'es_VE.ISO8859-15',
775 'estonian': 'et_EE.ISO8859-1',
776 'et': 'et_EE.ISO8859-15',
777 'et_ee': 'et_EE.ISO8859-15',
778 'et_ee.iso88591': 'et_EE.ISO8859-1',
779 'et_ee.iso885913': 'et_EE.ISO8859-13',
780 'et_ee.iso885915': 'et_EE.ISO8859-15',
781 'et_ee.iso88594': 'et_EE.ISO8859-4',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000782 'et_ee@euro': 'et_EE.ISO8859-15',
783 'eu': 'eu_ES.ISO8859-1',
784 'eu_es': 'eu_ES.ISO8859-1',
785 'eu_es.iso88591': 'eu_ES.ISO8859-1',
786 'eu_es.iso885915': 'eu_ES.ISO8859-15',
787 'eu_es@euro': 'eu_ES.ISO8859-15',
788 'fa': 'fa_IR.UTF-8',
789 'fa_ir': 'fa_IR.UTF-8',
790 'fa_ir.isiri3342': 'fa_IR.ISIRI-3342',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000791 'fi': 'fi_FI.ISO8859-15',
792 'fi_fi': 'fi_FI.ISO8859-15',
793 'fi_fi.88591': 'fi_FI.ISO8859-1',
794 'fi_fi.iso88591': 'fi_FI.ISO8859-1',
795 'fi_fi.iso885915': 'fi_FI.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000796 'fi_fi.utf8@euro': 'fi_FI.UTF-8',
797 'fi_fi@euro': 'fi_FI.ISO8859-15',
798 'finnish': 'fi_FI.ISO8859-1',
799 'finnish.iso88591': 'fi_FI.ISO8859-1',
800 'fo': 'fo_FO.ISO8859-1',
801 'fo_fo': 'fo_FO.ISO8859-1',
802 'fo_fo.iso88591': 'fo_FO.ISO8859-1',
803 'fo_fo.iso885915': 'fo_FO.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000804 'fo_fo@euro': 'fo_FO.ISO8859-15',
805 'fr': 'fr_FR.ISO8859-1',
806 'fr_be': 'fr_BE.ISO8859-1',
807 'fr_be.88591': 'fr_BE.ISO8859-1',
808 'fr_be.iso88591': 'fr_BE.ISO8859-1',
809 'fr_be.iso885915': 'fr_BE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000810 'fr_be@euro': 'fr_BE.ISO8859-15',
811 'fr_ca': 'fr_CA.ISO8859-1',
812 'fr_ca.88591': 'fr_CA.ISO8859-1',
813 'fr_ca.iso88591': 'fr_CA.ISO8859-1',
814 'fr_ca.iso885915': 'fr_CA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000815 'fr_ca@euro': 'fr_CA.ISO8859-15',
816 'fr_ch': 'fr_CH.ISO8859-1',
817 'fr_ch.88591': 'fr_CH.ISO8859-1',
818 'fr_ch.iso88591': 'fr_CH.ISO8859-1',
819 'fr_ch.iso885915': 'fr_CH.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000820 'fr_ch@euro': 'fr_CH.ISO8859-15',
821 'fr_fr': 'fr_FR.ISO8859-1',
822 'fr_fr.88591': 'fr_FR.ISO8859-1',
823 'fr_fr.iso88591': 'fr_FR.ISO8859-1',
824 'fr_fr.iso885915': 'fr_FR.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000825 'fr_fr@euro': 'fr_FR.ISO8859-15',
826 'fr_lu': 'fr_LU.ISO8859-1',
827 'fr_lu.88591': 'fr_LU.ISO8859-1',
828 'fr_lu.iso88591': 'fr_LU.ISO8859-1',
829 'fr_lu.iso885915': 'fr_LU.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000830 'fr_lu@euro': 'fr_LU.ISO8859-15',
831 'fran\xe7ais': 'fr_FR.ISO8859-1',
832 'fre_fr': 'fr_FR.ISO8859-1',
833 'fre_fr.8859': 'fr_FR.ISO8859-1',
834 'french': 'fr_FR.ISO8859-1',
835 'french.iso88591': 'fr_CH.ISO8859-1',
836 'french_france': 'fr_FR.ISO8859-1',
837 'french_france.8859': 'fr_FR.ISO8859-1',
838 'ga': 'ga_IE.ISO8859-1',
839 'ga_ie': 'ga_IE.ISO8859-1',
840 'ga_ie.iso88591': 'ga_IE.ISO8859-1',
841 'ga_ie.iso885914': 'ga_IE.ISO8859-14',
842 'ga_ie.iso885915': 'ga_IE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000843 'ga_ie@euro': 'ga_IE.ISO8859-15',
844 'galego': 'gl_ES.ISO8859-1',
845 'galician': 'gl_ES.ISO8859-1',
846 'gd': 'gd_GB.ISO8859-1',
847 'gd_gb': 'gd_GB.ISO8859-1',
848 'gd_gb.iso88591': 'gd_GB.ISO8859-1',
849 'gd_gb.iso885914': 'gd_GB.ISO8859-14',
850 'gd_gb.iso885915': 'gd_GB.ISO8859-15',
851 'gd_gb@euro': 'gd_GB.ISO8859-15',
852 'ger_de': 'de_DE.ISO8859-1',
853 'ger_de.8859': 'de_DE.ISO8859-1',
854 'german': 'de_DE.ISO8859-1',
855 'german.iso88591': 'de_CH.ISO8859-1',
856 'german_germany': 'de_DE.ISO8859-1',
857 'german_germany.8859': 'de_DE.ISO8859-1',
858 'gl': 'gl_ES.ISO8859-1',
859 'gl_es': 'gl_ES.ISO8859-1',
860 'gl_es.iso88591': 'gl_ES.ISO8859-1',
861 'gl_es.iso885915': 'gl_ES.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000862 'gl_es@euro': 'gl_ES.ISO8859-15',
863 'greek': 'el_GR.ISO8859-7',
864 'greek.iso88597': 'el_GR.ISO8859-7',
865 'gv': 'gv_GB.ISO8859-1',
866 'gv_gb': 'gv_GB.ISO8859-1',
867 'gv_gb.iso88591': 'gv_GB.ISO8859-1',
868 'gv_gb.iso885914': 'gv_GB.ISO8859-14',
869 'gv_gb.iso885915': 'gv_GB.ISO8859-15',
870 'gv_gb@euro': 'gv_GB.ISO8859-15',
871 'he': 'he_IL.ISO8859-8',
872 'he_il': 'he_IL.ISO8859-8',
873 'he_il.cp1255': 'he_IL.CP1255',
874 'he_il.iso88598': 'he_IL.ISO8859-8',
875 'he_il.microsoftcp1255': 'he_IL.CP1255',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000876 'hebrew': 'iw_IL.ISO8859-8',
877 'hebrew.iso88598': 'iw_IL.ISO8859-8',
878 'hi': 'hi_IN.ISCII-DEV',
879 'hi_in': 'hi_IN.ISCII-DEV',
880 'hi_in.isciidev': 'hi_IN.ISCII-DEV',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000881 'hr': 'hr_HR.ISO8859-2',
882 'hr_hr': 'hr_HR.ISO8859-2',
883 'hr_hr.iso88592': 'hr_HR.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000884 'hrvatski': 'hr_HR.ISO8859-2',
885 'hu': 'hu_HU.ISO8859-2',
886 'hu_hu': 'hu_HU.ISO8859-2',
887 'hu_hu.iso88592': 'hu_HU.ISO8859-2',
888 'hungarian': 'hu_HU.ISO8859-2',
889 'icelandic': 'is_IS.ISO8859-1',
890 'icelandic.iso88591': 'is_IS.ISO8859-1',
891 'id': 'id_ID.ISO8859-1',
892 'id_id': 'id_ID.ISO8859-1',
893 'in': 'id_ID.ISO8859-1',
894 'in_id': 'id_ID.ISO8859-1',
895 'is': 'is_IS.ISO8859-1',
896 'is_is': 'is_IS.ISO8859-1',
897 'is_is.iso88591': 'is_IS.ISO8859-1',
898 'is_is.iso885915': 'is_IS.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000899 'is_is@euro': 'is_IS.ISO8859-15',
900 'iso-8859-1': 'en_US.ISO8859-1',
901 'iso-8859-15': 'en_US.ISO8859-15',
902 'iso8859-1': 'en_US.ISO8859-1',
903 'iso8859-15': 'en_US.ISO8859-15',
904 'iso_8859_1': 'en_US.ISO8859-1',
905 'iso_8859_15': 'en_US.ISO8859-15',
906 'it': 'it_IT.ISO8859-1',
907 'it_ch': 'it_CH.ISO8859-1',
908 'it_ch.iso88591': 'it_CH.ISO8859-1',
909 'it_ch.iso885915': 'it_CH.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000910 'it_ch@euro': 'it_CH.ISO8859-15',
911 'it_it': 'it_IT.ISO8859-1',
912 'it_it.88591': 'it_IT.ISO8859-1',
913 'it_it.iso88591': 'it_IT.ISO8859-1',
914 'it_it.iso885915': 'it_IT.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000915 'it_it@euro': 'it_IT.ISO8859-15',
916 'italian': 'it_IT.ISO8859-1',
917 'italian.iso88591': 'it_IT.ISO8859-1',
918 'iu': 'iu_CA.NUNACOM-8',
919 'iu_ca': 'iu_CA.NUNACOM-8',
920 'iu_ca.nunacom8': 'iu_CA.NUNACOM-8',
921 'iw': 'he_IL.ISO8859-8',
922 'iw_il': 'he_IL.ISO8859-8',
923 'iw_il.iso88598': 'he_IL.ISO8859-8',
924 'ja': 'ja_JP.eucJP',
925 'ja.jis': 'ja_JP.JIS7',
926 'ja.sjis': 'ja_JP.SJIS',
927 'ja_jp': 'ja_JP.eucJP',
928 'ja_jp.ajec': 'ja_JP.eucJP',
929 'ja_jp.euc': 'ja_JP.eucJP',
930 'ja_jp.eucjp': 'ja_JP.eucJP',
931 'ja_jp.iso-2022-jp': 'ja_JP.JIS7',
932 'ja_jp.iso2022jp': 'ja_JP.JIS7',
933 'ja_jp.jis': 'ja_JP.JIS7',
934 'ja_jp.jis7': 'ja_JP.JIS7',
935 'ja_jp.mscode': 'ja_JP.SJIS',
936 'ja_jp.sjis': 'ja_JP.SJIS',
937 'ja_jp.ujis': 'ja_JP.eucJP',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000938 'japan': 'ja_JP.eucJP',
939 'japanese': 'ja_JP.eucJP',
940 'japanese-euc': 'ja_JP.eucJP',
941 'japanese.euc': 'ja_JP.eucJP',
942 'japanese.sjis': 'ja_JP.SJIS',
943 'jp_jp': 'ja_JP.eucJP',
944 'ka': 'ka_GE.GEORGIAN-ACADEMY',
945 'ka_ge': 'ka_GE.GEORGIAN-ACADEMY',
946 'ka_ge.georgianacademy': 'ka_GE.GEORGIAN-ACADEMY',
947 'ka_ge.georgianps': 'ka_GE.GEORGIAN-PS',
948 'ka_ge.georgianrs': 'ka_GE.GEORGIAN-ACADEMY',
949 'kl': 'kl_GL.ISO8859-1',
950 'kl_gl': 'kl_GL.ISO8859-1',
951 'kl_gl.iso88591': 'kl_GL.ISO8859-1',
952 'kl_gl.iso885915': 'kl_GL.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000953 'kl_gl@euro': 'kl_GL.ISO8859-15',
954 'ko': 'ko_KR.eucKR',
955 'ko_kr': 'ko_KR.eucKR',
956 'ko_kr.euc': 'ko_KR.eucKR',
957 'ko_kr.euckr': 'ko_KR.eucKR',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000958 'korean': 'ko_KR.eucKR',
959 'korean.euc': 'ko_KR.eucKR',
960 'kw': 'kw_GB.ISO8859-1',
961 'kw_gb': 'kw_GB.ISO8859-1',
962 'kw_gb.iso88591': 'kw_GB.ISO8859-1',
963 'kw_gb.iso885914': 'kw_GB.ISO8859-14',
964 'kw_gb.iso885915': 'kw_GB.ISO8859-15',
965 'kw_gb@euro': 'kw_GB.ISO8859-15',
966 'lithuanian': 'lt_LT.ISO8859-13',
967 'lo': 'lo_LA.MULELAO-1',
968 'lo_la': 'lo_LA.MULELAO-1',
969 'lo_la.cp1133': 'lo_LA.IBM-CP1133',
970 'lo_la.ibmcp1133': 'lo_LA.IBM-CP1133',
971 'lo_la.mulelao1': 'lo_LA.MULELAO-1',
972 'lt': 'lt_LT.ISO8859-13',
973 'lt_lt': 'lt_LT.ISO8859-13',
974 'lt_lt.iso885913': 'lt_LT.ISO8859-13',
975 'lt_lt.iso88594': 'lt_LT.ISO8859-4',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000976 'lv': 'lv_LV.ISO8859-13',
977 'lv_lv': 'lv_LV.ISO8859-13',
978 'lv_lv.iso885913': 'lv_LV.ISO8859-13',
979 'lv_lv.iso88594': 'lv_LV.ISO8859-4',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000980 'mi': 'mi_NZ.ISO8859-1',
981 'mi_nz': 'mi_NZ.ISO8859-1',
982 'mi_nz.iso88591': 'mi_NZ.ISO8859-1',
983 'mk': 'mk_MK.ISO8859-5',
984 'mk_mk': 'mk_MK.ISO8859-5',
985 'mk_mk.cp1251': 'mk_MK.CP1251',
986 'mk_mk.iso88595': 'mk_MK.ISO8859-5',
987 'mk_mk.microsoftcp1251': 'mk_MK.CP1251',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000988 'ms': 'ms_MY.ISO8859-1',
989 'ms_my': 'ms_MY.ISO8859-1',
990 'ms_my.iso88591': 'ms_MY.ISO8859-1',
991 'mt': 'mt_MT.ISO8859-3',
992 'mt_mt': 'mt_MT.ISO8859-3',
993 'mt_mt.iso88593': 'mt_MT.ISO8859-3',
994 'nb': 'nb_NO.ISO8859-1',
995 'nb_no': 'nb_NO.ISO8859-1',
996 'nb_no.88591': 'nb_NO.ISO8859-1',
997 'nb_no.iso88591': 'nb_NO.ISO8859-1',
998 'nb_no.iso885915': 'nb_NO.ISO8859-15',
999 'nb_no@euro': 'nb_NO.ISO8859-15',
1000 'nl': 'nl_NL.ISO8859-1',
1001 'nl_be': 'nl_BE.ISO8859-1',
1002 'nl_be.88591': 'nl_BE.ISO8859-1',
1003 'nl_be.iso88591': 'nl_BE.ISO8859-1',
1004 'nl_be.iso885915': 'nl_BE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001005 'nl_be@euro': 'nl_BE.ISO8859-15',
1006 'nl_nl': 'nl_NL.ISO8859-1',
1007 'nl_nl.88591': 'nl_NL.ISO8859-1',
1008 'nl_nl.iso88591': 'nl_NL.ISO8859-1',
1009 'nl_nl.iso885915': 'nl_NL.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001010 'nl_nl@euro': 'nl_NL.ISO8859-15',
1011 'nn': 'nn_NO.ISO8859-1',
1012 'nn_no': 'nn_NO.ISO8859-1',
1013 'nn_no.88591': 'nn_NO.ISO8859-1',
1014 'nn_no.iso88591': 'nn_NO.ISO8859-1',
1015 'nn_no.iso885915': 'nn_NO.ISO8859-15',
1016 'nn_no@euro': 'nn_NO.ISO8859-15',
1017 'no': 'no_NO.ISO8859-1',
1018 'no@nynorsk': 'ny_NO.ISO8859-1',
1019 'no_no': 'no_NO.ISO8859-1',
1020 'no_no.88591': 'no_NO.ISO8859-1',
1021 'no_no.iso88591': 'no_NO.ISO8859-1',
1022 'no_no.iso885915': 'no_NO.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001023 'no_no@euro': 'no_NO.ISO8859-15',
1024 'norwegian': 'no_NO.ISO8859-1',
1025 'norwegian.iso88591': 'no_NO.ISO8859-1',
1026 'ny': 'ny_NO.ISO8859-1',
1027 'ny_no': 'ny_NO.ISO8859-1',
1028 'ny_no.88591': 'ny_NO.ISO8859-1',
1029 'ny_no.iso88591': 'ny_NO.ISO8859-1',
1030 'ny_no.iso885915': 'ny_NO.ISO8859-15',
1031 'ny_no@euro': 'ny_NO.ISO8859-15',
1032 'nynorsk': 'nn_NO.ISO8859-1',
1033 'oc': 'oc_FR.ISO8859-1',
1034 'oc_fr': 'oc_FR.ISO8859-1',
1035 'oc_fr.iso88591': 'oc_FR.ISO8859-1',
1036 'oc_fr.iso885915': 'oc_FR.ISO8859-15',
1037 'oc_fr@euro': 'oc_FR.ISO8859-15',
1038 'pd': 'pd_US.ISO8859-1',
1039 'pd_de': 'pd_DE.ISO8859-1',
1040 'pd_de.iso88591': 'pd_DE.ISO8859-1',
1041 'pd_de.iso885915': 'pd_DE.ISO8859-15',
1042 'pd_de@euro': 'pd_DE.ISO8859-15',
1043 'pd_us': 'pd_US.ISO8859-1',
1044 'pd_us.iso88591': 'pd_US.ISO8859-1',
1045 'pd_us.iso885915': 'pd_US.ISO8859-15',
1046 'pd_us@euro': 'pd_US.ISO8859-15',
1047 'ph': 'ph_PH.ISO8859-1',
1048 'ph_ph': 'ph_PH.ISO8859-1',
1049 'ph_ph.iso88591': 'ph_PH.ISO8859-1',
1050 'pl': 'pl_PL.ISO8859-2',
1051 'pl_pl': 'pl_PL.ISO8859-2',
1052 'pl_pl.iso88592': 'pl_PL.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001053 'polish': 'pl_PL.ISO8859-2',
1054 'portuguese': 'pt_PT.ISO8859-1',
1055 'portuguese.iso88591': 'pt_PT.ISO8859-1',
1056 'portuguese_brazil': 'pt_BR.ISO8859-1',
1057 'portuguese_brazil.8859': 'pt_BR.ISO8859-1',
1058 'posix': 'C',
1059 'posix-utf2': 'C',
1060 'pp': 'pp_AN.ISO8859-1',
1061 'pp_an': 'pp_AN.ISO8859-1',
1062 'pp_an.iso88591': 'pp_AN.ISO8859-1',
1063 'pt': 'pt_PT.ISO8859-1',
1064 'pt_br': 'pt_BR.ISO8859-1',
1065 'pt_br.88591': 'pt_BR.ISO8859-1',
1066 'pt_br.iso88591': 'pt_BR.ISO8859-1',
1067 'pt_br.iso885915': 'pt_BR.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001068 'pt_br@euro': 'pt_BR.ISO8859-15',
1069 'pt_pt': 'pt_PT.ISO8859-1',
1070 'pt_pt.88591': 'pt_PT.ISO8859-1',
1071 'pt_pt.iso88591': 'pt_PT.ISO8859-1',
1072 'pt_pt.iso885915': 'pt_PT.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001073 'pt_pt.utf8@euro': 'pt_PT.UTF-8',
1074 'pt_pt@euro': 'pt_PT.ISO8859-15',
1075 'ro': 'ro_RO.ISO8859-2',
1076 'ro_ro': 'ro_RO.ISO8859-2',
1077 'ro_ro.iso88592': 'ro_RO.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001078 'romanian': 'ro_RO.ISO8859-2',
1079 'ru': 'ru_RU.ISO8859-5',
1080 'ru_ru': 'ru_RU.ISO8859-5',
1081 'ru_ru.cp1251': 'ru_RU.CP1251',
1082 'ru_ru.iso88595': 'ru_RU.ISO8859-5',
1083 'ru_ru.koi8r': 'ru_RU.KOI8-R',
1084 'ru_ru.microsoftcp1251': 'ru_RU.CP1251',
1085 'ru_ua': 'ru_UA.KOI8-U',
1086 'ru_ua.cp1251': 'ru_UA.CP1251',
1087 'ru_ua.koi8u': 'ru_UA.KOI8-U',
1088 'ru_ua.microsoftcp1251': 'ru_UA.CP1251',
1089 'rumanian': 'ro_RO.ISO8859-2',
1090 'russian': 'ru_RU.ISO8859-5',
1091 'se_no': 'se_NO.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001092 'serbocroatian': 'sh_YU.ISO8859-2',
1093 'sh': 'sh_YU.ISO8859-2',
1094 'sh_hr': 'sh_HR.ISO8859-2',
1095 'sh_hr.iso88592': 'sh_HR.ISO8859-2',
1096 'sh_sp': 'sh_YU.ISO8859-2',
1097 'sh_yu': 'sh_YU.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001098 'sk': 'sk_SK.ISO8859-2',
1099 'sk_sk': 'sk_SK.ISO8859-2',
1100 'sk_sk.iso88592': 'sk_SK.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001101 'sl': 'sl_SI.ISO8859-2',
1102 'sl_cs': 'sl_CS.ISO8859-2',
1103 'sl_si': 'sl_SI.ISO8859-2',
1104 'sl_si.iso88592': 'sl_SI.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001105 'slovak': 'sk_SK.ISO8859-2',
1106 'slovene': 'sl_SI.ISO8859-2',
1107 'slovenian': 'sl_SI.ISO8859-2',
1108 'sp': 'sp_YU.ISO8859-5',
1109 'sp_yu': 'sp_YU.ISO8859-5',
1110 'spanish': 'es_ES.ISO8859-1',
1111 'spanish.iso88591': 'es_ES.ISO8859-1',
1112 'spanish_spain': 'es_ES.ISO8859-1',
1113 'spanish_spain.8859': 'es_ES.ISO8859-1',
1114 'sq': 'sq_AL.ISO8859-2',
1115 'sq_al': 'sq_AL.ISO8859-2',
1116 'sq_al.iso88592': 'sq_AL.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001117 'sr': 'sr_YU.ISO8859-5',
1118 'sr@cyrillic': 'sr_YU.ISO8859-5',
1119 'sr_sp': 'sr_SP.ISO8859-2',
1120 'sr_yu': 'sr_YU.ISO8859-5',
1121 'sr_yu.cp1251@cyrillic': 'sr_YU.CP1251',
1122 'sr_yu.iso88592': 'sr_YU.ISO8859-2',
1123 'sr_yu.iso88595': 'sr_YU.ISO8859-5',
1124 'sr_yu.iso88595@cyrillic': 'sr_YU.ISO8859-5',
1125 'sr_yu.microsoftcp1251@cyrillic': 'sr_YU.CP1251',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001126 'sr_yu.utf8@cyrillic': 'sr_YU.UTF-8',
1127 'sr_yu@cyrillic': 'sr_YU.ISO8859-5',
1128 'sv': 'sv_SE.ISO8859-1',
1129 'sv_fi': 'sv_FI.ISO8859-1',
1130 'sv_fi.iso88591': 'sv_FI.ISO8859-1',
1131 'sv_fi.iso885915': 'sv_FI.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001132 'sv_fi@euro': 'sv_FI.ISO8859-15',
1133 'sv_se': 'sv_SE.ISO8859-1',
1134 'sv_se.88591': 'sv_SE.ISO8859-1',
1135 'sv_se.iso88591': 'sv_SE.ISO8859-1',
1136 'sv_se.iso885915': 'sv_SE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001137 'sv_se@euro': 'sv_SE.ISO8859-15',
1138 'swedish': 'sv_SE.ISO8859-1',
1139 'swedish.iso88591': 'sv_SE.ISO8859-1',
1140 'ta': 'ta_IN.TSCII-0',
1141 'ta_in': 'ta_IN.TSCII-0',
1142 'ta_in.tscii': 'ta_IN.TSCII-0',
1143 'ta_in.tscii0': 'ta_IN.TSCII-0',
1144 'tg': 'tg_TJ.KOI8-C',
1145 'tg_tj': 'tg_TJ.KOI8-C',
1146 'tg_tj.koi8c': 'tg_TJ.KOI8-C',
1147 'th': 'th_TH.ISO8859-11',
1148 'th_th': 'th_TH.ISO8859-11',
1149 'th_th.iso885911': 'th_TH.ISO8859-11',
1150 'th_th.tactis': 'th_TH.TIS620',
1151 'th_th.tis620': 'th_TH.TIS620',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001152 'thai': 'th_TH.ISO8859-11',
1153 'tl': 'tl_PH.ISO8859-1',
1154 'tl_ph': 'tl_PH.ISO8859-1',
1155 'tl_ph.iso88591': 'tl_PH.ISO8859-1',
1156 'tr': 'tr_TR.ISO8859-9',
1157 'tr_tr': 'tr_TR.ISO8859-9',
1158 'tr_tr.iso88599': 'tr_TR.ISO8859-9',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001159 'tt': 'tt_RU.TATAR-CYR',
1160 'tt_ru': 'tt_RU.TATAR-CYR',
1161 'tt_ru.koi8c': 'tt_RU.KOI8-C',
1162 'tt_ru.tatarcyr': 'tt_RU.TATAR-CYR',
1163 'turkish': 'tr_TR.ISO8859-9',
1164 'turkish.iso88599': 'tr_TR.ISO8859-9',
1165 'uk': 'uk_UA.KOI8-U',
1166 'uk_ua': 'uk_UA.KOI8-U',
1167 'uk_ua.cp1251': 'uk_UA.CP1251',
1168 'uk_ua.iso88595': 'uk_UA.ISO8859-5',
1169 'uk_ua.koi8u': 'uk_UA.KOI8-U',
1170 'uk_ua.microsoftcp1251': 'uk_UA.CP1251',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001171 'univ': 'en_US.utf',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001172 'universal': 'en_US.utf',
1173 'universal.utf8@ucs4': 'en_US.UTF-8',
1174 'ur': 'ur_PK.CP1256',
1175 'ur_pk': 'ur_PK.CP1256',
1176 'ur_pk.cp1256': 'ur_PK.CP1256',
1177 'ur_pk.microsoftcp1256': 'ur_PK.CP1256',
1178 'uz': 'uz_UZ.UTF-8',
1179 'uz_uz': 'uz_UZ.UTF-8',
1180 'vi': 'vi_VN.TCVN',
1181 'vi_vn': 'vi_VN.TCVN',
1182 'vi_vn.tcvn': 'vi_VN.TCVN',
1183 'vi_vn.tcvn5712': 'vi_VN.TCVN',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001184 'vi_vn.viscii': 'vi_VN.VISCII',
1185 'vi_vn.viscii111': 'vi_VN.VISCII',
1186 'wa': 'wa_BE.ISO8859-1',
1187 'wa_be': 'wa_BE.ISO8859-1',
1188 'wa_be.iso88591': 'wa_BE.ISO8859-1',
1189 'wa_be.iso885915': 'wa_BE.ISO8859-15',
1190 'wa_be@euro': 'wa_BE.ISO8859-15',
1191 'yi': 'yi_US.CP1255',
1192 'yi_us': 'yi_US.CP1255',
1193 'yi_us.cp1255': 'yi_US.CP1255',
1194 'yi_us.microsoftcp1255': 'yi_US.CP1255',
1195 'zh': 'zh_CN.eucCN',
1196 'zh_cn': 'zh_CN.gb2312',
1197 'zh_cn.big5': 'zh_TW.big5',
1198 'zh_cn.euc': 'zh_CN.eucCN',
1199 'zh_cn.gb18030': 'zh_CN.gb18030',
1200 'zh_cn.gb2312': 'zh_CN.gb2312',
1201 'zh_cn.gbk': 'zh_CN.gbk',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001202 'zh_hk': 'zh_HK.big5hkscs',
1203 'zh_hk.big5': 'zh_HK.big5',
1204 'zh_hk.big5hkscs': 'zh_HK.big5hkscs',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001205 'zh_tw': 'zh_TW.big5',
1206 'zh_tw.big5': 'zh_TW.big5',
1207 'zh_tw.euc': 'zh_TW.eucTW',
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001208}
1209
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001210#
1211# this maps windows language identifiers (as used on Windows 95 and
1212# earlier) to locale strings.
1213#
Fredrik Lundh37a09822002-10-19 20:19:10 +00001214# NOTE: this mapping is incomplete. If your language is missing, please
1215# submit a bug report to Python bug manager, which you can find via:
1216# http://www.python.org/dev/
1217# Make sure you include the missing language identifier and the suggested
1218# locale code.
1219#
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001220
1221windows_locale = {
1222 0x0404: "zh_TW", # Chinese (Taiwan)
1223 0x0804: "zh_CN", # Chinese (PRC)
1224 0x0406: "da_DK", # Danish
1225 0x0413: "nl_NL", # Dutch (Netherlands)
1226 0x0409: "en_US", # English (United States)
1227 0x0809: "en_UK", # English (United Kingdom)
1228 0x0c09: "en_AU", # English (Australian)
1229 0x1009: "en_CA", # English (Canadian)
1230 0x1409: "en_NZ", # English (New Zealand)
1231 0x1809: "en_IE", # English (Ireland)
1232 0x1c09: "en_ZA", # English (South Africa)
1233 0x040b: "fi_FI", # Finnish
1234 0x040c: "fr_FR", # French (Standard)
1235 0x080c: "fr_BE", # French (Belgian)
1236 0x0c0c: "fr_CA", # French (Canadian)
1237 0x100c: "fr_CH", # French (Switzerland)
1238 0x0407: "de_DE", # German (Standard)
1239 0x0408: "el_GR", # Greek
1240 0x040d: "iw_IL", # Hebrew
1241 0x040f: "is_IS", # Icelandic
1242 0x0410: "it_IT", # Italian (Standard)
1243 0x0411: "ja_JA", # Japanese
1244 0x0414: "no_NO", # Norwegian (Bokmal)
1245 0x0816: "pt_PT", # Portuguese (Standard)
1246 0x0c0a: "es_ES", # Spanish (Modern Sort)
1247 0x0441: "sw_KE", # Swahili (Kenya)
1248 0x041d: "sv_SE", # Swedish
1249 0x081d: "sv_FI", # Swedish (Finland)
1250 0x041f: "tr_TR", # Turkish
1251}
1252
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001253def _print_locale():
1254
1255 """ Test function.
1256 """
1257 categories = {}
1258 def _init_categories(categories=categories):
1259 for k,v in globals().items():
1260 if k[:3] == 'LC_':
1261 categories[k] = v
1262 _init_categories()
1263 del categories['LC_ALL']
1264
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001265 print 'Locale defaults as determined by getdefaultlocale():'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001266 print '-'*72
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001267 lang, enc = getdefaultlocale()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001268 print 'Language: ', lang or '(undefined)'
1269 print 'Encoding: ', enc or '(undefined)'
1270 print
1271
1272 print 'Locale settings on startup:'
1273 print '-'*72
1274 for name,category in categories.items():
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001275 print name, '...'
1276 lang, enc = getlocale(category)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001277 print ' Language: ', lang or '(undefined)'
1278 print ' Encoding: ', enc or '(undefined)'
1279 print
1280
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001281 print
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001282 print 'Locale settings after calling resetlocale():'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001283 print '-'*72
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001284 resetlocale()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001285 for name,category in categories.items():
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001286 print name, '...'
1287 lang, enc = getlocale(category)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001288 print ' Language: ', lang or '(undefined)'
1289 print ' Encoding: ', enc or '(undefined)'
1290 print
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001291
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001292 try:
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001293 setlocale(LC_ALL, "")
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001294 except:
1295 print 'NOTE:'
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001296 print 'setlocale(LC_ALL, "") does not support the default locale'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001297 print 'given in the OS environment variables.'
1298 else:
1299 print
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001300 print 'Locale settings after calling setlocale(LC_ALL, ""):'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001301 print '-'*72
1302 for name,category in categories.items():
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001303 print name, '...'
1304 lang, enc = getlocale(category)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001305 print ' Language: ', lang or '(undefined)'
1306 print ' Encoding: ', enc or '(undefined)'
1307 print
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001308
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001309###
Guido van Rossumeef1d4e1997-11-19 19:01:43 +00001310
Tim Peters1baf8292001-01-24 10:13:46 +00001311try:
1312 LC_MESSAGES
Skip Montanaro0897f0c2002-03-25 21:40:36 +00001313except NameError:
Tim Peters1baf8292001-01-24 10:13:46 +00001314 pass
1315else:
1316 __all__.append("LC_MESSAGES")
1317
Guido van Rossumeef1d4e1997-11-19 19:01:43 +00001318if __name__=='__main__':
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001319 print 'Locale aliasing:'
1320 print
1321 _print_locale()
1322 print
1323 print 'Number formatting:'
1324 print
1325 _test()