blob: fd948a793f5b393a392b5ecbadaf439587a0669c [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
Antoine Pitrouba54eda2008-07-25 20:40:19 +000015import functools
Marc-André Lemburg5431bc32000-06-07 09:11:40 +000016
Fredrik Lundh6c86b992000-07-09 17:12:58 +000017# Try importing the _locale module.
18#
19# If this fails, fall back on a basic 'C' locale emulation.
Guido van Rossumeef1d4e1997-11-19 19:01:43 +000020
Tim Peters1baf8292001-01-24 10:13:46 +000021# Yuck: LC_MESSAGES is non-standard: can't tell whether it exists before
22# trying the import. So __all__ is also fiddled at the end of the file.
Georg Brandl09728b72007-05-01 06:08:15 +000023__all__ = ["getlocale", "getdefaultlocale", "getpreferredencoding", "Error",
24 "setlocale", "resetlocale", "localeconv", "strcoll", "strxfrm",
25 "str", "atof", "atoi", "format", "format_string", "currency",
26 "normalize", "LC_CTYPE", "LC_COLLATE", "LC_TIME", "LC_MONETARY",
27 "LC_NUMERIC", "LC_ALL", "CHAR_MAX"]
Skip Montanaro17ab1232001-01-24 06:27:27 +000028
Marc-André Lemburg23481142000-06-08 17:49:41 +000029try:
Fredrik Lundh6c86b992000-07-09 17:12:58 +000030
Marc-André Lemburg23481142000-06-08 17:49:41 +000031 from _locale import *
32
33except ImportError:
34
Fredrik Lundh6c86b992000-07-09 17:12:58 +000035 # Locale emulation
36
Marc-André Lemburg23481142000-06-08 17:49:41 +000037 CHAR_MAX = 127
38 LC_ALL = 6
39 LC_COLLATE = 3
40 LC_CTYPE = 0
41 LC_MESSAGES = 5
42 LC_MONETARY = 4
43 LC_NUMERIC = 1
44 LC_TIME = 2
45 Error = ValueError
46
47 def localeconv():
Fredrik Lundh6c86b992000-07-09 17:12:58 +000048 """ localeconv() -> dict.
Marc-André Lemburg23481142000-06-08 17:49:41 +000049 Returns numeric and monetary locale-specific parameters.
50 """
51 # 'C' locale default values
52 return {'grouping': [127],
53 'currency_symbol': '',
54 'n_sign_posn': 127,
Fredrik Lundh6c86b992000-07-09 17:12:58 +000055 'p_cs_precedes': 127,
56 'n_cs_precedes': 127,
57 'mon_grouping': [],
Marc-André Lemburg23481142000-06-08 17:49:41 +000058 'n_sep_by_space': 127,
59 'decimal_point': '.',
60 'negative_sign': '',
61 'positive_sign': '',
Fredrik Lundh6c86b992000-07-09 17:12:58 +000062 'p_sep_by_space': 127,
Marc-André Lemburg23481142000-06-08 17:49:41 +000063 'int_curr_symbol': '',
Fredrik Lundh6c86b992000-07-09 17:12:58 +000064 'p_sign_posn': 127,
Marc-André Lemburg23481142000-06-08 17:49:41 +000065 'thousands_sep': '',
Fredrik Lundh6c86b992000-07-09 17:12:58 +000066 'mon_thousands_sep': '',
67 'frac_digits': 127,
Marc-André Lemburg23481142000-06-08 17:49:41 +000068 'mon_decimal_point': '',
69 'int_frac_digits': 127}
Fredrik Lundh6c86b992000-07-09 17:12:58 +000070
Marc-André Lemburg23481142000-06-08 17:49:41 +000071 def setlocale(category, value=None):
Fredrik Lundh6c86b992000-07-09 17:12:58 +000072 """ setlocale(integer,string=None) -> string.
Marc-André Lemburg23481142000-06-08 17:49:41 +000073 Activates/queries locale processing.
74 """
Martin v. Löwis103d6e72003-03-30 15:42:13 +000075 if value not in (None, '', 'C'):
Fredrik Lundh6c86b992000-07-09 17:12:58 +000076 raise Error, '_locale emulation only supports "C" locale'
Marc-André Lemburg23481142000-06-08 17:49:41 +000077 return 'C'
78
79 def strcoll(a,b):
Fredrik Lundh6c86b992000-07-09 17:12:58 +000080 """ strcoll(string,string) -> int.
Marc-André Lemburg23481142000-06-08 17:49:41 +000081 Compares two strings according to the locale.
82 """
83 return cmp(a,b)
84
85 def strxfrm(s):
Fredrik Lundh6c86b992000-07-09 17:12:58 +000086 """ strxfrm(string) -> string.
Marc-André Lemburg23481142000-06-08 17:49:41 +000087 Returns a string that behaves for cmp locale-aware.
88 """
89 return s
Marc-André Lemburg5431bc32000-06-07 09:11:40 +000090
Antoine Pitrouba54eda2008-07-25 20:40:19 +000091
92_localeconv = localeconv
93
94# With this dict, you can override some items of localeconv's return value.
95# This is useful for testing purposes.
96_override_localeconv = {}
97
98@functools.wraps(_localeconv)
99def localeconv():
100 d = _localeconv()
101 if _override_localeconv:
102 d.update(_override_localeconv)
103 return d
104
105
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000106### Number formatting APIs
107
108# Author: Martin von Loewis
Georg Brandlb89316f2006-05-17 15:51:16 +0000109# improved by Georg Brandl
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000110
111#perform the grouping from right to left
Georg Brandlb89316f2006-05-17 15:51:16 +0000112def _group(s, monetary=False):
113 conv = localeconv()
114 thousands_sep = conv[monetary and 'mon_thousands_sep' or 'thousands_sep']
115 grouping = conv[monetary and 'mon_grouping' or 'grouping']
116 if not grouping:
117 return (s, 0)
118 result = ""
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000119 seps = 0
120 spaces = ""
121 if s[-1] == ' ':
122 sp = s.find(' ')
123 spaces = s[sp:]
124 s = s[:sp]
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000125 while s and grouping:
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000126 # if grouping is -1, we are done
Georg Brandlb89316f2006-05-17 15:51:16 +0000127 if grouping[0] == CHAR_MAX:
Guido van Rossum45e2fbc1998-03-26 21:13:24 +0000128 break
129 # 0: re-use last group ad infinitum
Georg Brandlb89316f2006-05-17 15:51:16 +0000130 elif grouping[0] != 0:
Guido van Rossum45e2fbc1998-03-26 21:13:24 +0000131 #process last group
Georg Brandlb89316f2006-05-17 15:51:16 +0000132 group = grouping[0]
133 grouping = grouping[1:]
Guido van Rossum45e2fbc1998-03-26 21:13:24 +0000134 if result:
Georg Brandlb89316f2006-05-17 15:51:16 +0000135 result = s[-group:] + thousands_sep + result
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000136 seps += 1
Guido van Rossum45e2fbc1998-03-26 21:13:24 +0000137 else:
Georg Brandlb89316f2006-05-17 15:51:16 +0000138 result = s[-group:]
139 s = s[:-group]
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000140 if s and s[-1] not in "0123456789":
141 # the leading string is only spaces and signs
Georg Brandlb89316f2006-05-17 15:51:16 +0000142 return s + result + spaces, seps
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000143 if not result:
Georg Brandlb89316f2006-05-17 15:51:16 +0000144 return s + spaces, seps
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000145 if s:
Georg Brandlb89316f2006-05-17 15:51:16 +0000146 result = s + thousands_sep + result
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000147 seps += 1
Georg Brandlb89316f2006-05-17 15:51:16 +0000148 return result + spaces, seps
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000149
Georg Brandlb89316f2006-05-17 15:51:16 +0000150def format(percent, value, grouping=False, monetary=False, *additional):
151 """Returns the locale-aware substitution of a %? specifier
152 (percent).
Tim Petersfd4c4192006-05-18 02:06:40 +0000153
Georg Brandlb89316f2006-05-17 15:51:16 +0000154 additional is for format strings which contain one or more
155 '*' modifiers."""
156 # this is only for one-percent-specifier strings and this should be checked
157 if percent[0] != '%':
158 raise ValueError("format() must be given exactly one %char "
159 "format specifier")
160 if additional:
161 formatted = percent % ((value,) + additional)
162 else:
163 formatted = percent % value
164 # floats and decimal ints need special action!
165 if percent[-1] in 'eEfFgG':
166 seps = 0
167 parts = formatted.split('.')
168 if grouping:
169 parts[0], seps = _group(parts[0], monetary=monetary)
170 decimal_point = localeconv()[monetary and 'mon_decimal_point'
171 or 'decimal_point']
172 formatted = decimal_point.join(parts)
173 while seps:
174 sp = formatted.find(' ')
175 if sp == -1: break
176 formatted = formatted[:sp] + formatted[sp+1:]
177 seps -= 1
178 elif percent[-1] in 'diu':
179 if grouping:
180 formatted = _group(formatted, monetary=monetary)[0]
181 return formatted
182
183import re, operator
184_percent_re = re.compile(r'%(?:\((?P<key>.*?)\))?'
185 r'(?P<modifiers>[-#0-9 +*.hlL]*?)[eEfFgGdiouxXcrs%]')
186
187def format_string(f, val, grouping=False):
188 """Formats a string in the same way that the % formatting would use,
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000189 but takes the current locale into account.
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000190 Grouping is applied if the third parameter is true."""
Georg Brandlb89316f2006-05-17 15:51:16 +0000191 percents = list(_percent_re.finditer(f))
192 new_f = _percent_re.sub('%s', f)
193
194 if isinstance(val, tuple):
195 new_val = list(val)
196 i = 0
197 for perc in percents:
198 starcount = perc.group('modifiers').count('*')
199 new_val[i] = format(perc.group(), new_val[i], grouping, False, *new_val[i+1:i+1+starcount])
200 del new_val[i+1:i+1+starcount]
201 i += (1 + starcount)
202 val = tuple(new_val)
203 elif operator.isMappingType(val):
204 for perc in percents:
205 key = perc.group("key")
206 val[key] = format(perc.group(), val[key], grouping)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000207 else:
Georg Brandlb89316f2006-05-17 15:51:16 +0000208 # val is a single value
209 val = format(percents[0].group(), val, grouping)
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000210
Georg Brandlb89316f2006-05-17 15:51:16 +0000211 return new_f % val
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000212
Georg Brandlb89316f2006-05-17 15:51:16 +0000213def currency(val, symbol=True, grouping=False, international=False):
214 """Formats val according to the currency settings
215 in the current locale."""
216 conv = localeconv()
217
218 # check for illegal values
219 digits = conv[international and 'int_frac_digits' or 'frac_digits']
220 if digits == 127:
221 raise ValueError("Currency formatting is not possible using "
222 "the 'C' locale.")
223
224 s = format('%%.%if' % digits, abs(val), grouping, monetary=True)
225 # '<' and '>' are markers if the sign must be inserted between symbol and value
226 s = '<' + s + '>'
227
228 if symbol:
229 smb = conv[international and 'int_curr_symbol' or 'currency_symbol']
230 precedes = conv[val<0 and 'n_cs_precedes' or 'p_cs_precedes']
231 separated = conv[val<0 and 'n_sep_by_space' or 'p_sep_by_space']
232
233 if precedes:
234 s = smb + (separated and ' ' or '') + s
235 else:
236 s = s + (separated and ' ' or '') + smb
237
238 sign_pos = conv[val<0 and 'n_sign_posn' or 'p_sign_posn']
239 sign = conv[val<0 and 'negative_sign' or 'positive_sign']
240
241 if sign_pos == 0:
242 s = '(' + s + ')'
243 elif sign_pos == 1:
244 s = sign + s
245 elif sign_pos == 2:
246 s = s + sign
247 elif sign_pos == 3:
248 s = s.replace('<', sign)
249 elif sign_pos == 4:
250 s = s.replace('>', sign)
251 else:
252 # the default if nothing specified;
253 # this should be the most fitting sign position
254 s = sign + s
255
256 return s.replace('<', '').replace('>', '')
Martin v. Löwisdb786872001-01-21 18:52:33 +0000257
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000258def str(val):
259 """Convert float to integer, taking the locale into account."""
Georg Brandlb89316f2006-05-17 15:51:16 +0000260 return format("%.12g", val)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000261
Georg Brandlb89316f2006-05-17 15:51:16 +0000262def atof(string, func=float):
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000263 "Parses a string as a float according to the locale settings."
264 #First, get rid of the grouping
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000265 ts = localeconv()['thousands_sep']
266 if ts:
Skip Montanaro249369c2004-04-10 16:39:32 +0000267 string = string.replace(ts, '')
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000268 #next, replace the decimal point with a dot
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000269 dd = localeconv()['decimal_point']
270 if dd:
Skip Montanaro249369c2004-04-10 16:39:32 +0000271 string = string.replace(dd, '.')
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000272 #finally, parse the string
Skip Montanaro249369c2004-04-10 16:39:32 +0000273 return func(string)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000274
275def atoi(str):
276 "Converts a string to an integer according to the locale settings."
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000277 return atof(str, int)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000278
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000279def _test():
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000280 setlocale(LC_ALL, "")
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000281 #do grouping
Georg Brandlb89316f2006-05-17 15:51:16 +0000282 s1 = format("%d", 123456789,1)
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000283 print s1, "is", atoi(s1)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000284 #standard formatting
Georg Brandlb89316f2006-05-17 15:51:16 +0000285 s1 = str(3.14)
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000286 print s1, "is", atof(s1)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000287
288### Locale name aliasing engine
289
290# Author: Marc-Andre Lemburg, mal@lemburg.com
Fredrik Lundh37a09822002-10-19 20:19:10 +0000291# Various tweaks by Fredrik Lundh <fredrik@pythonware.com>
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000292
293# store away the low-level version of setlocale (it's
294# overridden below)
295_setlocale = setlocale
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000296
297def normalize(localename):
298
299 """ Returns a normalized locale code for the given locale
300 name.
301
302 The returned locale code is formatted for use with
303 setlocale().
304
305 If normalization fails, the original name is returned
306 unchanged.
307
308 If the given encoding is not known, the function defaults to
309 the default encoding for the locale code just like setlocale()
310 does.
311
312 """
313 # Normalize the locale name and extract the encoding
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000314 fullname = localename.lower()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000315 if ':' in fullname:
316 # ':' is sometimes used as encoding delimiter.
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000317 fullname = fullname.replace(':', '.')
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000318 if '.' in fullname:
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000319 langname, encoding = fullname.split('.')[:2]
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000320 fullname = langname + '.' + encoding
321 else:
322 langname = fullname
323 encoding = ''
324
325 # First lookup: fullname (possibly with encoding)
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000326 norm_encoding = encoding.replace('-', '')
327 norm_encoding = norm_encoding.replace('_', '')
328 lookup_name = langname + '.' + encoding
329 code = locale_alias.get(lookup_name, None)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000330 if code is not None:
331 return code
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000332 #print 'first lookup failed'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000333
334 # Second try: langname (without encoding)
335 code = locale_alias.get(langname, None)
336 if code is not None:
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000337 #print 'langname lookup succeeded'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000338 if '.' in code:
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000339 langname, defenc = code.split('.')
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000340 else:
341 langname = code
342 defenc = ''
343 if encoding:
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000344 # Convert the encoding to a C lib compatible encoding string
345 norm_encoding = encodings.normalize_encoding(encoding)
346 #print 'norm encoding: %r' % norm_encoding
347 norm_encoding = encodings.aliases.aliases.get(norm_encoding,
348 norm_encoding)
349 #print 'aliased encoding: %r' % norm_encoding
350 encoding = locale_encoding_alias.get(norm_encoding,
351 norm_encoding)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000352 else:
353 encoding = defenc
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000354 #print 'found encoding %r' % encoding
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000355 if encoding:
356 return langname + '.' + encoding
357 else:
358 return langname
359
360 else:
361 return localename
362
363def _parse_localename(localename):
364
365 """ Parses the locale code for localename and returns the
366 result as tuple (language code, encoding).
367
368 The localename is normalized and passed through the locale
369 alias engine. A ValueError is raised in case the locale name
370 cannot be parsed.
371
372 The language code corresponds to RFC 1766. code and encoding
373 can be None in case the values cannot be determined or are
Jeremy Hyltona05e2932000-06-28 14:48:01 +0000374 unknown to this implementation.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000375
376 """
377 code = normalize(localename)
Georg Brandlb709c2c2006-01-20 09:07:35 +0000378 if '@' in code:
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000379 # Deal with locale modifiers
380 code, modifier = code.split('@')
381 if modifier == 'euro' and '.' not in code:
382 # Assume Latin-9 for @euro locales. This is bogus,
383 # since some systems may use other encodings for these
384 # locales. Also, we ignore other modifiers.
385 return code, 'iso-8859-15'
Tim Peters230a60c2002-11-09 05:08:07 +0000386
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000387 if '.' in code:
Raymond Hettinger346e67f2005-01-01 06:10:26 +0000388 return tuple(code.split('.')[:2])
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000389 elif code == 'C':
390 return None, None
Andrew M. Kuchling1f877ef2001-08-13 14:50:44 +0000391 raise ValueError, 'unknown locale: %s' % localename
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000392
393def _build_localename(localetuple):
394
395 """ Builds a locale code from the given tuple (language code,
396 encoding).
397
398 No aliasing or normalizing takes place.
399
400 """
401 language, encoding = localetuple
402 if language is None:
403 language = 'C'
404 if encoding is None:
405 return language
406 else:
407 return language + '.' + encoding
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000408
Matthias Klosef3f231f2005-09-20 07:02:49 +0000409def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000410
411 """ Tries to determine the default locale settings and returns
412 them as tuple (language code, encoding).
413
414 According to POSIX, a program which has not called
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000415 setlocale(LC_ALL, "") runs using the portable 'C' locale.
416 Calling setlocale(LC_ALL, "") lets it use the default locale as
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000417 defined by the LANG variable. Since we don't want to interfere
Thomas Wouters7e474022000-07-16 12:04:32 +0000418 with the current locale setting we thus emulate the behavior
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000419 in the way described above.
420
421 To maintain compatibility with other platforms, not only the
422 LANG variable is tested, but a list of variables given as
423 envvars parameter. The first found to be defined will be
424 used. envvars defaults to the search path used in GNU gettext;
425 it must always contain the variable name 'LANG'.
426
427 Except for the code 'C', the language code corresponds to RFC
428 1766. code and encoding can be None in case the values cannot
429 be determined.
430
431 """
Fredrik Lundh04661322000-07-09 23:16:10 +0000432
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000433 try:
434 # check if it's supported by the _locale module
435 import _locale
436 code, encoding = _locale._getdefaultlocale()
Fredrik Lundh04661322000-07-09 23:16:10 +0000437 except (ImportError, AttributeError):
438 pass
439 else:
Fredrik Lundh663809e2000-07-10 19:32:19 +0000440 # make sure the code/encoding values are valid
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000441 if sys.platform == "win32" and code and code[:2] == "0x":
442 # map windows language identifier to language name
443 code = windows_locale.get(int(code, 0))
Fredrik Lundh663809e2000-07-10 19:32:19 +0000444 # ...add other platform-specific processing here, if
445 # necessary...
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000446 return code, encoding
Fredrik Lundh04661322000-07-09 23:16:10 +0000447
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000448 # fall back on POSIX behaviour
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000449 import os
450 lookup = os.environ.get
451 for variable in envvars:
452 localename = lookup(variable,None)
Martin v. Löwisc8ae31d2004-07-26 12:45:18 +0000453 if localename:
Matthias Klosef3f231f2005-09-20 07:02:49 +0000454 if variable == 'LANGUAGE':
455 localename = localename.split(':')[0]
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000456 break
457 else:
458 localename = 'C'
459 return _parse_localename(localename)
460
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000461
462def getlocale(category=LC_CTYPE):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000463
464 """ Returns the current setting for the given locale category as
465 tuple (language code, encoding).
466
467 category may be one of the LC_* value except LC_ALL. It
468 defaults to LC_CTYPE.
469
470 Except for the code 'C', the language code corresponds to RFC
471 1766. code and encoding can be None in case the values cannot
472 be determined.
473
474 """
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000475 localename = _setlocale(category)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000476 if category == LC_ALL and ';' in localename:
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000477 raise TypeError, 'category LC_ALL is not supported'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000478 return _parse_localename(localename)
479
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000480def setlocale(category, locale=None):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000481
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000482 """ Set the locale for the given category. The locale can be
483 a string, a locale tuple (language code, encoding), or None.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000484
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000485 Locale tuples are converted to strings the locale aliasing
486 engine. Locale strings are passed directly to the C lib.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000487
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000488 category may be given as one of the LC_* values.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000489
490 """
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000491 if locale and type(locale) is not type(""):
492 # convert to string
493 locale = normalize(_build_localename(locale))
494 return _setlocale(category, locale)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000495
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000496def resetlocale(category=LC_ALL):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000497
498 """ Sets the locale for category to the default setting.
499
500 The default setting is determined by calling
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000501 getdefaultlocale(). category defaults to LC_ALL.
502
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000503 """
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000504 _setlocale(category, _build_localename(getdefaultlocale()))
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000505
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000506if sys.platform in ('win32', 'darwin', 'mac'):
507 # On Win32, this will return the ANSI code page
508 # On the Mac, it should return the system encoding;
509 # it might return "ascii" instead
510 def getpreferredencoding(do_setlocale = True):
511 """Return the charset that the user is likely using."""
512 import _locale
Tim Petersa326f472002-11-05 03:49:09 +0000513 return _locale._getdefaultlocale()[1]
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000514else:
515 # On Unix, if CODESET is available, use that.
516 try:
517 CODESET
518 except NameError:
519 # Fall back to parsing environment variables :-(
520 def getpreferredencoding(do_setlocale = True):
521 """Return the charset that the user is likely using,
522 by looking at environment variables."""
523 return getdefaultlocale()[1]
524 else:
525 def getpreferredencoding(do_setlocale = True):
526 """Return the charset that the user is likely using,
527 according to the system configuration."""
528 if do_setlocale:
529 oldloc = setlocale(LC_CTYPE)
530 setlocale(LC_CTYPE, "")
531 result = nl_langinfo(CODESET)
532 setlocale(LC_CTYPE, oldloc)
533 return result
534 else:
535 return nl_langinfo(CODESET)
Tim Peters230a60c2002-11-09 05:08:07 +0000536
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000537
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000538### Database
539#
540# The following data was extracted from the locale.alias file which
541# comes with X11 and then hand edited removing the explicit encoding
542# definitions and adding some more aliases. The file is usually
543# available as /usr/lib/X11/locale/locale.alias.
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000544#
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000545
546#
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000547# The local_encoding_alias table maps lowercase encoding alias names
548# to C locale encoding names (case-sensitive). Note that normalize()
549# first looks up the encoding in the encodings.aliases dictionary and
550# then applies this mapping to find the correct C lib name for the
551# encoding.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000552#
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000553locale_encoding_alias = {
554
555 # Mappings for non-standard encoding names used in locale names
556 '437': 'C',
557 'c': 'C',
558 'en': 'ISO8859-1',
559 'jis': 'JIS7',
560 'jis7': 'JIS7',
561 'ajec': 'eucJP',
562
563 # Mappings from Python codec names to C lib encoding names
564 'ascii': 'ISO8859-1',
565 'latin_1': 'ISO8859-1',
566 'iso8859_1': 'ISO8859-1',
567 'iso8859_10': 'ISO8859-10',
568 'iso8859_11': 'ISO8859-11',
569 'iso8859_13': 'ISO8859-13',
570 'iso8859_14': 'ISO8859-14',
571 'iso8859_15': 'ISO8859-15',
572 'iso8859_2': 'ISO8859-2',
573 'iso8859_3': 'ISO8859-3',
574 'iso8859_4': 'ISO8859-4',
575 'iso8859_5': 'ISO8859-5',
576 'iso8859_6': 'ISO8859-6',
577 'iso8859_7': 'ISO8859-7',
578 'iso8859_8': 'ISO8859-8',
579 'iso8859_9': 'ISO8859-9',
580 'iso2022_jp': 'JIS7',
581 'shift_jis': 'SJIS',
582 'tactis': 'TACTIS',
583 'euc_jp': 'eucJP',
584 'euc_kr': 'eucKR',
Marc-André Lemburgb4cebd42004-12-13 19:56:01 +0000585 'utf_8': 'UTF8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000586 'koi8_r': 'KOI8-R',
587 'koi8_u': 'KOI8-U',
588 # XXX This list is still incomplete. If you know more
589 # mappings, please file a bug report. Thanks.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000590}
591
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000592#
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000593# The locale_alias table maps lowercase alias names to C locale names
594# (case-sensitive). Encodings are always separated from the locale
595# name using a dot ('.'); they should only be given in case the
596# language name is needed to interpret the given encoding alias
597# correctly (CJK codes often have this need).
598#
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000599# Note that the normalize() function which uses this tables
600# removes '_' and '-' characters from the encoding part of the
601# locale name before doing the lookup. This saves a lot of
602# space in the table.
603#
604# MAL 2004-12-10:
605# Updated alias mapping to most recent locale.alias file
606# from X.org distribution using makelocalealias.py.
607#
608# These are the differences compared to the old mapping (Python 2.4
609# and older):
610#
611# updated 'bg' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
612# updated 'bg_bg' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
613# updated 'bulgarian' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
614# updated 'cz' -> 'cz_CZ.ISO8859-2' to 'cs_CZ.ISO8859-2'
615# updated 'cz_cz' -> 'cz_CZ.ISO8859-2' to 'cs_CZ.ISO8859-2'
616# updated 'czech' -> 'cs_CS.ISO8859-2' to 'cs_CZ.ISO8859-2'
617# updated 'dutch' -> 'nl_BE.ISO8859-1' to 'nl_NL.ISO8859-1'
618# updated 'et' -> 'et_EE.ISO8859-4' to 'et_EE.ISO8859-15'
619# updated 'et_ee' -> 'et_EE.ISO8859-4' to 'et_EE.ISO8859-15'
620# updated 'fi' -> 'fi_FI.ISO8859-1' to 'fi_FI.ISO8859-15'
621# updated 'fi_fi' -> 'fi_FI.ISO8859-1' to 'fi_FI.ISO8859-15'
622# updated 'iw' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
623# updated 'iw_il' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
624# updated 'japanese' -> 'ja_JP.SJIS' to 'ja_JP.eucJP'
625# updated 'lt' -> 'lt_LT.ISO8859-4' to 'lt_LT.ISO8859-13'
626# updated 'lv' -> 'lv_LV.ISO8859-4' to 'lv_LV.ISO8859-13'
627# updated 'sl' -> 'sl_CS.ISO8859-2' to 'sl_SI.ISO8859-2'
628# updated 'slovene' -> 'sl_CS.ISO8859-2' to 'sl_SI.ISO8859-2'
629# updated 'th_th' -> 'th_TH.TACTIS' to 'th_TH.ISO8859-11'
630# updated 'zh_cn' -> 'zh_CN.eucCN' to 'zh_CN.gb2312'
631# updated 'zh_cn.big5' -> 'zh_TW.eucTW' to 'zh_TW.big5'
632# updated 'zh_tw' -> 'zh_TW.eucTW' to 'zh_TW.big5'
633#
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000634# MAL 2008-05-30:
635# Updated alias mapping to most recent locale.alias file
636# from X.org distribution using makelocalealias.py.
637#
638# These are the differences compared to the old mapping (Python 2.5
639# and older):
640#
641# updated 'cs_cs.iso88592' -> 'cs_CZ.ISO8859-2' to 'cs_CS.ISO8859-2'
642# updated 'serbocroatian' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
643# updated 'sh' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
644# updated 'sh_hr.iso88592' -> 'sh_HR.ISO8859-2' to 'hr_HR.ISO8859-2'
645# updated 'sh_sp' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
646# updated 'sh_yu' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
647# updated 'sp' -> 'sp_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
648# updated 'sp_yu' -> 'sp_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
649# updated 'sr' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
650# updated 'sr@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
651# updated 'sr_sp' -> 'sr_SP.ISO8859-2' to 'sr_CS.ISO8859-2'
652# updated 'sr_yu' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
653# updated 'sr_yu.cp1251@cyrillic' -> 'sr_YU.CP1251' to 'sr_CS.CP1251'
654# updated 'sr_yu.iso88592' -> 'sr_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
655# updated 'sr_yu.iso88595' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
656# updated 'sr_yu.iso88595@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
657# updated 'sr_yu.microsoftcp1251@cyrillic' -> 'sr_YU.CP1251' to 'sr_CS.CP1251'
658# updated 'sr_yu.utf8@cyrillic' -> 'sr_YU.UTF-8' to 'sr_CS.UTF-8'
659# updated 'sr_yu@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
660
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000661locale_alias = {
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000662 'a3': 'a3_AZ.KOI8-C',
663 'a3_az': 'a3_AZ.KOI8-C',
664 'a3_az.koi8c': 'a3_AZ.KOI8-C',
665 'af': 'af_ZA.ISO8859-1',
666 'af_za': 'af_ZA.ISO8859-1',
667 'af_za.iso88591': 'af_ZA.ISO8859-1',
668 'am': 'am_ET.UTF-8',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000669 'am_et': 'am_ET.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000670 'american': 'en_US.ISO8859-1',
671 'american.iso88591': 'en_US.ISO8859-1',
672 'ar': 'ar_AA.ISO8859-6',
673 'ar_aa': 'ar_AA.ISO8859-6',
674 'ar_aa.iso88596': 'ar_AA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000675 'ar_ae': 'ar_AE.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000676 'ar_ae.iso88596': 'ar_AE.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000677 'ar_bh': 'ar_BH.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000678 'ar_bh.iso88596': 'ar_BH.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000679 'ar_dz': 'ar_DZ.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000680 'ar_dz.iso88596': 'ar_DZ.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000681 'ar_eg': 'ar_EG.ISO8859-6',
682 'ar_eg.iso88596': 'ar_EG.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000683 'ar_iq': 'ar_IQ.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000684 'ar_iq.iso88596': 'ar_IQ.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000685 'ar_jo': 'ar_JO.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000686 'ar_jo.iso88596': 'ar_JO.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000687 'ar_kw': 'ar_KW.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000688 'ar_kw.iso88596': 'ar_KW.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000689 'ar_lb': 'ar_LB.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000690 'ar_lb.iso88596': 'ar_LB.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000691 'ar_ly': 'ar_LY.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000692 'ar_ly.iso88596': 'ar_LY.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000693 'ar_ma': 'ar_MA.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000694 'ar_ma.iso88596': 'ar_MA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000695 'ar_om': 'ar_OM.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000696 'ar_om.iso88596': 'ar_OM.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000697 'ar_qa': 'ar_QA.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000698 'ar_qa.iso88596': 'ar_QA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000699 'ar_sa': 'ar_SA.ISO8859-6',
700 'ar_sa.iso88596': 'ar_SA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000701 'ar_sd': 'ar_SD.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000702 'ar_sd.iso88596': 'ar_SD.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000703 'ar_sy': 'ar_SY.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000704 'ar_sy.iso88596': 'ar_SY.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000705 'ar_tn': 'ar_TN.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000706 'ar_tn.iso88596': 'ar_TN.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000707 'ar_ye': 'ar_YE.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000708 'ar_ye.iso88596': 'ar_YE.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000709 'arabic': 'ar_AA.ISO8859-6',
710 'arabic.iso88596': 'ar_AA.ISO8859-6',
711 'az': 'az_AZ.ISO8859-9E',
712 'az_az': 'az_AZ.ISO8859-9E',
713 'az_az.iso88599e': 'az_AZ.ISO8859-9E',
714 'be': 'be_BY.CP1251',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000715 'be_by': 'be_BY.CP1251',
716 'be_by.cp1251': 'be_BY.CP1251',
717 'be_by.microsoftcp1251': 'be_BY.CP1251',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000718 'bg': 'bg_BG.CP1251',
719 'bg_bg': 'bg_BG.CP1251',
720 'bg_bg.cp1251': 'bg_BG.CP1251',
721 'bg_bg.iso88595': 'bg_BG.ISO8859-5',
722 'bg_bg.koi8r': 'bg_BG.KOI8-R',
723 'bg_bg.microsoftcp1251': 'bg_BG.CP1251',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000724 'bn_in': 'bn_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000725 'bokmal': 'nb_NO.ISO8859-1',
726 'bokm\xe5l': 'nb_NO.ISO8859-1',
727 'br': 'br_FR.ISO8859-1',
728 'br_fr': 'br_FR.ISO8859-1',
729 'br_fr.iso88591': 'br_FR.ISO8859-1',
730 'br_fr.iso885914': 'br_FR.ISO8859-14',
731 'br_fr.iso885915': 'br_FR.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000732 'br_fr.iso885915@euro': 'br_FR.ISO8859-15',
733 'br_fr.utf8@euro': 'br_FR.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000734 'br_fr@euro': 'br_FR.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000735 'bs': 'bs_BA.ISO8859-2',
736 'bs_ba': 'bs_BA.ISO8859-2',
737 'bs_ba.iso88592': 'bs_BA.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000738 'bulgarian': 'bg_BG.CP1251',
739 'c': 'C',
740 'c-french': 'fr_CA.ISO8859-1',
741 'c-french.iso88591': 'fr_CA.ISO8859-1',
742 'c.en': 'C',
743 'c.iso88591': 'en_US.ISO8859-1',
744 'c_c': 'C',
745 'c_c.c': 'C',
746 'ca': 'ca_ES.ISO8859-1',
747 'ca_es': 'ca_ES.ISO8859-1',
748 'ca_es.iso88591': 'ca_ES.ISO8859-1',
749 'ca_es.iso885915': 'ca_ES.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000750 'ca_es.iso885915@euro': 'ca_ES.ISO8859-15',
751 'ca_es.utf8@euro': 'ca_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000752 'ca_es@euro': 'ca_ES.ISO8859-15',
753 'catalan': 'ca_ES.ISO8859-1',
754 'cextend': 'en_US.ISO8859-1',
755 'cextend.en': 'en_US.ISO8859-1',
756 'chinese-s': 'zh_CN.eucCN',
757 'chinese-t': 'zh_TW.eucTW',
758 'croatian': 'hr_HR.ISO8859-2',
759 'cs': 'cs_CZ.ISO8859-2',
760 'cs_cs': 'cs_CZ.ISO8859-2',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000761 'cs_cs.iso88592': 'cs_CS.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000762 'cs_cz': 'cs_CZ.ISO8859-2',
763 'cs_cz.iso88592': 'cs_CZ.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000764 'cy': 'cy_GB.ISO8859-1',
765 'cy_gb': 'cy_GB.ISO8859-1',
766 'cy_gb.iso88591': 'cy_GB.ISO8859-1',
767 'cy_gb.iso885914': 'cy_GB.ISO8859-14',
768 'cy_gb.iso885915': 'cy_GB.ISO8859-15',
769 'cy_gb@euro': 'cy_GB.ISO8859-15',
770 'cz': 'cs_CZ.ISO8859-2',
771 'cz_cz': 'cs_CZ.ISO8859-2',
772 'czech': 'cs_CZ.ISO8859-2',
773 'da': 'da_DK.ISO8859-1',
774 'da_dk': 'da_DK.ISO8859-1',
775 'da_dk.88591': 'da_DK.ISO8859-1',
776 'da_dk.885915': 'da_DK.ISO8859-15',
777 'da_dk.iso88591': 'da_DK.ISO8859-1',
778 'da_dk.iso885915': 'da_DK.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000779 'da_dk@euro': 'da_DK.ISO8859-15',
780 'danish': 'da_DK.ISO8859-1',
781 'danish.iso88591': 'da_DK.ISO8859-1',
782 'dansk': 'da_DK.ISO8859-1',
783 'de': 'de_DE.ISO8859-1',
784 'de_at': 'de_AT.ISO8859-1',
785 'de_at.iso88591': 'de_AT.ISO8859-1',
786 'de_at.iso885915': 'de_AT.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000787 'de_at.iso885915@euro': 'de_AT.ISO8859-15',
788 'de_at.utf8@euro': 'de_AT.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000789 'de_at@euro': 'de_AT.ISO8859-15',
790 'de_be': 'de_BE.ISO8859-1',
791 'de_be.iso88591': 'de_BE.ISO8859-1',
792 'de_be.iso885915': 'de_BE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000793 'de_be.iso885915@euro': 'de_BE.ISO8859-15',
794 'de_be.utf8@euro': 'de_BE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000795 'de_be@euro': 'de_BE.ISO8859-15',
796 'de_ch': 'de_CH.ISO8859-1',
797 'de_ch.iso88591': 'de_CH.ISO8859-1',
798 'de_ch.iso885915': 'de_CH.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000799 'de_ch@euro': 'de_CH.ISO8859-15',
800 'de_de': 'de_DE.ISO8859-1',
801 'de_de.88591': 'de_DE.ISO8859-1',
802 'de_de.885915': 'de_DE.ISO8859-15',
803 'de_de.885915@euro': 'de_DE.ISO8859-15',
804 'de_de.iso88591': 'de_DE.ISO8859-1',
805 'de_de.iso885915': 'de_DE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000806 'de_de.iso885915@euro': 'de_DE.ISO8859-15',
807 'de_de.utf8@euro': 'de_DE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000808 'de_de@euro': 'de_DE.ISO8859-15',
809 'de_lu': 'de_LU.ISO8859-1',
810 'de_lu.iso88591': 'de_LU.ISO8859-1',
811 'de_lu.iso885915': 'de_LU.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000812 'de_lu.iso885915@euro': 'de_LU.ISO8859-15',
813 'de_lu.utf8@euro': 'de_LU.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000814 'de_lu@euro': 'de_LU.ISO8859-15',
815 'deutsch': 'de_DE.ISO8859-1',
816 'dutch': 'nl_NL.ISO8859-1',
817 'dutch.iso88591': 'nl_BE.ISO8859-1',
818 'ee': 'ee_EE.ISO8859-4',
819 'ee_ee': 'ee_EE.ISO8859-4',
820 'ee_ee.iso88594': 'ee_EE.ISO8859-4',
821 'eesti': 'et_EE.ISO8859-1',
822 'el': 'el_GR.ISO8859-7',
823 'el_gr': 'el_GR.ISO8859-7',
824 'el_gr.iso88597': 'el_GR.ISO8859-7',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000825 'el_gr@euro': 'el_GR.ISO8859-15',
826 'en': 'en_US.ISO8859-1',
827 'en.iso88591': 'en_US.ISO8859-1',
828 'en_au': 'en_AU.ISO8859-1',
829 'en_au.iso88591': 'en_AU.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000830 'en_be': 'en_BE.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000831 'en_be@euro': 'en_BE.ISO8859-15',
832 'en_bw': 'en_BW.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000833 'en_bw.iso88591': 'en_BW.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000834 'en_ca': 'en_CA.ISO8859-1',
835 'en_ca.iso88591': 'en_CA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000836 'en_gb': 'en_GB.ISO8859-1',
837 'en_gb.88591': 'en_GB.ISO8859-1',
838 'en_gb.iso88591': 'en_GB.ISO8859-1',
839 'en_gb.iso885915': 'en_GB.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000840 'en_gb@euro': 'en_GB.ISO8859-15',
841 'en_hk': 'en_HK.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000842 'en_hk.iso88591': 'en_HK.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000843 'en_ie': 'en_IE.ISO8859-1',
844 'en_ie.iso88591': 'en_IE.ISO8859-1',
845 'en_ie.iso885915': 'en_IE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000846 'en_ie.iso885915@euro': 'en_IE.ISO8859-15',
847 'en_ie.utf8@euro': 'en_IE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000848 'en_ie@euro': 'en_IE.ISO8859-15',
849 'en_in': 'en_IN.ISO8859-1',
850 'en_nz': 'en_NZ.ISO8859-1',
851 'en_nz.iso88591': 'en_NZ.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000852 'en_ph': 'en_PH.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000853 'en_ph.iso88591': 'en_PH.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000854 'en_sg': 'en_SG.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000855 'en_sg.iso88591': 'en_SG.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000856 'en_uk': 'en_GB.ISO8859-1',
857 'en_us': 'en_US.ISO8859-1',
858 'en_us.88591': 'en_US.ISO8859-1',
859 'en_us.885915': 'en_US.ISO8859-15',
860 'en_us.iso88591': 'en_US.ISO8859-1',
861 'en_us.iso885915': 'en_US.ISO8859-15',
862 'en_us.iso885915@euro': 'en_US.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000863 'en_us@euro': 'en_US.ISO8859-15',
864 'en_us@euro@euro': 'en_US.ISO8859-15',
865 'en_za': 'en_ZA.ISO8859-1',
866 'en_za.88591': 'en_ZA.ISO8859-1',
867 'en_za.iso88591': 'en_ZA.ISO8859-1',
868 'en_za.iso885915': 'en_ZA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000869 'en_za@euro': 'en_ZA.ISO8859-15',
870 'en_zw': 'en_ZW.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000871 'en_zw.iso88591': 'en_ZW.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000872 'eng_gb': 'en_GB.ISO8859-1',
873 'eng_gb.8859': 'en_GB.ISO8859-1',
874 'english': 'en_EN.ISO8859-1',
875 'english.iso88591': 'en_EN.ISO8859-1',
876 'english_uk': 'en_GB.ISO8859-1',
877 'english_uk.8859': 'en_GB.ISO8859-1',
878 'english_united-states': 'en_US.ISO8859-1',
879 'english_united-states.437': 'C',
880 'english_us': 'en_US.ISO8859-1',
881 'english_us.8859': 'en_US.ISO8859-1',
882 'english_us.ascii': 'en_US.ISO8859-1',
883 'eo': 'eo_XX.ISO8859-3',
884 'eo_eo': 'eo_EO.ISO8859-3',
885 'eo_eo.iso88593': 'eo_EO.ISO8859-3',
886 'eo_xx': 'eo_XX.ISO8859-3',
887 'eo_xx.iso88593': 'eo_XX.ISO8859-3',
888 'es': 'es_ES.ISO8859-1',
889 'es_ar': 'es_AR.ISO8859-1',
890 'es_ar.iso88591': 'es_AR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000891 'es_bo': 'es_BO.ISO8859-1',
892 'es_bo.iso88591': 'es_BO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000893 'es_cl': 'es_CL.ISO8859-1',
894 'es_cl.iso88591': 'es_CL.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000895 'es_co': 'es_CO.ISO8859-1',
896 'es_co.iso88591': 'es_CO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000897 'es_cr': 'es_CR.ISO8859-1',
898 'es_cr.iso88591': 'es_CR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000899 'es_do': 'es_DO.ISO8859-1',
900 'es_do.iso88591': 'es_DO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000901 'es_ec': 'es_EC.ISO8859-1',
902 'es_ec.iso88591': 'es_EC.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000903 'es_es': 'es_ES.ISO8859-1',
904 'es_es.88591': 'es_ES.ISO8859-1',
905 'es_es.iso88591': 'es_ES.ISO8859-1',
906 'es_es.iso885915': 'es_ES.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000907 'es_es.iso885915@euro': 'es_ES.ISO8859-15',
908 'es_es.utf8@euro': 'es_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000909 'es_es@euro': 'es_ES.ISO8859-15',
910 'es_gt': 'es_GT.ISO8859-1',
911 'es_gt.iso88591': 'es_GT.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000912 'es_hn': 'es_HN.ISO8859-1',
913 'es_hn.iso88591': 'es_HN.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000914 'es_mx': 'es_MX.ISO8859-1',
915 'es_mx.iso88591': 'es_MX.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000916 'es_ni': 'es_NI.ISO8859-1',
917 'es_ni.iso88591': 'es_NI.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000918 'es_pa': 'es_PA.ISO8859-1',
919 'es_pa.iso88591': 'es_PA.ISO8859-1',
920 'es_pa.iso885915': 'es_PA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000921 'es_pa@euro': 'es_PA.ISO8859-15',
922 'es_pe': 'es_PE.ISO8859-1',
923 'es_pe.iso88591': 'es_PE.ISO8859-1',
924 'es_pe.iso885915': 'es_PE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000925 'es_pe@euro': 'es_PE.ISO8859-15',
926 'es_pr': 'es_PR.ISO8859-1',
927 'es_pr.iso88591': 'es_PR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000928 'es_py': 'es_PY.ISO8859-1',
929 'es_py.iso88591': 'es_PY.ISO8859-1',
930 'es_py.iso885915': 'es_PY.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000931 'es_py@euro': 'es_PY.ISO8859-15',
932 'es_sv': 'es_SV.ISO8859-1',
933 'es_sv.iso88591': 'es_SV.ISO8859-1',
934 'es_sv.iso885915': 'es_SV.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000935 'es_sv@euro': 'es_SV.ISO8859-15',
936 'es_us': 'es_US.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000937 'es_us.iso88591': 'es_US.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000938 'es_uy': 'es_UY.ISO8859-1',
939 'es_uy.iso88591': 'es_UY.ISO8859-1',
940 'es_uy.iso885915': 'es_UY.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000941 'es_uy@euro': 'es_UY.ISO8859-15',
942 'es_ve': 'es_VE.ISO8859-1',
943 'es_ve.iso88591': 'es_VE.ISO8859-1',
944 'es_ve.iso885915': 'es_VE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000945 'es_ve@euro': 'es_VE.ISO8859-15',
946 'estonian': 'et_EE.ISO8859-1',
947 'et': 'et_EE.ISO8859-15',
948 'et_ee': 'et_EE.ISO8859-15',
949 'et_ee.iso88591': 'et_EE.ISO8859-1',
950 'et_ee.iso885913': 'et_EE.ISO8859-13',
951 'et_ee.iso885915': 'et_EE.ISO8859-15',
952 'et_ee.iso88594': 'et_EE.ISO8859-4',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000953 'et_ee@euro': 'et_EE.ISO8859-15',
954 'eu': 'eu_ES.ISO8859-1',
955 'eu_es': 'eu_ES.ISO8859-1',
956 'eu_es.iso88591': 'eu_ES.ISO8859-1',
957 'eu_es.iso885915': 'eu_ES.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000958 'eu_es.iso885915@euro': 'eu_ES.ISO8859-15',
959 'eu_es.utf8@euro': 'eu_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000960 'eu_es@euro': 'eu_ES.ISO8859-15',
961 'fa': 'fa_IR.UTF-8',
962 'fa_ir': 'fa_IR.UTF-8',
963 'fa_ir.isiri3342': 'fa_IR.ISIRI-3342',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000964 'fi': 'fi_FI.ISO8859-15',
965 'fi_fi': 'fi_FI.ISO8859-15',
966 'fi_fi.88591': 'fi_FI.ISO8859-1',
967 'fi_fi.iso88591': 'fi_FI.ISO8859-1',
968 'fi_fi.iso885915': 'fi_FI.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000969 'fi_fi.iso885915@euro': 'fi_FI.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000970 'fi_fi.utf8@euro': 'fi_FI.UTF-8',
971 'fi_fi@euro': 'fi_FI.ISO8859-15',
972 'finnish': 'fi_FI.ISO8859-1',
973 'finnish.iso88591': 'fi_FI.ISO8859-1',
974 'fo': 'fo_FO.ISO8859-1',
975 'fo_fo': 'fo_FO.ISO8859-1',
976 'fo_fo.iso88591': 'fo_FO.ISO8859-1',
977 'fo_fo.iso885915': 'fo_FO.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000978 'fo_fo@euro': 'fo_FO.ISO8859-15',
979 'fr': 'fr_FR.ISO8859-1',
980 'fr_be': 'fr_BE.ISO8859-1',
981 'fr_be.88591': 'fr_BE.ISO8859-1',
982 'fr_be.iso88591': 'fr_BE.ISO8859-1',
983 'fr_be.iso885915': 'fr_BE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000984 'fr_be.iso885915@euro': 'fr_BE.ISO8859-15',
985 'fr_be.utf8@euro': 'fr_BE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000986 'fr_be@euro': 'fr_BE.ISO8859-15',
987 'fr_ca': 'fr_CA.ISO8859-1',
988 'fr_ca.88591': 'fr_CA.ISO8859-1',
989 'fr_ca.iso88591': 'fr_CA.ISO8859-1',
990 'fr_ca.iso885915': 'fr_CA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000991 'fr_ca@euro': 'fr_CA.ISO8859-15',
992 'fr_ch': 'fr_CH.ISO8859-1',
993 'fr_ch.88591': 'fr_CH.ISO8859-1',
994 'fr_ch.iso88591': 'fr_CH.ISO8859-1',
995 'fr_ch.iso885915': 'fr_CH.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000996 'fr_ch@euro': 'fr_CH.ISO8859-15',
997 'fr_fr': 'fr_FR.ISO8859-1',
998 'fr_fr.88591': 'fr_FR.ISO8859-1',
999 'fr_fr.iso88591': 'fr_FR.ISO8859-1',
1000 'fr_fr.iso885915': 'fr_FR.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001001 'fr_fr.iso885915@euro': 'fr_FR.ISO8859-15',
1002 'fr_fr.utf8@euro': 'fr_FR.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001003 'fr_fr@euro': 'fr_FR.ISO8859-15',
1004 'fr_lu': 'fr_LU.ISO8859-1',
1005 'fr_lu.88591': 'fr_LU.ISO8859-1',
1006 'fr_lu.iso88591': 'fr_LU.ISO8859-1',
1007 'fr_lu.iso885915': 'fr_LU.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001008 'fr_lu.iso885915@euro': 'fr_LU.ISO8859-15',
1009 'fr_lu.utf8@euro': 'fr_LU.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001010 'fr_lu@euro': 'fr_LU.ISO8859-15',
1011 'fran\xe7ais': 'fr_FR.ISO8859-1',
1012 'fre_fr': 'fr_FR.ISO8859-1',
1013 'fre_fr.8859': 'fr_FR.ISO8859-1',
1014 'french': 'fr_FR.ISO8859-1',
1015 'french.iso88591': 'fr_CH.ISO8859-1',
1016 'french_france': 'fr_FR.ISO8859-1',
1017 'french_france.8859': 'fr_FR.ISO8859-1',
1018 'ga': 'ga_IE.ISO8859-1',
1019 'ga_ie': 'ga_IE.ISO8859-1',
1020 'ga_ie.iso88591': 'ga_IE.ISO8859-1',
1021 'ga_ie.iso885914': 'ga_IE.ISO8859-14',
1022 'ga_ie.iso885915': 'ga_IE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001023 'ga_ie.iso885915@euro': 'ga_IE.ISO8859-15',
1024 'ga_ie.utf8@euro': 'ga_IE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001025 'ga_ie@euro': 'ga_IE.ISO8859-15',
1026 'galego': 'gl_ES.ISO8859-1',
1027 'galician': 'gl_ES.ISO8859-1',
1028 'gd': 'gd_GB.ISO8859-1',
1029 'gd_gb': 'gd_GB.ISO8859-1',
1030 'gd_gb.iso88591': 'gd_GB.ISO8859-1',
1031 'gd_gb.iso885914': 'gd_GB.ISO8859-14',
1032 'gd_gb.iso885915': 'gd_GB.ISO8859-15',
1033 'gd_gb@euro': 'gd_GB.ISO8859-15',
1034 'ger_de': 'de_DE.ISO8859-1',
1035 'ger_de.8859': 'de_DE.ISO8859-1',
1036 'german': 'de_DE.ISO8859-1',
1037 'german.iso88591': 'de_CH.ISO8859-1',
1038 'german_germany': 'de_DE.ISO8859-1',
1039 'german_germany.8859': 'de_DE.ISO8859-1',
1040 'gl': 'gl_ES.ISO8859-1',
1041 'gl_es': 'gl_ES.ISO8859-1',
1042 'gl_es.iso88591': 'gl_ES.ISO8859-1',
1043 'gl_es.iso885915': 'gl_ES.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001044 'gl_es.iso885915@euro': 'gl_ES.ISO8859-15',
1045 'gl_es.utf8@euro': 'gl_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001046 'gl_es@euro': 'gl_ES.ISO8859-15',
1047 'greek': 'el_GR.ISO8859-7',
1048 'greek.iso88597': 'el_GR.ISO8859-7',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001049 'gu_in': 'gu_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001050 'gv': 'gv_GB.ISO8859-1',
1051 'gv_gb': 'gv_GB.ISO8859-1',
1052 'gv_gb.iso88591': 'gv_GB.ISO8859-1',
1053 'gv_gb.iso885914': 'gv_GB.ISO8859-14',
1054 'gv_gb.iso885915': 'gv_GB.ISO8859-15',
1055 'gv_gb@euro': 'gv_GB.ISO8859-15',
1056 'he': 'he_IL.ISO8859-8',
1057 'he_il': 'he_IL.ISO8859-8',
1058 'he_il.cp1255': 'he_IL.CP1255',
1059 'he_il.iso88598': 'he_IL.ISO8859-8',
1060 'he_il.microsoftcp1255': 'he_IL.CP1255',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001061 'hebrew': 'iw_IL.ISO8859-8',
1062 'hebrew.iso88598': 'iw_IL.ISO8859-8',
1063 'hi': 'hi_IN.ISCII-DEV',
1064 'hi_in': 'hi_IN.ISCII-DEV',
1065 'hi_in.isciidev': 'hi_IN.ISCII-DEV',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001066 'hr': 'hr_HR.ISO8859-2',
1067 'hr_hr': 'hr_HR.ISO8859-2',
1068 'hr_hr.iso88592': 'hr_HR.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001069 'hrvatski': 'hr_HR.ISO8859-2',
1070 'hu': 'hu_HU.ISO8859-2',
1071 'hu_hu': 'hu_HU.ISO8859-2',
1072 'hu_hu.iso88592': 'hu_HU.ISO8859-2',
1073 'hungarian': 'hu_HU.ISO8859-2',
1074 'icelandic': 'is_IS.ISO8859-1',
1075 'icelandic.iso88591': 'is_IS.ISO8859-1',
1076 'id': 'id_ID.ISO8859-1',
1077 'id_id': 'id_ID.ISO8859-1',
1078 'in': 'id_ID.ISO8859-1',
1079 'in_id': 'id_ID.ISO8859-1',
1080 'is': 'is_IS.ISO8859-1',
1081 'is_is': 'is_IS.ISO8859-1',
1082 'is_is.iso88591': 'is_IS.ISO8859-1',
1083 'is_is.iso885915': 'is_IS.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001084 'is_is@euro': 'is_IS.ISO8859-15',
1085 'iso-8859-1': 'en_US.ISO8859-1',
1086 'iso-8859-15': 'en_US.ISO8859-15',
1087 'iso8859-1': 'en_US.ISO8859-1',
1088 'iso8859-15': 'en_US.ISO8859-15',
1089 'iso_8859_1': 'en_US.ISO8859-1',
1090 'iso_8859_15': 'en_US.ISO8859-15',
1091 'it': 'it_IT.ISO8859-1',
1092 'it_ch': 'it_CH.ISO8859-1',
1093 'it_ch.iso88591': 'it_CH.ISO8859-1',
1094 'it_ch.iso885915': 'it_CH.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001095 'it_ch@euro': 'it_CH.ISO8859-15',
1096 'it_it': 'it_IT.ISO8859-1',
1097 'it_it.88591': 'it_IT.ISO8859-1',
1098 'it_it.iso88591': 'it_IT.ISO8859-1',
1099 'it_it.iso885915': 'it_IT.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001100 'it_it.iso885915@euro': 'it_IT.ISO8859-15',
1101 'it_it.utf8@euro': 'it_IT.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001102 'it_it@euro': 'it_IT.ISO8859-15',
1103 'italian': 'it_IT.ISO8859-1',
1104 'italian.iso88591': 'it_IT.ISO8859-1',
1105 'iu': 'iu_CA.NUNACOM-8',
1106 'iu_ca': 'iu_CA.NUNACOM-8',
1107 'iu_ca.nunacom8': 'iu_CA.NUNACOM-8',
1108 'iw': 'he_IL.ISO8859-8',
1109 'iw_il': 'he_IL.ISO8859-8',
1110 'iw_il.iso88598': 'he_IL.ISO8859-8',
1111 'ja': 'ja_JP.eucJP',
1112 'ja.jis': 'ja_JP.JIS7',
1113 'ja.sjis': 'ja_JP.SJIS',
1114 'ja_jp': 'ja_JP.eucJP',
1115 'ja_jp.ajec': 'ja_JP.eucJP',
1116 'ja_jp.euc': 'ja_JP.eucJP',
1117 'ja_jp.eucjp': 'ja_JP.eucJP',
1118 'ja_jp.iso-2022-jp': 'ja_JP.JIS7',
1119 'ja_jp.iso2022jp': 'ja_JP.JIS7',
1120 'ja_jp.jis': 'ja_JP.JIS7',
1121 'ja_jp.jis7': 'ja_JP.JIS7',
1122 'ja_jp.mscode': 'ja_JP.SJIS',
1123 'ja_jp.sjis': 'ja_JP.SJIS',
1124 'ja_jp.ujis': 'ja_JP.eucJP',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001125 'japan': 'ja_JP.eucJP',
1126 'japanese': 'ja_JP.eucJP',
1127 'japanese-euc': 'ja_JP.eucJP',
1128 'japanese.euc': 'ja_JP.eucJP',
1129 'japanese.sjis': 'ja_JP.SJIS',
1130 'jp_jp': 'ja_JP.eucJP',
1131 'ka': 'ka_GE.GEORGIAN-ACADEMY',
1132 'ka_ge': 'ka_GE.GEORGIAN-ACADEMY',
1133 'ka_ge.georgianacademy': 'ka_GE.GEORGIAN-ACADEMY',
1134 'ka_ge.georgianps': 'ka_GE.GEORGIAN-PS',
1135 'ka_ge.georgianrs': 'ka_GE.GEORGIAN-ACADEMY',
1136 'kl': 'kl_GL.ISO8859-1',
1137 'kl_gl': 'kl_GL.ISO8859-1',
1138 'kl_gl.iso88591': 'kl_GL.ISO8859-1',
1139 'kl_gl.iso885915': 'kl_GL.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001140 'kl_gl@euro': 'kl_GL.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001141 'km_kh': 'km_KH.UTF-8',
1142 'kn_in': 'kn_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001143 'ko': 'ko_KR.eucKR',
1144 'ko_kr': 'ko_KR.eucKR',
1145 'ko_kr.euc': 'ko_KR.eucKR',
1146 'ko_kr.euckr': 'ko_KR.eucKR',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001147 'korean': 'ko_KR.eucKR',
1148 'korean.euc': 'ko_KR.eucKR',
1149 'kw': 'kw_GB.ISO8859-1',
1150 'kw_gb': 'kw_GB.ISO8859-1',
1151 'kw_gb.iso88591': 'kw_GB.ISO8859-1',
1152 'kw_gb.iso885914': 'kw_GB.ISO8859-14',
1153 'kw_gb.iso885915': 'kw_GB.ISO8859-15',
1154 'kw_gb@euro': 'kw_GB.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001155 'ky': 'ky_KG.UTF-8',
1156 'ky_kg': 'ky_KG.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001157 'lithuanian': 'lt_LT.ISO8859-13',
1158 'lo': 'lo_LA.MULELAO-1',
1159 'lo_la': 'lo_LA.MULELAO-1',
1160 'lo_la.cp1133': 'lo_LA.IBM-CP1133',
1161 'lo_la.ibmcp1133': 'lo_LA.IBM-CP1133',
1162 'lo_la.mulelao1': 'lo_LA.MULELAO-1',
1163 'lt': 'lt_LT.ISO8859-13',
1164 'lt_lt': 'lt_LT.ISO8859-13',
1165 'lt_lt.iso885913': 'lt_LT.ISO8859-13',
1166 'lt_lt.iso88594': 'lt_LT.ISO8859-4',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001167 'lv': 'lv_LV.ISO8859-13',
1168 'lv_lv': 'lv_LV.ISO8859-13',
1169 'lv_lv.iso885913': 'lv_LV.ISO8859-13',
1170 'lv_lv.iso88594': 'lv_LV.ISO8859-4',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001171 'mi': 'mi_NZ.ISO8859-1',
1172 'mi_nz': 'mi_NZ.ISO8859-1',
1173 'mi_nz.iso88591': 'mi_NZ.ISO8859-1',
1174 'mk': 'mk_MK.ISO8859-5',
1175 'mk_mk': 'mk_MK.ISO8859-5',
1176 'mk_mk.cp1251': 'mk_MK.CP1251',
1177 'mk_mk.iso88595': 'mk_MK.ISO8859-5',
1178 'mk_mk.microsoftcp1251': 'mk_MK.CP1251',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001179 'mr_in': 'mr_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001180 'ms': 'ms_MY.ISO8859-1',
1181 'ms_my': 'ms_MY.ISO8859-1',
1182 'ms_my.iso88591': 'ms_MY.ISO8859-1',
1183 'mt': 'mt_MT.ISO8859-3',
1184 'mt_mt': 'mt_MT.ISO8859-3',
1185 'mt_mt.iso88593': 'mt_MT.ISO8859-3',
1186 'nb': 'nb_NO.ISO8859-1',
1187 'nb_no': 'nb_NO.ISO8859-1',
1188 'nb_no.88591': 'nb_NO.ISO8859-1',
1189 'nb_no.iso88591': 'nb_NO.ISO8859-1',
1190 'nb_no.iso885915': 'nb_NO.ISO8859-15',
1191 'nb_no@euro': 'nb_NO.ISO8859-15',
1192 'nl': 'nl_NL.ISO8859-1',
1193 'nl_be': 'nl_BE.ISO8859-1',
1194 'nl_be.88591': 'nl_BE.ISO8859-1',
1195 'nl_be.iso88591': 'nl_BE.ISO8859-1',
1196 'nl_be.iso885915': 'nl_BE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001197 'nl_be.iso885915@euro': 'nl_BE.ISO8859-15',
1198 'nl_be.utf8@euro': 'nl_BE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001199 'nl_be@euro': 'nl_BE.ISO8859-15',
1200 'nl_nl': 'nl_NL.ISO8859-1',
1201 'nl_nl.88591': 'nl_NL.ISO8859-1',
1202 'nl_nl.iso88591': 'nl_NL.ISO8859-1',
1203 'nl_nl.iso885915': 'nl_NL.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001204 'nl_nl.iso885915@euro': 'nl_NL.ISO8859-15',
1205 'nl_nl.utf8@euro': 'nl_NL.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001206 'nl_nl@euro': 'nl_NL.ISO8859-15',
1207 'nn': 'nn_NO.ISO8859-1',
1208 'nn_no': 'nn_NO.ISO8859-1',
1209 'nn_no.88591': 'nn_NO.ISO8859-1',
1210 'nn_no.iso88591': 'nn_NO.ISO8859-1',
1211 'nn_no.iso885915': 'nn_NO.ISO8859-15',
1212 'nn_no@euro': 'nn_NO.ISO8859-15',
1213 'no': 'no_NO.ISO8859-1',
1214 'no@nynorsk': 'ny_NO.ISO8859-1',
1215 'no_no': 'no_NO.ISO8859-1',
1216 'no_no.88591': 'no_NO.ISO8859-1',
1217 'no_no.iso88591': 'no_NO.ISO8859-1',
1218 'no_no.iso885915': 'no_NO.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001219 'no_no@euro': 'no_NO.ISO8859-15',
1220 'norwegian': 'no_NO.ISO8859-1',
1221 'norwegian.iso88591': 'no_NO.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001222 'nr': 'nr_ZA.ISO8859-1',
1223 'nr_za': 'nr_ZA.ISO8859-1',
1224 'nr_za.iso88591': 'nr_ZA.ISO8859-1',
1225 'nso': 'nso_ZA.ISO8859-15',
1226 'nso_za': 'nso_ZA.ISO8859-15',
1227 'nso_za.iso885915': 'nso_ZA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001228 'ny': 'ny_NO.ISO8859-1',
1229 'ny_no': 'ny_NO.ISO8859-1',
1230 'ny_no.88591': 'ny_NO.ISO8859-1',
1231 'ny_no.iso88591': 'ny_NO.ISO8859-1',
1232 'ny_no.iso885915': 'ny_NO.ISO8859-15',
1233 'ny_no@euro': 'ny_NO.ISO8859-15',
1234 'nynorsk': 'nn_NO.ISO8859-1',
1235 'oc': 'oc_FR.ISO8859-1',
1236 'oc_fr': 'oc_FR.ISO8859-1',
1237 'oc_fr.iso88591': 'oc_FR.ISO8859-1',
1238 'oc_fr.iso885915': 'oc_FR.ISO8859-15',
1239 'oc_fr@euro': 'oc_FR.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001240 'pa_in': 'pa_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001241 'pd': 'pd_US.ISO8859-1',
1242 'pd_de': 'pd_DE.ISO8859-1',
1243 'pd_de.iso88591': 'pd_DE.ISO8859-1',
1244 'pd_de.iso885915': 'pd_DE.ISO8859-15',
1245 'pd_de@euro': 'pd_DE.ISO8859-15',
1246 'pd_us': 'pd_US.ISO8859-1',
1247 'pd_us.iso88591': 'pd_US.ISO8859-1',
1248 'pd_us.iso885915': 'pd_US.ISO8859-15',
1249 'pd_us@euro': 'pd_US.ISO8859-15',
1250 'ph': 'ph_PH.ISO8859-1',
1251 'ph_ph': 'ph_PH.ISO8859-1',
1252 'ph_ph.iso88591': 'ph_PH.ISO8859-1',
1253 'pl': 'pl_PL.ISO8859-2',
1254 'pl_pl': 'pl_PL.ISO8859-2',
1255 'pl_pl.iso88592': 'pl_PL.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001256 'polish': 'pl_PL.ISO8859-2',
1257 'portuguese': 'pt_PT.ISO8859-1',
1258 'portuguese.iso88591': 'pt_PT.ISO8859-1',
1259 'portuguese_brazil': 'pt_BR.ISO8859-1',
1260 'portuguese_brazil.8859': 'pt_BR.ISO8859-1',
1261 'posix': 'C',
1262 'posix-utf2': 'C',
1263 'pp': 'pp_AN.ISO8859-1',
1264 'pp_an': 'pp_AN.ISO8859-1',
1265 'pp_an.iso88591': 'pp_AN.ISO8859-1',
1266 'pt': 'pt_PT.ISO8859-1',
1267 'pt_br': 'pt_BR.ISO8859-1',
1268 'pt_br.88591': 'pt_BR.ISO8859-1',
1269 'pt_br.iso88591': 'pt_BR.ISO8859-1',
1270 'pt_br.iso885915': 'pt_BR.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001271 'pt_br@euro': 'pt_BR.ISO8859-15',
1272 'pt_pt': 'pt_PT.ISO8859-1',
1273 'pt_pt.88591': 'pt_PT.ISO8859-1',
1274 'pt_pt.iso88591': 'pt_PT.ISO8859-1',
1275 'pt_pt.iso885915': 'pt_PT.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001276 'pt_pt.iso885915@euro': 'pt_PT.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001277 'pt_pt.utf8@euro': 'pt_PT.UTF-8',
1278 'pt_pt@euro': 'pt_PT.ISO8859-15',
1279 'ro': 'ro_RO.ISO8859-2',
1280 'ro_ro': 'ro_RO.ISO8859-2',
1281 'ro_ro.iso88592': 'ro_RO.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001282 'romanian': 'ro_RO.ISO8859-2',
1283 'ru': 'ru_RU.ISO8859-5',
1284 'ru_ru': 'ru_RU.ISO8859-5',
1285 'ru_ru.cp1251': 'ru_RU.CP1251',
1286 'ru_ru.iso88595': 'ru_RU.ISO8859-5',
1287 'ru_ru.koi8r': 'ru_RU.KOI8-R',
1288 'ru_ru.microsoftcp1251': 'ru_RU.CP1251',
1289 'ru_ua': 'ru_UA.KOI8-U',
1290 'ru_ua.cp1251': 'ru_UA.CP1251',
1291 'ru_ua.koi8u': 'ru_UA.KOI8-U',
1292 'ru_ua.microsoftcp1251': 'ru_UA.CP1251',
1293 'rumanian': 'ro_RO.ISO8859-2',
1294 'russian': 'ru_RU.ISO8859-5',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001295 'rw': 'rw_RW.ISO8859-1',
1296 'rw_rw': 'rw_RW.ISO8859-1',
1297 'rw_rw.iso88591': 'rw_RW.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001298 'se_no': 'se_NO.UTF-8',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001299 'serbocroatian': 'sr_CS.ISO8859-2',
1300 'sh': 'sr_CS.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001301 'sh_hr': 'sh_HR.ISO8859-2',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001302 'sh_hr.iso88592': 'hr_HR.ISO8859-2',
1303 'sh_sp': 'sr_CS.ISO8859-2',
1304 'sh_yu': 'sr_CS.ISO8859-2',
1305 'si': 'si_LK.UTF-8',
1306 'si_lk': 'si_LK.UTF-8',
1307 'sinhala': 'si_LK.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001308 'sk': 'sk_SK.ISO8859-2',
1309 'sk_sk': 'sk_SK.ISO8859-2',
1310 'sk_sk.iso88592': 'sk_SK.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001311 'sl': 'sl_SI.ISO8859-2',
1312 'sl_cs': 'sl_CS.ISO8859-2',
1313 'sl_si': 'sl_SI.ISO8859-2',
1314 'sl_si.iso88592': 'sl_SI.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001315 'slovak': 'sk_SK.ISO8859-2',
1316 'slovene': 'sl_SI.ISO8859-2',
1317 'slovenian': 'sl_SI.ISO8859-2',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001318 'sp': 'sr_CS.ISO8859-5',
1319 'sp_yu': 'sr_CS.ISO8859-5',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001320 'spanish': 'es_ES.ISO8859-1',
1321 'spanish.iso88591': 'es_ES.ISO8859-1',
1322 'spanish_spain': 'es_ES.ISO8859-1',
1323 'spanish_spain.8859': 'es_ES.ISO8859-1',
1324 'sq': 'sq_AL.ISO8859-2',
1325 'sq_al': 'sq_AL.ISO8859-2',
1326 'sq_al.iso88592': 'sq_AL.ISO8859-2',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001327 'sr': 'sr_CS.ISO8859-5',
1328 'sr@cyrillic': 'sr_CS.ISO8859-5',
1329 'sr@latn': 'sr_CS.ISO8859-2',
1330 'sr_cs.iso88592': 'sr_CS.ISO8859-2',
1331 'sr_cs.iso88592@latn': 'sr_CS.ISO8859-2',
1332 'sr_cs.iso88595': 'sr_CS.ISO8859-5',
1333 'sr_cs.utf8@latn': 'sr_CS.UTF-8',
1334 'sr_cs@latn': 'sr_CS.ISO8859-2',
1335 'sr_sp': 'sr_CS.ISO8859-2',
1336 'sr_yu': 'sr_CS.ISO8859-5',
1337 'sr_yu.cp1251@cyrillic': 'sr_CS.CP1251',
1338 'sr_yu.iso88592': 'sr_CS.ISO8859-2',
1339 'sr_yu.iso88595': 'sr_CS.ISO8859-5',
1340 'sr_yu.iso88595@cyrillic': 'sr_CS.ISO8859-5',
1341 'sr_yu.microsoftcp1251@cyrillic': 'sr_CS.CP1251',
1342 'sr_yu.utf8@cyrillic': 'sr_CS.UTF-8',
1343 'sr_yu@cyrillic': 'sr_CS.ISO8859-5',
1344 'ss': 'ss_ZA.ISO8859-1',
1345 'ss_za': 'ss_ZA.ISO8859-1',
1346 'ss_za.iso88591': 'ss_ZA.ISO8859-1',
1347 'st': 'st_ZA.ISO8859-1',
1348 'st_za': 'st_ZA.ISO8859-1',
1349 'st_za.iso88591': 'st_ZA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001350 'sv': 'sv_SE.ISO8859-1',
1351 'sv_fi': 'sv_FI.ISO8859-1',
1352 'sv_fi.iso88591': 'sv_FI.ISO8859-1',
1353 'sv_fi.iso885915': 'sv_FI.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001354 'sv_fi.iso885915@euro': 'sv_FI.ISO8859-15',
1355 'sv_fi.utf8@euro': 'sv_FI.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001356 'sv_fi@euro': 'sv_FI.ISO8859-15',
1357 'sv_se': 'sv_SE.ISO8859-1',
1358 'sv_se.88591': 'sv_SE.ISO8859-1',
1359 'sv_se.iso88591': 'sv_SE.ISO8859-1',
1360 'sv_se.iso885915': 'sv_SE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001361 'sv_se@euro': 'sv_SE.ISO8859-15',
1362 'swedish': 'sv_SE.ISO8859-1',
1363 'swedish.iso88591': 'sv_SE.ISO8859-1',
1364 'ta': 'ta_IN.TSCII-0',
1365 'ta_in': 'ta_IN.TSCII-0',
1366 'ta_in.tscii': 'ta_IN.TSCII-0',
1367 'ta_in.tscii0': 'ta_IN.TSCII-0',
1368 'tg': 'tg_TJ.KOI8-C',
1369 'tg_tj': 'tg_TJ.KOI8-C',
1370 'tg_tj.koi8c': 'tg_TJ.KOI8-C',
1371 'th': 'th_TH.ISO8859-11',
1372 'th_th': 'th_TH.ISO8859-11',
1373 'th_th.iso885911': 'th_TH.ISO8859-11',
1374 'th_th.tactis': 'th_TH.TIS620',
1375 'th_th.tis620': 'th_TH.TIS620',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001376 'thai': 'th_TH.ISO8859-11',
1377 'tl': 'tl_PH.ISO8859-1',
1378 'tl_ph': 'tl_PH.ISO8859-1',
1379 'tl_ph.iso88591': 'tl_PH.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001380 'tn': 'tn_ZA.ISO8859-15',
1381 'tn_za': 'tn_ZA.ISO8859-15',
1382 'tn_za.iso885915': 'tn_ZA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001383 'tr': 'tr_TR.ISO8859-9',
1384 'tr_tr': 'tr_TR.ISO8859-9',
1385 'tr_tr.iso88599': 'tr_TR.ISO8859-9',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001386 'ts': 'ts_ZA.ISO8859-1',
1387 'ts_za': 'ts_ZA.ISO8859-1',
1388 'ts_za.iso88591': 'ts_ZA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001389 'tt': 'tt_RU.TATAR-CYR',
1390 'tt_ru': 'tt_RU.TATAR-CYR',
1391 'tt_ru.koi8c': 'tt_RU.KOI8-C',
1392 'tt_ru.tatarcyr': 'tt_RU.TATAR-CYR',
1393 'turkish': 'tr_TR.ISO8859-9',
1394 'turkish.iso88599': 'tr_TR.ISO8859-9',
1395 'uk': 'uk_UA.KOI8-U',
1396 'uk_ua': 'uk_UA.KOI8-U',
1397 'uk_ua.cp1251': 'uk_UA.CP1251',
1398 'uk_ua.iso88595': 'uk_UA.ISO8859-5',
1399 'uk_ua.koi8u': 'uk_UA.KOI8-U',
1400 'uk_ua.microsoftcp1251': 'uk_UA.CP1251',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001401 'univ': 'en_US.utf',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001402 'universal': 'en_US.utf',
1403 'universal.utf8@ucs4': 'en_US.UTF-8',
1404 'ur': 'ur_PK.CP1256',
1405 'ur_pk': 'ur_PK.CP1256',
1406 'ur_pk.cp1256': 'ur_PK.CP1256',
1407 'ur_pk.microsoftcp1256': 'ur_PK.CP1256',
1408 'uz': 'uz_UZ.UTF-8',
1409 'uz_uz': 'uz_UZ.UTF-8',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001410 'uz_uz.iso88591': 'uz_UZ.ISO8859-1',
1411 'uz_uz.utf8@cyrillic': 'uz_UZ.UTF-8',
1412 'uz_uz@cyrillic': 'uz_UZ.UTF-8',
1413 've': 've_ZA.UTF-8',
1414 've_za': 've_ZA.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001415 'vi': 'vi_VN.TCVN',
1416 'vi_vn': 'vi_VN.TCVN',
1417 'vi_vn.tcvn': 'vi_VN.TCVN',
1418 'vi_vn.tcvn5712': 'vi_VN.TCVN',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001419 'vi_vn.viscii': 'vi_VN.VISCII',
1420 'vi_vn.viscii111': 'vi_VN.VISCII',
1421 'wa': 'wa_BE.ISO8859-1',
1422 'wa_be': 'wa_BE.ISO8859-1',
1423 'wa_be.iso88591': 'wa_BE.ISO8859-1',
1424 'wa_be.iso885915': 'wa_BE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001425 'wa_be.iso885915@euro': 'wa_BE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001426 'wa_be@euro': 'wa_BE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001427 'xh': 'xh_ZA.ISO8859-1',
1428 'xh_za': 'xh_ZA.ISO8859-1',
1429 'xh_za.iso88591': 'xh_ZA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001430 'yi': 'yi_US.CP1255',
1431 'yi_us': 'yi_US.CP1255',
1432 'yi_us.cp1255': 'yi_US.CP1255',
1433 'yi_us.microsoftcp1255': 'yi_US.CP1255',
1434 'zh': 'zh_CN.eucCN',
1435 'zh_cn': 'zh_CN.gb2312',
1436 'zh_cn.big5': 'zh_TW.big5',
1437 'zh_cn.euc': 'zh_CN.eucCN',
1438 'zh_cn.gb18030': 'zh_CN.gb18030',
1439 'zh_cn.gb2312': 'zh_CN.gb2312',
1440 'zh_cn.gbk': 'zh_CN.gbk',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001441 'zh_hk': 'zh_HK.big5hkscs',
1442 'zh_hk.big5': 'zh_HK.big5',
1443 'zh_hk.big5hkscs': 'zh_HK.big5hkscs',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001444 'zh_tw': 'zh_TW.big5',
1445 'zh_tw.big5': 'zh_TW.big5',
1446 'zh_tw.euc': 'zh_TW.eucTW',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001447 'zh_tw.euctw': 'zh_TW.eucTW',
1448 'zu': 'zu_ZA.ISO8859-1',
1449 'zu_za': 'zu_ZA.ISO8859-1',
1450 'zu_za.iso88591': 'zu_ZA.ISO8859-1',
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001451}
1452
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001453#
Georg Brandlb709c2c2006-01-20 09:07:35 +00001454# This maps Windows language identifiers to locale strings.
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001455#
Tim Peters777f1082006-01-20 20:03:24 +00001456# This list has been updated from
Georg Brandlb709c2c2006-01-20 09:07:35 +00001457# http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nls_238z.asp
1458# to include every locale up to Windows XP.
Fredrik Lundh37a09822002-10-19 20:19:10 +00001459#
Georg Brandl5035c1c2006-01-20 13:38:26 +00001460# NOTE: this mapping is incomplete. If your language is missing, please
1461# submit a bug report to Python bug manager, which you can find via:
1462# http://www.python.org/dev/
1463# Make sure you include the missing language identifier and the suggested
1464# locale code.
1465#
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001466
1467windows_locale = {
Georg Brandlb709c2c2006-01-20 09:07:35 +00001468 0x0436: "af_ZA", # Afrikaans
1469 0x041c: "sq_AL", # Albanian
1470 0x0401: "ar_SA", # Arabic - Saudi Arabia
1471 0x0801: "ar_IQ", # Arabic - Iraq
1472 0x0c01: "ar_EG", # Arabic - Egypt
1473 0x1001: "ar_LY", # Arabic - Libya
1474 0x1401: "ar_DZ", # Arabic - Algeria
1475 0x1801: "ar_MA", # Arabic - Morocco
1476 0x1c01: "ar_TN", # Arabic - Tunisia
1477 0x2001: "ar_OM", # Arabic - Oman
1478 0x2401: "ar_YE", # Arabic - Yemen
1479 0x2801: "ar_SY", # Arabic - Syria
1480 0x2c01: "ar_JO", # Arabic - Jordan
1481 0x3001: "ar_LB", # Arabic - Lebanon
1482 0x3401: "ar_KW", # Arabic - Kuwait
1483 0x3801: "ar_AE", # Arabic - United Arab Emirates
1484 0x3c01: "ar_BH", # Arabic - Bahrain
1485 0x4001: "ar_QA", # Arabic - Qatar
1486 0x042b: "hy_AM", # Armenian
1487 0x042c: "az_AZ", # Azeri Latin
1488 0x082c: "az_AZ", # Azeri - Cyrillic
1489 0x042d: "eu_ES", # Basque
1490 0x0423: "be_BY", # Belarusian
1491 0x0445: "bn_IN", # Begali
1492 0x201a: "bs_BA", # Bosnian
1493 0x141a: "bs_BA", # Bosnian - Cyrillic
1494 0x047e: "br_FR", # Breton - France
1495 0x0402: "bg_BG", # Bulgarian
1496 0x0403: "ca_ES", # Catalan
1497 0x0004: "zh_CHS",# Chinese - Simplified
1498 0x0404: "zh_TW", # Chinese - Taiwan
1499 0x0804: "zh_CN", # Chinese - PRC
1500 0x0c04: "zh_HK", # Chinese - Hong Kong S.A.R.
1501 0x1004: "zh_SG", # Chinese - Singapore
1502 0x1404: "zh_MO", # Chinese - Macao S.A.R.
1503 0x7c04: "zh_CHT",# Chinese - Traditional
1504 0x041a: "hr_HR", # Croatian
1505 0x101a: "hr_BA", # Croatian - Bosnia
1506 0x0405: "cs_CZ", # Czech
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001507 0x0406: "da_DK", # Danish
Georg Brandlb709c2c2006-01-20 09:07:35 +00001508 0x048c: "gbz_AF",# Dari - Afghanistan
1509 0x0465: "div_MV",# Divehi - Maldives
1510 0x0413: "nl_NL", # Dutch - The Netherlands
1511 0x0813: "nl_BE", # Dutch - Belgium
1512 0x0409: "en_US", # English - United States
1513 0x0809: "en_GB", # English - United Kingdom
1514 0x0c09: "en_AU", # English - Australia
1515 0x1009: "en_CA", # English - Canada
1516 0x1409: "en_NZ", # English - New Zealand
1517 0x1809: "en_IE", # English - Ireland
1518 0x1c09: "en_ZA", # English - South Africa
1519 0x2009: "en_JA", # English - Jamaica
1520 0x2409: "en_CB", # English - Carribbean
1521 0x2809: "en_BZ", # English - Belize
1522 0x2c09: "en_TT", # English - Trinidad
1523 0x3009: "en_ZW", # English - Zimbabwe
1524 0x3409: "en_PH", # English - Phillippines
1525 0x0425: "et_EE", # Estonian
1526 0x0438: "fo_FO", # Faroese
1527 0x0464: "fil_PH",# Filipino
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001528 0x040b: "fi_FI", # Finnish
Georg Brandlb709c2c2006-01-20 09:07:35 +00001529 0x040c: "fr_FR", # French - France
1530 0x080c: "fr_BE", # French - Belgium
1531 0x0c0c: "fr_CA", # French - Canada
1532 0x100c: "fr_CH", # French - Switzerland
1533 0x140c: "fr_LU", # French - Luxembourg
1534 0x180c: "fr_MC", # French - Monaco
1535 0x0462: "fy_NL", # Frisian - Netherlands
1536 0x0456: "gl_ES", # Galician
1537 0x0437: "ka_GE", # Georgian
1538 0x0407: "de_DE", # German - Germany
1539 0x0807: "de_CH", # German - Switzerland
1540 0x0c07: "de_AT", # German - Austria
1541 0x1007: "de_LU", # German - Luxembourg
1542 0x1407: "de_LI", # German - Liechtenstein
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001543 0x0408: "el_GR", # Greek
Georg Brandlb709c2c2006-01-20 09:07:35 +00001544 0x0447: "gu_IN", # Gujarati
1545 0x040d: "he_IL", # Hebrew
1546 0x0439: "hi_IN", # Hindi
1547 0x040e: "hu_HU", # Hungarian
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001548 0x040f: "is_IS", # Icelandic
Georg Brandlb709c2c2006-01-20 09:07:35 +00001549 0x0421: "id_ID", # Indonesian
1550 0x045d: "iu_CA", # Inuktitut
1551 0x085d: "iu_CA", # Inuktitut - Latin
1552 0x083c: "ga_IE", # Irish - Ireland
1553 0x0434: "xh_ZA", # Xhosa - South Africa
1554 0x0435: "zu_ZA", # Zulu
1555 0x0410: "it_IT", # Italian - Italy
1556 0x0810: "it_CH", # Italian - Switzerland
1557 0x0411: "ja_JP", # Japanese
1558 0x044b: "kn_IN", # Kannada - India
1559 0x043f: "kk_KZ", # Kazakh
1560 0x0457: "kok_IN",# Konkani
1561 0x0412: "ko_KR", # Korean
1562 0x0440: "ky_KG", # Kyrgyz
1563 0x0426: "lv_LV", # Latvian
1564 0x0427: "lt_LT", # Lithuanian
1565 0x046e: "lb_LU", # Luxembourgish
1566 0x042f: "mk_MK", # FYRO Macedonian
1567 0x043e: "ms_MY", # Malay - Malaysia
1568 0x083e: "ms_BN", # Malay - Brunei
1569 0x044c: "ml_IN", # Malayalam - India
1570 0x043a: "mt_MT", # Maltese
1571 0x0481: "mi_NZ", # Maori
1572 0x047a: "arn_CL",# Mapudungun
1573 0x044e: "mr_IN", # Marathi
1574 0x047c: "moh_CA",# Mohawk - Canada
1575 0x0450: "mn_MN", # Mongolian
1576 0x0461: "ne_NP", # Nepali
1577 0x0414: "nb_NO", # Norwegian - Bokmal
1578 0x0814: "nn_NO", # Norwegian - Nynorsk
1579 0x0482: "oc_FR", # Occitan - France
1580 0x0448: "or_IN", # Oriya - India
1581 0x0463: "ps_AF", # Pashto - Afghanistan
1582 0x0429: "fa_IR", # Persian
1583 0x0415: "pl_PL", # Polish
1584 0x0416: "pt_BR", # Portuguese - Brazil
1585 0x0816: "pt_PT", # Portuguese - Portugal
1586 0x0446: "pa_IN", # Punjabi
1587 0x046b: "quz_BO",# Quechua (Bolivia)
1588 0x086b: "quz_EC",# Quechua (Ecuador)
1589 0x0c6b: "quz_PE",# Quechua (Peru)
1590 0x0418: "ro_RO", # Romanian - Romania
1591 0x0417: "rm_CH", # Raeto-Romanese
1592 0x0419: "ru_RU", # Russian
1593 0x243b: "smn_FI",# Sami Finland
1594 0x103b: "smj_NO",# Sami Norway
1595 0x143b: "smj_SE",# Sami Sweden
1596 0x043b: "se_NO", # Sami Northern Norway
1597 0x083b: "se_SE", # Sami Northern Sweden
1598 0x0c3b: "se_FI", # Sami Northern Finland
1599 0x203b: "sms_FI",# Sami Skolt
1600 0x183b: "sma_NO",# Sami Southern Norway
1601 0x1c3b: "sma_SE",# Sami Southern Sweden
1602 0x044f: "sa_IN", # Sanskrit
1603 0x0c1a: "sr_SP", # Serbian - Cyrillic
1604 0x1c1a: "sr_BA", # Serbian - Bosnia Cyrillic
1605 0x081a: "sr_SP", # Serbian - Latin
1606 0x181a: "sr_BA", # Serbian - Bosnia Latin
1607 0x046c: "ns_ZA", # Northern Sotho
1608 0x0432: "tn_ZA", # Setswana - Southern Africa
1609 0x041b: "sk_SK", # Slovak
1610 0x0424: "sl_SI", # Slovenian
1611 0x040a: "es_ES", # Spanish - Spain
1612 0x080a: "es_MX", # Spanish - Mexico
1613 0x0c0a: "es_ES", # Spanish - Spain (Modern)
1614 0x100a: "es_GT", # Spanish - Guatemala
1615 0x140a: "es_CR", # Spanish - Costa Rica
1616 0x180a: "es_PA", # Spanish - Panama
1617 0x1c0a: "es_DO", # Spanish - Dominican Republic
1618 0x200a: "es_VE", # Spanish - Venezuela
1619 0x240a: "es_CO", # Spanish - Colombia
1620 0x280a: "es_PE", # Spanish - Peru
1621 0x2c0a: "es_AR", # Spanish - Argentina
1622 0x300a: "es_EC", # Spanish - Ecuador
1623 0x340a: "es_CL", # Spanish - Chile
1624 0x380a: "es_UR", # Spanish - Uruguay
1625 0x3c0a: "es_PY", # Spanish - Paraguay
1626 0x400a: "es_BO", # Spanish - Bolivia
1627 0x440a: "es_SV", # Spanish - El Salvador
1628 0x480a: "es_HN", # Spanish - Honduras
1629 0x4c0a: "es_NI", # Spanish - Nicaragua
1630 0x500a: "es_PR", # Spanish - Puerto Rico
1631 0x0441: "sw_KE", # Swahili
1632 0x041d: "sv_SE", # Swedish - Sweden
1633 0x081d: "sv_FI", # Swedish - Finland
1634 0x045a: "syr_SY",# Syriac
1635 0x0449: "ta_IN", # Tamil
1636 0x0444: "tt_RU", # Tatar
1637 0x044a: "te_IN", # Telugu
1638 0x041e: "th_TH", # Thai
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001639 0x041f: "tr_TR", # Turkish
Georg Brandlb709c2c2006-01-20 09:07:35 +00001640 0x0422: "uk_UA", # Ukrainian
1641 0x0420: "ur_PK", # Urdu
1642 0x0820: "ur_IN", # Urdu - India
1643 0x0443: "uz_UZ", # Uzbek - Latin
1644 0x0843: "uz_UZ", # Uzbek - Cyrillic
1645 0x042a: "vi_VN", # Vietnamese
1646 0x0452: "cy_GB", # Welsh
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001647}
1648
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001649def _print_locale():
1650
1651 """ Test function.
1652 """
1653 categories = {}
1654 def _init_categories(categories=categories):
1655 for k,v in globals().items():
1656 if k[:3] == 'LC_':
1657 categories[k] = v
1658 _init_categories()
1659 del categories['LC_ALL']
1660
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001661 print 'Locale defaults as determined by getdefaultlocale():'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001662 print '-'*72
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001663 lang, enc = getdefaultlocale()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001664 print 'Language: ', lang or '(undefined)'
1665 print 'Encoding: ', enc or '(undefined)'
1666 print
1667
1668 print 'Locale settings on startup:'
1669 print '-'*72
1670 for name,category in categories.items():
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001671 print name, '...'
1672 lang, enc = getlocale(category)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001673 print ' Language: ', lang or '(undefined)'
1674 print ' Encoding: ', enc or '(undefined)'
1675 print
1676
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001677 print
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001678 print 'Locale settings after calling resetlocale():'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001679 print '-'*72
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001680 resetlocale()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001681 for name,category in categories.items():
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001682 print name, '...'
1683 lang, enc = getlocale(category)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001684 print ' Language: ', lang or '(undefined)'
1685 print ' Encoding: ', enc or '(undefined)'
1686 print
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001687
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001688 try:
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001689 setlocale(LC_ALL, "")
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001690 except:
1691 print 'NOTE:'
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001692 print 'setlocale(LC_ALL, "") does not support the default locale'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001693 print 'given in the OS environment variables.'
1694 else:
1695 print
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001696 print 'Locale settings after calling setlocale(LC_ALL, ""):'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001697 print '-'*72
1698 for name,category in categories.items():
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001699 print name, '...'
1700 lang, enc = getlocale(category)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001701 print ' Language: ', lang or '(undefined)'
1702 print ' Encoding: ', enc or '(undefined)'
1703 print
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001704
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001705###
Guido van Rossumeef1d4e1997-11-19 19:01:43 +00001706
Tim Peters1baf8292001-01-24 10:13:46 +00001707try:
1708 LC_MESSAGES
Skip Montanaro0897f0c2002-03-25 21:40:36 +00001709except NameError:
Tim Peters1baf8292001-01-24 10:13:46 +00001710 pass
1711else:
1712 __all__.append("LC_MESSAGES")
1713
Guido van Rossumeef1d4e1997-11-19 19:01:43 +00001714if __name__=='__main__':
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001715 print 'Locale aliasing:'
1716 print
1717 _print_locale()
1718 print
1719 print 'Number formatting:'
1720 print
1721 _test()