blob: 751353dac27019f502b537f3ddaede7239092cb0 [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.
Georg Brandl09728b72007-05-01 06:08:15 +000022__all__ = ["getlocale", "getdefaultlocale", "getpreferredencoding", "Error",
23 "setlocale", "resetlocale", "localeconv", "strcoll", "strxfrm",
24 "str", "atof", "atoi", "format", "format_string", "currency",
25 "normalize", "LC_CTYPE", "LC_COLLATE", "LC_TIME", "LC_MONETARY",
26 "LC_NUMERIC", "LC_ALL", "CHAR_MAX"]
Skip Montanaro17ab1232001-01-24 06:27:27 +000027
Marc-André Lemburg23481142000-06-08 17:49:41 +000028try:
Fredrik Lundh6c86b992000-07-09 17:12:58 +000029
Marc-André Lemburg23481142000-06-08 17:49:41 +000030 from _locale import *
31
32except ImportError:
33
Fredrik Lundh6c86b992000-07-09 17:12:58 +000034 # Locale emulation
35
Marc-André Lemburg23481142000-06-08 17:49:41 +000036 CHAR_MAX = 127
37 LC_ALL = 6
38 LC_COLLATE = 3
39 LC_CTYPE = 0
40 LC_MESSAGES = 5
41 LC_MONETARY = 4
42 LC_NUMERIC = 1
43 LC_TIME = 2
44 Error = ValueError
45
46 def localeconv():
Fredrik Lundh6c86b992000-07-09 17:12:58 +000047 """ localeconv() -> dict.
Marc-André Lemburg23481142000-06-08 17:49:41 +000048 Returns numeric and monetary locale-specific parameters.
49 """
50 # 'C' locale default values
51 return {'grouping': [127],
52 'currency_symbol': '',
53 'n_sign_posn': 127,
Fredrik Lundh6c86b992000-07-09 17:12:58 +000054 'p_cs_precedes': 127,
55 'n_cs_precedes': 127,
56 'mon_grouping': [],
Marc-André Lemburg23481142000-06-08 17:49:41 +000057 'n_sep_by_space': 127,
58 'decimal_point': '.',
59 'negative_sign': '',
60 'positive_sign': '',
Fredrik Lundh6c86b992000-07-09 17:12:58 +000061 'p_sep_by_space': 127,
Marc-André Lemburg23481142000-06-08 17:49:41 +000062 'int_curr_symbol': '',
Fredrik Lundh6c86b992000-07-09 17:12:58 +000063 'p_sign_posn': 127,
Marc-André Lemburg23481142000-06-08 17:49:41 +000064 'thousands_sep': '',
Fredrik Lundh6c86b992000-07-09 17:12:58 +000065 'mon_thousands_sep': '',
66 'frac_digits': 127,
Marc-André Lemburg23481142000-06-08 17:49:41 +000067 'mon_decimal_point': '',
68 'int_frac_digits': 127}
Fredrik Lundh6c86b992000-07-09 17:12:58 +000069
Marc-André Lemburg23481142000-06-08 17:49:41 +000070 def setlocale(category, value=None):
Fredrik Lundh6c86b992000-07-09 17:12:58 +000071 """ setlocale(integer,string=None) -> string.
Marc-André Lemburg23481142000-06-08 17:49:41 +000072 Activates/queries locale processing.
73 """
Martin v. Löwis103d6e72003-03-30 15:42:13 +000074 if value not in (None, '', 'C'):
Fredrik Lundh6c86b992000-07-09 17:12:58 +000075 raise Error, '_locale emulation only supports "C" locale'
Marc-André Lemburg23481142000-06-08 17:49:41 +000076 return 'C'
77
78 def strcoll(a,b):
Fredrik Lundh6c86b992000-07-09 17:12:58 +000079 """ strcoll(string,string) -> int.
Marc-André Lemburg23481142000-06-08 17:49:41 +000080 Compares two strings according to the locale.
81 """
82 return cmp(a,b)
83
84 def strxfrm(s):
Fredrik Lundh6c86b992000-07-09 17:12:58 +000085 """ strxfrm(string) -> string.
Marc-André Lemburg23481142000-06-08 17:49:41 +000086 Returns a string that behaves for cmp locale-aware.
87 """
88 return s
Marc-André Lemburg5431bc32000-06-07 09:11:40 +000089
90### Number formatting APIs
91
92# Author: Martin von Loewis
Georg Brandlb89316f2006-05-17 15:51:16 +000093# improved by Georg Brandl
Guido van Rossumeef1d4e1997-11-19 19:01:43 +000094
95#perform the grouping from right to left
Georg Brandlb89316f2006-05-17 15:51:16 +000096def _group(s, monetary=False):
97 conv = localeconv()
98 thousands_sep = conv[monetary and 'mon_thousands_sep' or 'thousands_sep']
99 grouping = conv[monetary and 'mon_grouping' or 'grouping']
100 if not grouping:
101 return (s, 0)
102 result = ""
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000103 seps = 0
104 spaces = ""
105 if s[-1] == ' ':
106 sp = s.find(' ')
107 spaces = s[sp:]
108 s = s[:sp]
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000109 while s and grouping:
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000110 # if grouping is -1, we are done
Georg Brandlb89316f2006-05-17 15:51:16 +0000111 if grouping[0] == CHAR_MAX:
Guido van Rossum45e2fbc1998-03-26 21:13:24 +0000112 break
113 # 0: re-use last group ad infinitum
Georg Brandlb89316f2006-05-17 15:51:16 +0000114 elif grouping[0] != 0:
Guido van Rossum45e2fbc1998-03-26 21:13:24 +0000115 #process last group
Georg Brandlb89316f2006-05-17 15:51:16 +0000116 group = grouping[0]
117 grouping = grouping[1:]
Guido van Rossum45e2fbc1998-03-26 21:13:24 +0000118 if result:
Georg Brandlb89316f2006-05-17 15:51:16 +0000119 result = s[-group:] + thousands_sep + result
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000120 seps += 1
Guido van Rossum45e2fbc1998-03-26 21:13:24 +0000121 else:
Georg Brandlb89316f2006-05-17 15:51:16 +0000122 result = s[-group:]
123 s = s[:-group]
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000124 if s and s[-1] not in "0123456789":
125 # the leading string is only spaces and signs
Georg Brandlb89316f2006-05-17 15:51:16 +0000126 return s + result + spaces, seps
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000127 if not result:
Georg Brandlb89316f2006-05-17 15:51:16 +0000128 return s + spaces, seps
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000129 if s:
Georg Brandlb89316f2006-05-17 15:51:16 +0000130 result = s + thousands_sep + result
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000131 seps += 1
Georg Brandlb89316f2006-05-17 15:51:16 +0000132 return result + spaces, seps
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000133
Georg Brandlb89316f2006-05-17 15:51:16 +0000134def format(percent, value, grouping=False, monetary=False, *additional):
135 """Returns the locale-aware substitution of a %? specifier
136 (percent).
Tim Petersfd4c4192006-05-18 02:06:40 +0000137
Georg Brandlb89316f2006-05-17 15:51:16 +0000138 additional is for format strings which contain one or more
139 '*' modifiers."""
140 # this is only for one-percent-specifier strings and this should be checked
141 if percent[0] != '%':
142 raise ValueError("format() must be given exactly one %char "
143 "format specifier")
144 if additional:
145 formatted = percent % ((value,) + additional)
146 else:
147 formatted = percent % value
148 # floats and decimal ints need special action!
149 if percent[-1] in 'eEfFgG':
150 seps = 0
151 parts = formatted.split('.')
152 if grouping:
153 parts[0], seps = _group(parts[0], monetary=monetary)
154 decimal_point = localeconv()[monetary and 'mon_decimal_point'
155 or 'decimal_point']
156 formatted = decimal_point.join(parts)
157 while seps:
158 sp = formatted.find(' ')
159 if sp == -1: break
160 formatted = formatted[:sp] + formatted[sp+1:]
161 seps -= 1
162 elif percent[-1] in 'diu':
163 if grouping:
164 formatted = _group(formatted, monetary=monetary)[0]
165 return formatted
166
167import re, operator
168_percent_re = re.compile(r'%(?:\((?P<key>.*?)\))?'
169 r'(?P<modifiers>[-#0-9 +*.hlL]*?)[eEfFgGdiouxXcrs%]')
170
171def format_string(f, val, grouping=False):
172 """Formats a string in the same way that the % formatting would use,
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000173 but takes the current locale into account.
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000174 Grouping is applied if the third parameter is true."""
Georg Brandlb89316f2006-05-17 15:51:16 +0000175 percents = list(_percent_re.finditer(f))
176 new_f = _percent_re.sub('%s', f)
177
178 if isinstance(val, tuple):
179 new_val = list(val)
180 i = 0
181 for perc in percents:
182 starcount = perc.group('modifiers').count('*')
183 new_val[i] = format(perc.group(), new_val[i], grouping, False, *new_val[i+1:i+1+starcount])
184 del new_val[i+1:i+1+starcount]
185 i += (1 + starcount)
186 val = tuple(new_val)
187 elif operator.isMappingType(val):
188 for perc in percents:
189 key = perc.group("key")
190 val[key] = format(perc.group(), val[key], grouping)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000191 else:
Georg Brandlb89316f2006-05-17 15:51:16 +0000192 # val is a single value
193 val = format(percents[0].group(), val, grouping)
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000194
Georg Brandlb89316f2006-05-17 15:51:16 +0000195 return new_f % val
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000196
Georg Brandlb89316f2006-05-17 15:51:16 +0000197def currency(val, symbol=True, grouping=False, international=False):
198 """Formats val according to the currency settings
199 in the current locale."""
200 conv = localeconv()
201
202 # check for illegal values
203 digits = conv[international and 'int_frac_digits' or 'frac_digits']
204 if digits == 127:
205 raise ValueError("Currency formatting is not possible using "
206 "the 'C' locale.")
207
208 s = format('%%.%if' % digits, abs(val), grouping, monetary=True)
209 # '<' and '>' are markers if the sign must be inserted between symbol and value
210 s = '<' + s + '>'
211
212 if symbol:
213 smb = conv[international and 'int_curr_symbol' or 'currency_symbol']
214 precedes = conv[val<0 and 'n_cs_precedes' or 'p_cs_precedes']
215 separated = conv[val<0 and 'n_sep_by_space' or 'p_sep_by_space']
216
217 if precedes:
218 s = smb + (separated and ' ' or '') + s
219 else:
220 s = s + (separated and ' ' or '') + smb
221
222 sign_pos = conv[val<0 and 'n_sign_posn' or 'p_sign_posn']
223 sign = conv[val<0 and 'negative_sign' or 'positive_sign']
224
225 if sign_pos == 0:
226 s = '(' + s + ')'
227 elif sign_pos == 1:
228 s = sign + s
229 elif sign_pos == 2:
230 s = s + sign
231 elif sign_pos == 3:
232 s = s.replace('<', sign)
233 elif sign_pos == 4:
234 s = s.replace('>', sign)
235 else:
236 # the default if nothing specified;
237 # this should be the most fitting sign position
238 s = sign + s
239
240 return s.replace('<', '').replace('>', '')
Martin v. Löwisdb786872001-01-21 18:52:33 +0000241
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000242def str(val):
243 """Convert float to integer, taking the locale into account."""
Georg Brandlb89316f2006-05-17 15:51:16 +0000244 return format("%.12g", val)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000245
Georg Brandlb89316f2006-05-17 15:51:16 +0000246def atof(string, func=float):
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000247 "Parses a string as a float according to the locale settings."
248 #First, get rid of the grouping
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000249 ts = localeconv()['thousands_sep']
250 if ts:
Skip Montanaro249369c2004-04-10 16:39:32 +0000251 string = string.replace(ts, '')
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000252 #next, replace the decimal point with a dot
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000253 dd = localeconv()['decimal_point']
254 if dd:
Skip Montanaro249369c2004-04-10 16:39:32 +0000255 string = string.replace(dd, '.')
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000256 #finally, parse the string
Skip Montanaro249369c2004-04-10 16:39:32 +0000257 return func(string)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000258
259def atoi(str):
260 "Converts a string to an integer according to the locale settings."
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000261 return atof(str, int)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000262
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000263def _test():
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000264 setlocale(LC_ALL, "")
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000265 #do grouping
Georg Brandlb89316f2006-05-17 15:51:16 +0000266 s1 = format("%d", 123456789,1)
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000267 print s1, "is", atoi(s1)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000268 #standard formatting
Georg Brandlb89316f2006-05-17 15:51:16 +0000269 s1 = str(3.14)
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000270 print s1, "is", atof(s1)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000271
272### Locale name aliasing engine
273
274# Author: Marc-Andre Lemburg, mal@lemburg.com
Fredrik Lundh37a09822002-10-19 20:19:10 +0000275# Various tweaks by Fredrik Lundh <fredrik@pythonware.com>
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000276
277# store away the low-level version of setlocale (it's
278# overridden below)
279_setlocale = setlocale
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000280
281def normalize(localename):
282
283 """ Returns a normalized locale code for the given locale
284 name.
285
286 The returned locale code is formatted for use with
287 setlocale().
288
289 If normalization fails, the original name is returned
290 unchanged.
291
292 If the given encoding is not known, the function defaults to
293 the default encoding for the locale code just like setlocale()
294 does.
295
296 """
297 # Normalize the locale name and extract the encoding
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000298 fullname = localename.lower()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000299 if ':' in fullname:
300 # ':' is sometimes used as encoding delimiter.
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000301 fullname = fullname.replace(':', '.')
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000302 if '.' in fullname:
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000303 langname, encoding = fullname.split('.')[:2]
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000304 fullname = langname + '.' + encoding
305 else:
306 langname = fullname
307 encoding = ''
308
309 # First lookup: fullname (possibly with encoding)
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000310 norm_encoding = encoding.replace('-', '')
311 norm_encoding = norm_encoding.replace('_', '')
312 lookup_name = langname + '.' + encoding
313 code = locale_alias.get(lookup_name, None)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000314 if code is not None:
315 return code
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000316 #print 'first lookup failed'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000317
318 # Second try: langname (without encoding)
319 code = locale_alias.get(langname, None)
320 if code is not None:
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000321 #print 'langname lookup succeeded'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000322 if '.' in code:
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000323 langname, defenc = code.split('.')
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000324 else:
325 langname = code
326 defenc = ''
327 if encoding:
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000328 # Convert the encoding to a C lib compatible encoding string
329 norm_encoding = encodings.normalize_encoding(encoding)
330 #print 'norm encoding: %r' % norm_encoding
331 norm_encoding = encodings.aliases.aliases.get(norm_encoding,
332 norm_encoding)
333 #print 'aliased encoding: %r' % norm_encoding
334 encoding = locale_encoding_alias.get(norm_encoding,
335 norm_encoding)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000336 else:
337 encoding = defenc
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000338 #print 'found encoding %r' % encoding
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000339 if encoding:
340 return langname + '.' + encoding
341 else:
342 return langname
343
344 else:
345 return localename
346
347def _parse_localename(localename):
348
349 """ Parses the locale code for localename and returns the
350 result as tuple (language code, encoding).
351
352 The localename is normalized and passed through the locale
353 alias engine. A ValueError is raised in case the locale name
354 cannot be parsed.
355
356 The language code corresponds to RFC 1766. code and encoding
357 can be None in case the values cannot be determined or are
Jeremy Hyltona05e2932000-06-28 14:48:01 +0000358 unknown to this implementation.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000359
360 """
361 code = normalize(localename)
Georg Brandlb709c2c2006-01-20 09:07:35 +0000362 if '@' in code:
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000363 # Deal with locale modifiers
364 code, modifier = code.split('@')
365 if modifier == 'euro' and '.' not in code:
366 # Assume Latin-9 for @euro locales. This is bogus,
367 # since some systems may use other encodings for these
368 # locales. Also, we ignore other modifiers.
369 return code, 'iso-8859-15'
Tim Peters230a60c2002-11-09 05:08:07 +0000370
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000371 if '.' in code:
Raymond Hettinger346e67f2005-01-01 06:10:26 +0000372 return tuple(code.split('.')[:2])
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000373 elif code == 'C':
374 return None, None
Andrew M. Kuchling1f877ef2001-08-13 14:50:44 +0000375 raise ValueError, 'unknown locale: %s' % localename
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000376
377def _build_localename(localetuple):
378
379 """ Builds a locale code from the given tuple (language code,
380 encoding).
381
382 No aliasing or normalizing takes place.
383
384 """
385 language, encoding = localetuple
386 if language is None:
387 language = 'C'
388 if encoding is None:
389 return language
390 else:
391 return language + '.' + encoding
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000392
Matthias Klosef3f231f2005-09-20 07:02:49 +0000393def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000394
395 """ Tries to determine the default locale settings and returns
396 them as tuple (language code, encoding).
397
398 According to POSIX, a program which has not called
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000399 setlocale(LC_ALL, "") runs using the portable 'C' locale.
400 Calling setlocale(LC_ALL, "") lets it use the default locale as
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000401 defined by the LANG variable. Since we don't want to interfere
Thomas Wouters7e474022000-07-16 12:04:32 +0000402 with the current locale setting we thus emulate the behavior
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000403 in the way described above.
404
405 To maintain compatibility with other platforms, not only the
406 LANG variable is tested, but a list of variables given as
407 envvars parameter. The first found to be defined will be
408 used. envvars defaults to the search path used in GNU gettext;
409 it must always contain the variable name 'LANG'.
410
411 Except for the code 'C', the language code corresponds to RFC
412 1766. code and encoding can be None in case the values cannot
413 be determined.
414
415 """
Fredrik Lundh04661322000-07-09 23:16:10 +0000416
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000417 try:
418 # check if it's supported by the _locale module
419 import _locale
420 code, encoding = _locale._getdefaultlocale()
Fredrik Lundh04661322000-07-09 23:16:10 +0000421 except (ImportError, AttributeError):
422 pass
423 else:
Fredrik Lundh663809e2000-07-10 19:32:19 +0000424 # make sure the code/encoding values are valid
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000425 if sys.platform == "win32" and code and code[:2] == "0x":
426 # map windows language identifier to language name
427 code = windows_locale.get(int(code, 0))
Fredrik Lundh663809e2000-07-10 19:32:19 +0000428 # ...add other platform-specific processing here, if
429 # necessary...
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000430 return code, encoding
Fredrik Lundh04661322000-07-09 23:16:10 +0000431
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000432 # fall back on POSIX behaviour
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000433 import os
434 lookup = os.environ.get
435 for variable in envvars:
436 localename = lookup(variable,None)
Martin v. Löwisc8ae31d2004-07-26 12:45:18 +0000437 if localename:
Matthias Klosef3f231f2005-09-20 07:02:49 +0000438 if variable == 'LANGUAGE':
439 localename = localename.split(':')[0]
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000440 break
441 else:
442 localename = 'C'
443 return _parse_localename(localename)
444
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000445
446def getlocale(category=LC_CTYPE):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000447
448 """ Returns the current setting for the given locale category as
449 tuple (language code, encoding).
450
451 category may be one of the LC_* value except LC_ALL. It
452 defaults to LC_CTYPE.
453
454 Except for the code 'C', the language code corresponds to RFC
455 1766. code and encoding can be None in case the values cannot
456 be determined.
457
458 """
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000459 localename = _setlocale(category)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000460 if category == LC_ALL and ';' in localename:
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000461 raise TypeError, 'category LC_ALL is not supported'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000462 return _parse_localename(localename)
463
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000464def setlocale(category, locale=None):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000465
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000466 """ Set the locale for the given category. The locale can be
467 a string, a locale tuple (language code, encoding), or None.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000468
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000469 Locale tuples are converted to strings the locale aliasing
470 engine. Locale strings are passed directly to the C lib.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000471
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000472 category may be given as one of the LC_* values.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000473
474 """
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000475 if locale and type(locale) is not type(""):
476 # convert to string
477 locale = normalize(_build_localename(locale))
478 return _setlocale(category, locale)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000479
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000480def resetlocale(category=LC_ALL):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000481
482 """ Sets the locale for category to the default setting.
483
484 The default setting is determined by calling
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000485 getdefaultlocale(). category defaults to LC_ALL.
486
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000487 """
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000488 _setlocale(category, _build_localename(getdefaultlocale()))
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000489
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000490if sys.platform in ('win32', 'darwin', 'mac'):
491 # On Win32, this will return the ANSI code page
492 # On the Mac, it should return the system encoding;
493 # it might return "ascii" instead
494 def getpreferredencoding(do_setlocale = True):
495 """Return the charset that the user is likely using."""
496 import _locale
Tim Petersa326f472002-11-05 03:49:09 +0000497 return _locale._getdefaultlocale()[1]
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000498else:
499 # On Unix, if CODESET is available, use that.
500 try:
501 CODESET
502 except NameError:
503 # Fall back to parsing environment variables :-(
504 def getpreferredencoding(do_setlocale = True):
505 """Return the charset that the user is likely using,
506 by looking at environment variables."""
507 return getdefaultlocale()[1]
508 else:
509 def getpreferredencoding(do_setlocale = True):
510 """Return the charset that the user is likely using,
511 according to the system configuration."""
512 if do_setlocale:
513 oldloc = setlocale(LC_CTYPE)
514 setlocale(LC_CTYPE, "")
515 result = nl_langinfo(CODESET)
516 setlocale(LC_CTYPE, oldloc)
517 return result
518 else:
519 return nl_langinfo(CODESET)
Tim Peters230a60c2002-11-09 05:08:07 +0000520
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000521
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000522### Database
523#
524# The following data was extracted from the locale.alias file which
525# comes with X11 and then hand edited removing the explicit encoding
526# definitions and adding some more aliases. The file is usually
527# available as /usr/lib/X11/locale/locale.alias.
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000528#
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000529
530#
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000531# The local_encoding_alias table maps lowercase encoding alias names
532# to C locale encoding names (case-sensitive). Note that normalize()
533# first looks up the encoding in the encodings.aliases dictionary and
534# then applies this mapping to find the correct C lib name for the
535# encoding.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000536#
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000537locale_encoding_alias = {
538
539 # Mappings for non-standard encoding names used in locale names
540 '437': 'C',
541 'c': 'C',
542 'en': 'ISO8859-1',
543 'jis': 'JIS7',
544 'jis7': 'JIS7',
545 'ajec': 'eucJP',
546
547 # Mappings from Python codec names to C lib encoding names
548 'ascii': 'ISO8859-1',
549 'latin_1': 'ISO8859-1',
550 'iso8859_1': 'ISO8859-1',
551 'iso8859_10': 'ISO8859-10',
552 'iso8859_11': 'ISO8859-11',
553 'iso8859_13': 'ISO8859-13',
554 'iso8859_14': 'ISO8859-14',
555 'iso8859_15': 'ISO8859-15',
556 'iso8859_2': 'ISO8859-2',
557 'iso8859_3': 'ISO8859-3',
558 'iso8859_4': 'ISO8859-4',
559 'iso8859_5': 'ISO8859-5',
560 'iso8859_6': 'ISO8859-6',
561 'iso8859_7': 'ISO8859-7',
562 'iso8859_8': 'ISO8859-8',
563 'iso8859_9': 'ISO8859-9',
564 'iso2022_jp': 'JIS7',
565 'shift_jis': 'SJIS',
566 'tactis': 'TACTIS',
567 'euc_jp': 'eucJP',
568 'euc_kr': 'eucKR',
Marc-André Lemburgb4cebd42004-12-13 19:56:01 +0000569 'utf_8': 'UTF8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000570 'koi8_r': 'KOI8-R',
571 'koi8_u': 'KOI8-U',
572 # XXX This list is still incomplete. If you know more
573 # mappings, please file a bug report. Thanks.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000574}
575
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000576#
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000577# The locale_alias table maps lowercase alias names to C locale names
578# (case-sensitive). Encodings are always separated from the locale
579# name using a dot ('.'); they should only be given in case the
580# language name is needed to interpret the given encoding alias
581# correctly (CJK codes often have this need).
582#
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000583# Note that the normalize() function which uses this tables
584# removes '_' and '-' characters from the encoding part of the
585# locale name before doing the lookup. This saves a lot of
586# space in the table.
587#
588# MAL 2004-12-10:
589# Updated alias mapping to most recent locale.alias file
590# from X.org distribution using makelocalealias.py.
591#
592# These are the differences compared to the old mapping (Python 2.4
593# and older):
594#
595# updated 'bg' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
596# updated 'bg_bg' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
597# updated 'bulgarian' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
598# updated 'cz' -> 'cz_CZ.ISO8859-2' to 'cs_CZ.ISO8859-2'
599# updated 'cz_cz' -> 'cz_CZ.ISO8859-2' to 'cs_CZ.ISO8859-2'
600# updated 'czech' -> 'cs_CS.ISO8859-2' to 'cs_CZ.ISO8859-2'
601# updated 'dutch' -> 'nl_BE.ISO8859-1' to 'nl_NL.ISO8859-1'
602# updated 'et' -> 'et_EE.ISO8859-4' to 'et_EE.ISO8859-15'
603# updated 'et_ee' -> 'et_EE.ISO8859-4' to 'et_EE.ISO8859-15'
604# updated 'fi' -> 'fi_FI.ISO8859-1' to 'fi_FI.ISO8859-15'
605# updated 'fi_fi' -> 'fi_FI.ISO8859-1' to 'fi_FI.ISO8859-15'
606# updated 'iw' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
607# updated 'iw_il' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
608# updated 'japanese' -> 'ja_JP.SJIS' to 'ja_JP.eucJP'
609# updated 'lt' -> 'lt_LT.ISO8859-4' to 'lt_LT.ISO8859-13'
610# updated 'lv' -> 'lv_LV.ISO8859-4' to 'lv_LV.ISO8859-13'
611# updated 'sl' -> 'sl_CS.ISO8859-2' to 'sl_SI.ISO8859-2'
612# updated 'slovene' -> 'sl_CS.ISO8859-2' to 'sl_SI.ISO8859-2'
613# updated 'th_th' -> 'th_TH.TACTIS' to 'th_TH.ISO8859-11'
614# updated 'zh_cn' -> 'zh_CN.eucCN' to 'zh_CN.gb2312'
615# updated 'zh_cn.big5' -> 'zh_TW.eucTW' to 'zh_TW.big5'
616# updated 'zh_tw' -> 'zh_TW.eucTW' to 'zh_TW.big5'
617#
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000618# MAL 2008-05-30:
619# Updated alias mapping to most recent locale.alias file
620# from X.org distribution using makelocalealias.py.
621#
622# These are the differences compared to the old mapping (Python 2.5
623# and older):
624#
625# updated 'cs_cs.iso88592' -> 'cs_CZ.ISO8859-2' to 'cs_CS.ISO8859-2'
626# updated 'serbocroatian' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
627# updated 'sh' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
628# updated 'sh_hr.iso88592' -> 'sh_HR.ISO8859-2' to 'hr_HR.ISO8859-2'
629# updated 'sh_sp' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
630# updated 'sh_yu' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
631# updated 'sp' -> 'sp_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
632# updated 'sp_yu' -> 'sp_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
633# updated 'sr' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
634# updated 'sr@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
635# updated 'sr_sp' -> 'sr_SP.ISO8859-2' to 'sr_CS.ISO8859-2'
636# updated 'sr_yu' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
637# updated 'sr_yu.cp1251@cyrillic' -> 'sr_YU.CP1251' to 'sr_CS.CP1251'
638# updated 'sr_yu.iso88592' -> 'sr_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
639# updated 'sr_yu.iso88595' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
640# updated 'sr_yu.iso88595@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
641# updated 'sr_yu.microsoftcp1251@cyrillic' -> 'sr_YU.CP1251' to 'sr_CS.CP1251'
642# updated 'sr_yu.utf8@cyrillic' -> 'sr_YU.UTF-8' to 'sr_CS.UTF-8'
643# updated 'sr_yu@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
644
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000645locale_alias = {
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000646 'a3': 'a3_AZ.KOI8-C',
647 'a3_az': 'a3_AZ.KOI8-C',
648 'a3_az.koi8c': 'a3_AZ.KOI8-C',
649 'af': 'af_ZA.ISO8859-1',
650 'af_za': 'af_ZA.ISO8859-1',
651 'af_za.iso88591': 'af_ZA.ISO8859-1',
652 'am': 'am_ET.UTF-8',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000653 'am_et': 'am_ET.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000654 'american': 'en_US.ISO8859-1',
655 'american.iso88591': 'en_US.ISO8859-1',
656 'ar': 'ar_AA.ISO8859-6',
657 'ar_aa': 'ar_AA.ISO8859-6',
658 'ar_aa.iso88596': 'ar_AA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000659 'ar_ae': 'ar_AE.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000660 'ar_ae.iso88596': 'ar_AE.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000661 'ar_bh': 'ar_BH.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000662 'ar_bh.iso88596': 'ar_BH.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000663 'ar_dz': 'ar_DZ.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000664 'ar_dz.iso88596': 'ar_DZ.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000665 'ar_eg': 'ar_EG.ISO8859-6',
666 'ar_eg.iso88596': 'ar_EG.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000667 'ar_iq': 'ar_IQ.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000668 'ar_iq.iso88596': 'ar_IQ.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000669 'ar_jo': 'ar_JO.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000670 'ar_jo.iso88596': 'ar_JO.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000671 'ar_kw': 'ar_KW.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000672 'ar_kw.iso88596': 'ar_KW.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000673 'ar_lb': 'ar_LB.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000674 'ar_lb.iso88596': 'ar_LB.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000675 'ar_ly': 'ar_LY.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000676 'ar_ly.iso88596': 'ar_LY.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000677 'ar_ma': 'ar_MA.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000678 'ar_ma.iso88596': 'ar_MA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000679 'ar_om': 'ar_OM.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000680 'ar_om.iso88596': 'ar_OM.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000681 'ar_qa': 'ar_QA.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000682 'ar_qa.iso88596': 'ar_QA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000683 'ar_sa': 'ar_SA.ISO8859-6',
684 'ar_sa.iso88596': 'ar_SA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000685 'ar_sd': 'ar_SD.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000686 'ar_sd.iso88596': 'ar_SD.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000687 'ar_sy': 'ar_SY.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000688 'ar_sy.iso88596': 'ar_SY.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000689 'ar_tn': 'ar_TN.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000690 'ar_tn.iso88596': 'ar_TN.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000691 'ar_ye': 'ar_YE.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000692 'ar_ye.iso88596': 'ar_YE.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000693 'arabic': 'ar_AA.ISO8859-6',
694 'arabic.iso88596': 'ar_AA.ISO8859-6',
695 'az': 'az_AZ.ISO8859-9E',
696 'az_az': 'az_AZ.ISO8859-9E',
697 'az_az.iso88599e': 'az_AZ.ISO8859-9E',
698 'be': 'be_BY.CP1251',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000699 'be_by': 'be_BY.CP1251',
700 'be_by.cp1251': 'be_BY.CP1251',
701 'be_by.microsoftcp1251': 'be_BY.CP1251',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000702 'bg': 'bg_BG.CP1251',
703 'bg_bg': 'bg_BG.CP1251',
704 'bg_bg.cp1251': 'bg_BG.CP1251',
705 'bg_bg.iso88595': 'bg_BG.ISO8859-5',
706 'bg_bg.koi8r': 'bg_BG.KOI8-R',
707 'bg_bg.microsoftcp1251': 'bg_BG.CP1251',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000708 'bn_in': 'bn_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000709 'bokmal': 'nb_NO.ISO8859-1',
710 'bokm\xe5l': 'nb_NO.ISO8859-1',
711 'br': 'br_FR.ISO8859-1',
712 'br_fr': 'br_FR.ISO8859-1',
713 'br_fr.iso88591': 'br_FR.ISO8859-1',
714 'br_fr.iso885914': 'br_FR.ISO8859-14',
715 'br_fr.iso885915': 'br_FR.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000716 'br_fr.iso885915@euro': 'br_FR.ISO8859-15',
717 'br_fr.utf8@euro': 'br_FR.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000718 'br_fr@euro': 'br_FR.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000719 'bs': 'bs_BA.ISO8859-2',
720 'bs_ba': 'bs_BA.ISO8859-2',
721 'bs_ba.iso88592': 'bs_BA.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000722 'bulgarian': 'bg_BG.CP1251',
723 'c': 'C',
724 'c-french': 'fr_CA.ISO8859-1',
725 'c-french.iso88591': 'fr_CA.ISO8859-1',
726 'c.en': 'C',
727 'c.iso88591': 'en_US.ISO8859-1',
728 'c_c': 'C',
729 'c_c.c': 'C',
730 'ca': 'ca_ES.ISO8859-1',
731 'ca_es': 'ca_ES.ISO8859-1',
732 'ca_es.iso88591': 'ca_ES.ISO8859-1',
733 'ca_es.iso885915': 'ca_ES.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000734 'ca_es.iso885915@euro': 'ca_ES.ISO8859-15',
735 'ca_es.utf8@euro': 'ca_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000736 'ca_es@euro': 'ca_ES.ISO8859-15',
737 'catalan': 'ca_ES.ISO8859-1',
738 'cextend': 'en_US.ISO8859-1',
739 'cextend.en': 'en_US.ISO8859-1',
740 'chinese-s': 'zh_CN.eucCN',
741 'chinese-t': 'zh_TW.eucTW',
742 'croatian': 'hr_HR.ISO8859-2',
743 'cs': 'cs_CZ.ISO8859-2',
744 'cs_cs': 'cs_CZ.ISO8859-2',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000745 'cs_cs.iso88592': 'cs_CS.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000746 'cs_cz': 'cs_CZ.ISO8859-2',
747 'cs_cz.iso88592': 'cs_CZ.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000748 'cy': 'cy_GB.ISO8859-1',
749 'cy_gb': 'cy_GB.ISO8859-1',
750 'cy_gb.iso88591': 'cy_GB.ISO8859-1',
751 'cy_gb.iso885914': 'cy_GB.ISO8859-14',
752 'cy_gb.iso885915': 'cy_GB.ISO8859-15',
753 'cy_gb@euro': 'cy_GB.ISO8859-15',
754 'cz': 'cs_CZ.ISO8859-2',
755 'cz_cz': 'cs_CZ.ISO8859-2',
756 'czech': 'cs_CZ.ISO8859-2',
757 'da': 'da_DK.ISO8859-1',
758 'da_dk': 'da_DK.ISO8859-1',
759 'da_dk.88591': 'da_DK.ISO8859-1',
760 'da_dk.885915': 'da_DK.ISO8859-15',
761 'da_dk.iso88591': 'da_DK.ISO8859-1',
762 'da_dk.iso885915': 'da_DK.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000763 'da_dk@euro': 'da_DK.ISO8859-15',
764 'danish': 'da_DK.ISO8859-1',
765 'danish.iso88591': 'da_DK.ISO8859-1',
766 'dansk': 'da_DK.ISO8859-1',
767 'de': 'de_DE.ISO8859-1',
768 'de_at': 'de_AT.ISO8859-1',
769 'de_at.iso88591': 'de_AT.ISO8859-1',
770 'de_at.iso885915': 'de_AT.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000771 'de_at.iso885915@euro': 'de_AT.ISO8859-15',
772 'de_at.utf8@euro': 'de_AT.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000773 'de_at@euro': 'de_AT.ISO8859-15',
774 'de_be': 'de_BE.ISO8859-1',
775 'de_be.iso88591': 'de_BE.ISO8859-1',
776 'de_be.iso885915': 'de_BE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000777 'de_be.iso885915@euro': 'de_BE.ISO8859-15',
778 'de_be.utf8@euro': 'de_BE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000779 'de_be@euro': 'de_BE.ISO8859-15',
780 'de_ch': 'de_CH.ISO8859-1',
781 'de_ch.iso88591': 'de_CH.ISO8859-1',
782 'de_ch.iso885915': 'de_CH.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000783 'de_ch@euro': 'de_CH.ISO8859-15',
784 'de_de': 'de_DE.ISO8859-1',
785 'de_de.88591': 'de_DE.ISO8859-1',
786 'de_de.885915': 'de_DE.ISO8859-15',
787 'de_de.885915@euro': 'de_DE.ISO8859-15',
788 'de_de.iso88591': 'de_DE.ISO8859-1',
789 'de_de.iso885915': 'de_DE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000790 'de_de.iso885915@euro': 'de_DE.ISO8859-15',
791 'de_de.utf8@euro': 'de_DE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000792 'de_de@euro': 'de_DE.ISO8859-15',
793 'de_lu': 'de_LU.ISO8859-1',
794 'de_lu.iso88591': 'de_LU.ISO8859-1',
795 'de_lu.iso885915': 'de_LU.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000796 'de_lu.iso885915@euro': 'de_LU.ISO8859-15',
797 'de_lu.utf8@euro': 'de_LU.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000798 'de_lu@euro': 'de_LU.ISO8859-15',
799 'deutsch': 'de_DE.ISO8859-1',
800 'dutch': 'nl_NL.ISO8859-1',
801 'dutch.iso88591': 'nl_BE.ISO8859-1',
802 'ee': 'ee_EE.ISO8859-4',
803 'ee_ee': 'ee_EE.ISO8859-4',
804 'ee_ee.iso88594': 'ee_EE.ISO8859-4',
805 'eesti': 'et_EE.ISO8859-1',
806 'el': 'el_GR.ISO8859-7',
807 'el_gr': 'el_GR.ISO8859-7',
808 'el_gr.iso88597': 'el_GR.ISO8859-7',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000809 'el_gr@euro': 'el_GR.ISO8859-15',
810 'en': 'en_US.ISO8859-1',
811 'en.iso88591': 'en_US.ISO8859-1',
812 'en_au': 'en_AU.ISO8859-1',
813 'en_au.iso88591': 'en_AU.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000814 'en_be': 'en_BE.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000815 'en_be@euro': 'en_BE.ISO8859-15',
816 'en_bw': 'en_BW.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000817 'en_bw.iso88591': 'en_BW.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000818 'en_ca': 'en_CA.ISO8859-1',
819 'en_ca.iso88591': 'en_CA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000820 'en_gb': 'en_GB.ISO8859-1',
821 'en_gb.88591': 'en_GB.ISO8859-1',
822 'en_gb.iso88591': 'en_GB.ISO8859-1',
823 'en_gb.iso885915': 'en_GB.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000824 'en_gb@euro': 'en_GB.ISO8859-15',
825 'en_hk': 'en_HK.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000826 'en_hk.iso88591': 'en_HK.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000827 'en_ie': 'en_IE.ISO8859-1',
828 'en_ie.iso88591': 'en_IE.ISO8859-1',
829 'en_ie.iso885915': 'en_IE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000830 'en_ie.iso885915@euro': 'en_IE.ISO8859-15',
831 'en_ie.utf8@euro': 'en_IE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000832 'en_ie@euro': 'en_IE.ISO8859-15',
833 'en_in': 'en_IN.ISO8859-1',
834 'en_nz': 'en_NZ.ISO8859-1',
835 'en_nz.iso88591': 'en_NZ.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000836 'en_ph': 'en_PH.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000837 'en_ph.iso88591': 'en_PH.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000838 'en_sg': 'en_SG.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000839 'en_sg.iso88591': 'en_SG.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000840 'en_uk': 'en_GB.ISO8859-1',
841 'en_us': 'en_US.ISO8859-1',
842 'en_us.88591': 'en_US.ISO8859-1',
843 'en_us.885915': 'en_US.ISO8859-15',
844 'en_us.iso88591': 'en_US.ISO8859-1',
845 'en_us.iso885915': 'en_US.ISO8859-15',
846 'en_us.iso885915@euro': 'en_US.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000847 'en_us@euro': 'en_US.ISO8859-15',
848 'en_us@euro@euro': 'en_US.ISO8859-15',
849 'en_za': 'en_ZA.ISO8859-1',
850 'en_za.88591': 'en_ZA.ISO8859-1',
851 'en_za.iso88591': 'en_ZA.ISO8859-1',
852 'en_za.iso885915': 'en_ZA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000853 'en_za@euro': 'en_ZA.ISO8859-15',
854 'en_zw': 'en_ZW.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000855 'en_zw.iso88591': 'en_ZW.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000856 'eng_gb': 'en_GB.ISO8859-1',
857 'eng_gb.8859': 'en_GB.ISO8859-1',
858 'english': 'en_EN.ISO8859-1',
859 'english.iso88591': 'en_EN.ISO8859-1',
860 'english_uk': 'en_GB.ISO8859-1',
861 'english_uk.8859': 'en_GB.ISO8859-1',
862 'english_united-states': 'en_US.ISO8859-1',
863 'english_united-states.437': 'C',
864 'english_us': 'en_US.ISO8859-1',
865 'english_us.8859': 'en_US.ISO8859-1',
866 'english_us.ascii': 'en_US.ISO8859-1',
867 'eo': 'eo_XX.ISO8859-3',
868 'eo_eo': 'eo_EO.ISO8859-3',
869 'eo_eo.iso88593': 'eo_EO.ISO8859-3',
870 'eo_xx': 'eo_XX.ISO8859-3',
871 'eo_xx.iso88593': 'eo_XX.ISO8859-3',
872 'es': 'es_ES.ISO8859-1',
873 'es_ar': 'es_AR.ISO8859-1',
874 'es_ar.iso88591': 'es_AR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000875 'es_bo': 'es_BO.ISO8859-1',
876 'es_bo.iso88591': 'es_BO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000877 'es_cl': 'es_CL.ISO8859-1',
878 'es_cl.iso88591': 'es_CL.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000879 'es_co': 'es_CO.ISO8859-1',
880 'es_co.iso88591': 'es_CO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000881 'es_cr': 'es_CR.ISO8859-1',
882 'es_cr.iso88591': 'es_CR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000883 'es_do': 'es_DO.ISO8859-1',
884 'es_do.iso88591': 'es_DO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000885 'es_ec': 'es_EC.ISO8859-1',
886 'es_ec.iso88591': 'es_EC.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000887 'es_es': 'es_ES.ISO8859-1',
888 'es_es.88591': 'es_ES.ISO8859-1',
889 'es_es.iso88591': 'es_ES.ISO8859-1',
890 'es_es.iso885915': 'es_ES.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000891 'es_es.iso885915@euro': 'es_ES.ISO8859-15',
892 'es_es.utf8@euro': 'es_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000893 'es_es@euro': 'es_ES.ISO8859-15',
894 'es_gt': 'es_GT.ISO8859-1',
895 'es_gt.iso88591': 'es_GT.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000896 'es_hn': 'es_HN.ISO8859-1',
897 'es_hn.iso88591': 'es_HN.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000898 'es_mx': 'es_MX.ISO8859-1',
899 'es_mx.iso88591': 'es_MX.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000900 'es_ni': 'es_NI.ISO8859-1',
901 'es_ni.iso88591': 'es_NI.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000902 'es_pa': 'es_PA.ISO8859-1',
903 'es_pa.iso88591': 'es_PA.ISO8859-1',
904 'es_pa.iso885915': 'es_PA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000905 'es_pa@euro': 'es_PA.ISO8859-15',
906 'es_pe': 'es_PE.ISO8859-1',
907 'es_pe.iso88591': 'es_PE.ISO8859-1',
908 'es_pe.iso885915': 'es_PE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000909 'es_pe@euro': 'es_PE.ISO8859-15',
910 'es_pr': 'es_PR.ISO8859-1',
911 'es_pr.iso88591': 'es_PR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000912 'es_py': 'es_PY.ISO8859-1',
913 'es_py.iso88591': 'es_PY.ISO8859-1',
914 'es_py.iso885915': 'es_PY.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000915 'es_py@euro': 'es_PY.ISO8859-15',
916 'es_sv': 'es_SV.ISO8859-1',
917 'es_sv.iso88591': 'es_SV.ISO8859-1',
918 'es_sv.iso885915': 'es_SV.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000919 'es_sv@euro': 'es_SV.ISO8859-15',
920 'es_us': 'es_US.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000921 'es_us.iso88591': 'es_US.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000922 'es_uy': 'es_UY.ISO8859-1',
923 'es_uy.iso88591': 'es_UY.ISO8859-1',
924 'es_uy.iso885915': 'es_UY.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000925 'es_uy@euro': 'es_UY.ISO8859-15',
926 'es_ve': 'es_VE.ISO8859-1',
927 'es_ve.iso88591': 'es_VE.ISO8859-1',
928 'es_ve.iso885915': 'es_VE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000929 'es_ve@euro': 'es_VE.ISO8859-15',
930 'estonian': 'et_EE.ISO8859-1',
931 'et': 'et_EE.ISO8859-15',
932 'et_ee': 'et_EE.ISO8859-15',
933 'et_ee.iso88591': 'et_EE.ISO8859-1',
934 'et_ee.iso885913': 'et_EE.ISO8859-13',
935 'et_ee.iso885915': 'et_EE.ISO8859-15',
936 'et_ee.iso88594': 'et_EE.ISO8859-4',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000937 'et_ee@euro': 'et_EE.ISO8859-15',
938 'eu': 'eu_ES.ISO8859-1',
939 'eu_es': 'eu_ES.ISO8859-1',
940 'eu_es.iso88591': 'eu_ES.ISO8859-1',
941 'eu_es.iso885915': 'eu_ES.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000942 'eu_es.iso885915@euro': 'eu_ES.ISO8859-15',
943 'eu_es.utf8@euro': 'eu_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000944 'eu_es@euro': 'eu_ES.ISO8859-15',
945 'fa': 'fa_IR.UTF-8',
946 'fa_ir': 'fa_IR.UTF-8',
947 'fa_ir.isiri3342': 'fa_IR.ISIRI-3342',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000948 'fi': 'fi_FI.ISO8859-15',
949 'fi_fi': 'fi_FI.ISO8859-15',
950 'fi_fi.88591': 'fi_FI.ISO8859-1',
951 'fi_fi.iso88591': 'fi_FI.ISO8859-1',
952 'fi_fi.iso885915': 'fi_FI.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000953 'fi_fi.iso885915@euro': 'fi_FI.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000954 'fi_fi.utf8@euro': 'fi_FI.UTF-8',
955 'fi_fi@euro': 'fi_FI.ISO8859-15',
956 'finnish': 'fi_FI.ISO8859-1',
957 'finnish.iso88591': 'fi_FI.ISO8859-1',
958 'fo': 'fo_FO.ISO8859-1',
959 'fo_fo': 'fo_FO.ISO8859-1',
960 'fo_fo.iso88591': 'fo_FO.ISO8859-1',
961 'fo_fo.iso885915': 'fo_FO.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000962 'fo_fo@euro': 'fo_FO.ISO8859-15',
963 'fr': 'fr_FR.ISO8859-1',
964 'fr_be': 'fr_BE.ISO8859-1',
965 'fr_be.88591': 'fr_BE.ISO8859-1',
966 'fr_be.iso88591': 'fr_BE.ISO8859-1',
967 'fr_be.iso885915': 'fr_BE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000968 'fr_be.iso885915@euro': 'fr_BE.ISO8859-15',
969 'fr_be.utf8@euro': 'fr_BE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000970 'fr_be@euro': 'fr_BE.ISO8859-15',
971 'fr_ca': 'fr_CA.ISO8859-1',
972 'fr_ca.88591': 'fr_CA.ISO8859-1',
973 'fr_ca.iso88591': 'fr_CA.ISO8859-1',
974 'fr_ca.iso885915': 'fr_CA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000975 'fr_ca@euro': 'fr_CA.ISO8859-15',
976 'fr_ch': 'fr_CH.ISO8859-1',
977 'fr_ch.88591': 'fr_CH.ISO8859-1',
978 'fr_ch.iso88591': 'fr_CH.ISO8859-1',
979 'fr_ch.iso885915': 'fr_CH.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000980 'fr_ch@euro': 'fr_CH.ISO8859-15',
981 'fr_fr': 'fr_FR.ISO8859-1',
982 'fr_fr.88591': 'fr_FR.ISO8859-1',
983 'fr_fr.iso88591': 'fr_FR.ISO8859-1',
984 'fr_fr.iso885915': 'fr_FR.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000985 'fr_fr.iso885915@euro': 'fr_FR.ISO8859-15',
986 'fr_fr.utf8@euro': 'fr_FR.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000987 'fr_fr@euro': 'fr_FR.ISO8859-15',
988 'fr_lu': 'fr_LU.ISO8859-1',
989 'fr_lu.88591': 'fr_LU.ISO8859-1',
990 'fr_lu.iso88591': 'fr_LU.ISO8859-1',
991 'fr_lu.iso885915': 'fr_LU.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000992 'fr_lu.iso885915@euro': 'fr_LU.ISO8859-15',
993 'fr_lu.utf8@euro': 'fr_LU.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000994 'fr_lu@euro': 'fr_LU.ISO8859-15',
995 'fran\xe7ais': 'fr_FR.ISO8859-1',
996 'fre_fr': 'fr_FR.ISO8859-1',
997 'fre_fr.8859': 'fr_FR.ISO8859-1',
998 'french': 'fr_FR.ISO8859-1',
999 'french.iso88591': 'fr_CH.ISO8859-1',
1000 'french_france': 'fr_FR.ISO8859-1',
1001 'french_france.8859': 'fr_FR.ISO8859-1',
1002 'ga': 'ga_IE.ISO8859-1',
1003 'ga_ie': 'ga_IE.ISO8859-1',
1004 'ga_ie.iso88591': 'ga_IE.ISO8859-1',
1005 'ga_ie.iso885914': 'ga_IE.ISO8859-14',
1006 'ga_ie.iso885915': 'ga_IE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001007 'ga_ie.iso885915@euro': 'ga_IE.ISO8859-15',
1008 'ga_ie.utf8@euro': 'ga_IE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001009 'ga_ie@euro': 'ga_IE.ISO8859-15',
1010 'galego': 'gl_ES.ISO8859-1',
1011 'galician': 'gl_ES.ISO8859-1',
1012 'gd': 'gd_GB.ISO8859-1',
1013 'gd_gb': 'gd_GB.ISO8859-1',
1014 'gd_gb.iso88591': 'gd_GB.ISO8859-1',
1015 'gd_gb.iso885914': 'gd_GB.ISO8859-14',
1016 'gd_gb.iso885915': 'gd_GB.ISO8859-15',
1017 'gd_gb@euro': 'gd_GB.ISO8859-15',
1018 'ger_de': 'de_DE.ISO8859-1',
1019 'ger_de.8859': 'de_DE.ISO8859-1',
1020 'german': 'de_DE.ISO8859-1',
1021 'german.iso88591': 'de_CH.ISO8859-1',
1022 'german_germany': 'de_DE.ISO8859-1',
1023 'german_germany.8859': 'de_DE.ISO8859-1',
1024 'gl': 'gl_ES.ISO8859-1',
1025 'gl_es': 'gl_ES.ISO8859-1',
1026 'gl_es.iso88591': 'gl_ES.ISO8859-1',
1027 'gl_es.iso885915': 'gl_ES.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001028 'gl_es.iso885915@euro': 'gl_ES.ISO8859-15',
1029 'gl_es.utf8@euro': 'gl_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001030 'gl_es@euro': 'gl_ES.ISO8859-15',
1031 'greek': 'el_GR.ISO8859-7',
1032 'greek.iso88597': 'el_GR.ISO8859-7',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001033 'gu_in': 'gu_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001034 'gv': 'gv_GB.ISO8859-1',
1035 'gv_gb': 'gv_GB.ISO8859-1',
1036 'gv_gb.iso88591': 'gv_GB.ISO8859-1',
1037 'gv_gb.iso885914': 'gv_GB.ISO8859-14',
1038 'gv_gb.iso885915': 'gv_GB.ISO8859-15',
1039 'gv_gb@euro': 'gv_GB.ISO8859-15',
1040 'he': 'he_IL.ISO8859-8',
1041 'he_il': 'he_IL.ISO8859-8',
1042 'he_il.cp1255': 'he_IL.CP1255',
1043 'he_il.iso88598': 'he_IL.ISO8859-8',
1044 'he_il.microsoftcp1255': 'he_IL.CP1255',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001045 'hebrew': 'iw_IL.ISO8859-8',
1046 'hebrew.iso88598': 'iw_IL.ISO8859-8',
1047 'hi': 'hi_IN.ISCII-DEV',
1048 'hi_in': 'hi_IN.ISCII-DEV',
1049 'hi_in.isciidev': 'hi_IN.ISCII-DEV',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001050 'hr': 'hr_HR.ISO8859-2',
1051 'hr_hr': 'hr_HR.ISO8859-2',
1052 'hr_hr.iso88592': 'hr_HR.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001053 'hrvatski': 'hr_HR.ISO8859-2',
1054 'hu': 'hu_HU.ISO8859-2',
1055 'hu_hu': 'hu_HU.ISO8859-2',
1056 'hu_hu.iso88592': 'hu_HU.ISO8859-2',
1057 'hungarian': 'hu_HU.ISO8859-2',
1058 'icelandic': 'is_IS.ISO8859-1',
1059 'icelandic.iso88591': 'is_IS.ISO8859-1',
1060 'id': 'id_ID.ISO8859-1',
1061 'id_id': 'id_ID.ISO8859-1',
1062 'in': 'id_ID.ISO8859-1',
1063 'in_id': 'id_ID.ISO8859-1',
1064 'is': 'is_IS.ISO8859-1',
1065 'is_is': 'is_IS.ISO8859-1',
1066 'is_is.iso88591': 'is_IS.ISO8859-1',
1067 'is_is.iso885915': 'is_IS.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001068 'is_is@euro': 'is_IS.ISO8859-15',
1069 'iso-8859-1': 'en_US.ISO8859-1',
1070 'iso-8859-15': 'en_US.ISO8859-15',
1071 'iso8859-1': 'en_US.ISO8859-1',
1072 'iso8859-15': 'en_US.ISO8859-15',
1073 'iso_8859_1': 'en_US.ISO8859-1',
1074 'iso_8859_15': 'en_US.ISO8859-15',
1075 'it': 'it_IT.ISO8859-1',
1076 'it_ch': 'it_CH.ISO8859-1',
1077 'it_ch.iso88591': 'it_CH.ISO8859-1',
1078 'it_ch.iso885915': 'it_CH.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001079 'it_ch@euro': 'it_CH.ISO8859-15',
1080 'it_it': 'it_IT.ISO8859-1',
1081 'it_it.88591': 'it_IT.ISO8859-1',
1082 'it_it.iso88591': 'it_IT.ISO8859-1',
1083 'it_it.iso885915': 'it_IT.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001084 'it_it.iso885915@euro': 'it_IT.ISO8859-15',
1085 'it_it.utf8@euro': 'it_IT.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001086 'it_it@euro': 'it_IT.ISO8859-15',
1087 'italian': 'it_IT.ISO8859-1',
1088 'italian.iso88591': 'it_IT.ISO8859-1',
1089 'iu': 'iu_CA.NUNACOM-8',
1090 'iu_ca': 'iu_CA.NUNACOM-8',
1091 'iu_ca.nunacom8': 'iu_CA.NUNACOM-8',
1092 'iw': 'he_IL.ISO8859-8',
1093 'iw_il': 'he_IL.ISO8859-8',
1094 'iw_il.iso88598': 'he_IL.ISO8859-8',
1095 'ja': 'ja_JP.eucJP',
1096 'ja.jis': 'ja_JP.JIS7',
1097 'ja.sjis': 'ja_JP.SJIS',
1098 'ja_jp': 'ja_JP.eucJP',
1099 'ja_jp.ajec': 'ja_JP.eucJP',
1100 'ja_jp.euc': 'ja_JP.eucJP',
1101 'ja_jp.eucjp': 'ja_JP.eucJP',
1102 'ja_jp.iso-2022-jp': 'ja_JP.JIS7',
1103 'ja_jp.iso2022jp': 'ja_JP.JIS7',
1104 'ja_jp.jis': 'ja_JP.JIS7',
1105 'ja_jp.jis7': 'ja_JP.JIS7',
1106 'ja_jp.mscode': 'ja_JP.SJIS',
1107 'ja_jp.sjis': 'ja_JP.SJIS',
1108 'ja_jp.ujis': 'ja_JP.eucJP',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001109 'japan': 'ja_JP.eucJP',
1110 'japanese': 'ja_JP.eucJP',
1111 'japanese-euc': 'ja_JP.eucJP',
1112 'japanese.euc': 'ja_JP.eucJP',
1113 'japanese.sjis': 'ja_JP.SJIS',
1114 'jp_jp': 'ja_JP.eucJP',
1115 'ka': 'ka_GE.GEORGIAN-ACADEMY',
1116 'ka_ge': 'ka_GE.GEORGIAN-ACADEMY',
1117 'ka_ge.georgianacademy': 'ka_GE.GEORGIAN-ACADEMY',
1118 'ka_ge.georgianps': 'ka_GE.GEORGIAN-PS',
1119 'ka_ge.georgianrs': 'ka_GE.GEORGIAN-ACADEMY',
1120 'kl': 'kl_GL.ISO8859-1',
1121 'kl_gl': 'kl_GL.ISO8859-1',
1122 'kl_gl.iso88591': 'kl_GL.ISO8859-1',
1123 'kl_gl.iso885915': 'kl_GL.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001124 'kl_gl@euro': 'kl_GL.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001125 'km_kh': 'km_KH.UTF-8',
1126 'kn_in': 'kn_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001127 'ko': 'ko_KR.eucKR',
1128 'ko_kr': 'ko_KR.eucKR',
1129 'ko_kr.euc': 'ko_KR.eucKR',
1130 'ko_kr.euckr': 'ko_KR.eucKR',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001131 'korean': 'ko_KR.eucKR',
1132 'korean.euc': 'ko_KR.eucKR',
1133 'kw': 'kw_GB.ISO8859-1',
1134 'kw_gb': 'kw_GB.ISO8859-1',
1135 'kw_gb.iso88591': 'kw_GB.ISO8859-1',
1136 'kw_gb.iso885914': 'kw_GB.ISO8859-14',
1137 'kw_gb.iso885915': 'kw_GB.ISO8859-15',
1138 'kw_gb@euro': 'kw_GB.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001139 'ky': 'ky_KG.UTF-8',
1140 'ky_kg': 'ky_KG.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001141 'lithuanian': 'lt_LT.ISO8859-13',
1142 'lo': 'lo_LA.MULELAO-1',
1143 'lo_la': 'lo_LA.MULELAO-1',
1144 'lo_la.cp1133': 'lo_LA.IBM-CP1133',
1145 'lo_la.ibmcp1133': 'lo_LA.IBM-CP1133',
1146 'lo_la.mulelao1': 'lo_LA.MULELAO-1',
1147 'lt': 'lt_LT.ISO8859-13',
1148 'lt_lt': 'lt_LT.ISO8859-13',
1149 'lt_lt.iso885913': 'lt_LT.ISO8859-13',
1150 'lt_lt.iso88594': 'lt_LT.ISO8859-4',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001151 'lv': 'lv_LV.ISO8859-13',
1152 'lv_lv': 'lv_LV.ISO8859-13',
1153 'lv_lv.iso885913': 'lv_LV.ISO8859-13',
1154 'lv_lv.iso88594': 'lv_LV.ISO8859-4',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001155 'mi': 'mi_NZ.ISO8859-1',
1156 'mi_nz': 'mi_NZ.ISO8859-1',
1157 'mi_nz.iso88591': 'mi_NZ.ISO8859-1',
1158 'mk': 'mk_MK.ISO8859-5',
1159 'mk_mk': 'mk_MK.ISO8859-5',
1160 'mk_mk.cp1251': 'mk_MK.CP1251',
1161 'mk_mk.iso88595': 'mk_MK.ISO8859-5',
1162 'mk_mk.microsoftcp1251': 'mk_MK.CP1251',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001163 'mr_in': 'mr_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001164 'ms': 'ms_MY.ISO8859-1',
1165 'ms_my': 'ms_MY.ISO8859-1',
1166 'ms_my.iso88591': 'ms_MY.ISO8859-1',
1167 'mt': 'mt_MT.ISO8859-3',
1168 'mt_mt': 'mt_MT.ISO8859-3',
1169 'mt_mt.iso88593': 'mt_MT.ISO8859-3',
1170 'nb': 'nb_NO.ISO8859-1',
1171 'nb_no': 'nb_NO.ISO8859-1',
1172 'nb_no.88591': 'nb_NO.ISO8859-1',
1173 'nb_no.iso88591': 'nb_NO.ISO8859-1',
1174 'nb_no.iso885915': 'nb_NO.ISO8859-15',
1175 'nb_no@euro': 'nb_NO.ISO8859-15',
1176 'nl': 'nl_NL.ISO8859-1',
1177 'nl_be': 'nl_BE.ISO8859-1',
1178 'nl_be.88591': 'nl_BE.ISO8859-1',
1179 'nl_be.iso88591': 'nl_BE.ISO8859-1',
1180 'nl_be.iso885915': 'nl_BE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001181 'nl_be.iso885915@euro': 'nl_BE.ISO8859-15',
1182 'nl_be.utf8@euro': 'nl_BE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001183 'nl_be@euro': 'nl_BE.ISO8859-15',
1184 'nl_nl': 'nl_NL.ISO8859-1',
1185 'nl_nl.88591': 'nl_NL.ISO8859-1',
1186 'nl_nl.iso88591': 'nl_NL.ISO8859-1',
1187 'nl_nl.iso885915': 'nl_NL.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001188 'nl_nl.iso885915@euro': 'nl_NL.ISO8859-15',
1189 'nl_nl.utf8@euro': 'nl_NL.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001190 'nl_nl@euro': 'nl_NL.ISO8859-15',
1191 'nn': 'nn_NO.ISO8859-1',
1192 'nn_no': 'nn_NO.ISO8859-1',
1193 'nn_no.88591': 'nn_NO.ISO8859-1',
1194 'nn_no.iso88591': 'nn_NO.ISO8859-1',
1195 'nn_no.iso885915': 'nn_NO.ISO8859-15',
1196 'nn_no@euro': 'nn_NO.ISO8859-15',
1197 'no': 'no_NO.ISO8859-1',
1198 'no@nynorsk': 'ny_NO.ISO8859-1',
1199 'no_no': 'no_NO.ISO8859-1',
1200 'no_no.88591': 'no_NO.ISO8859-1',
1201 'no_no.iso88591': 'no_NO.ISO8859-1',
1202 'no_no.iso885915': 'no_NO.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001203 'no_no@euro': 'no_NO.ISO8859-15',
1204 'norwegian': 'no_NO.ISO8859-1',
1205 'norwegian.iso88591': 'no_NO.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001206 'nr': 'nr_ZA.ISO8859-1',
1207 'nr_za': 'nr_ZA.ISO8859-1',
1208 'nr_za.iso88591': 'nr_ZA.ISO8859-1',
1209 'nso': 'nso_ZA.ISO8859-15',
1210 'nso_za': 'nso_ZA.ISO8859-15',
1211 'nso_za.iso885915': 'nso_ZA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001212 'ny': 'ny_NO.ISO8859-1',
1213 'ny_no': 'ny_NO.ISO8859-1',
1214 'ny_no.88591': 'ny_NO.ISO8859-1',
1215 'ny_no.iso88591': 'ny_NO.ISO8859-1',
1216 'ny_no.iso885915': 'ny_NO.ISO8859-15',
1217 'ny_no@euro': 'ny_NO.ISO8859-15',
1218 'nynorsk': 'nn_NO.ISO8859-1',
1219 'oc': 'oc_FR.ISO8859-1',
1220 'oc_fr': 'oc_FR.ISO8859-1',
1221 'oc_fr.iso88591': 'oc_FR.ISO8859-1',
1222 'oc_fr.iso885915': 'oc_FR.ISO8859-15',
1223 'oc_fr@euro': 'oc_FR.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001224 'pa_in': 'pa_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001225 'pd': 'pd_US.ISO8859-1',
1226 'pd_de': 'pd_DE.ISO8859-1',
1227 'pd_de.iso88591': 'pd_DE.ISO8859-1',
1228 'pd_de.iso885915': 'pd_DE.ISO8859-15',
1229 'pd_de@euro': 'pd_DE.ISO8859-15',
1230 'pd_us': 'pd_US.ISO8859-1',
1231 'pd_us.iso88591': 'pd_US.ISO8859-1',
1232 'pd_us.iso885915': 'pd_US.ISO8859-15',
1233 'pd_us@euro': 'pd_US.ISO8859-15',
1234 'ph': 'ph_PH.ISO8859-1',
1235 'ph_ph': 'ph_PH.ISO8859-1',
1236 'ph_ph.iso88591': 'ph_PH.ISO8859-1',
1237 'pl': 'pl_PL.ISO8859-2',
1238 'pl_pl': 'pl_PL.ISO8859-2',
1239 'pl_pl.iso88592': 'pl_PL.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001240 'polish': 'pl_PL.ISO8859-2',
1241 'portuguese': 'pt_PT.ISO8859-1',
1242 'portuguese.iso88591': 'pt_PT.ISO8859-1',
1243 'portuguese_brazil': 'pt_BR.ISO8859-1',
1244 'portuguese_brazil.8859': 'pt_BR.ISO8859-1',
1245 'posix': 'C',
1246 'posix-utf2': 'C',
1247 'pp': 'pp_AN.ISO8859-1',
1248 'pp_an': 'pp_AN.ISO8859-1',
1249 'pp_an.iso88591': 'pp_AN.ISO8859-1',
1250 'pt': 'pt_PT.ISO8859-1',
1251 'pt_br': 'pt_BR.ISO8859-1',
1252 'pt_br.88591': 'pt_BR.ISO8859-1',
1253 'pt_br.iso88591': 'pt_BR.ISO8859-1',
1254 'pt_br.iso885915': 'pt_BR.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001255 'pt_br@euro': 'pt_BR.ISO8859-15',
1256 'pt_pt': 'pt_PT.ISO8859-1',
1257 'pt_pt.88591': 'pt_PT.ISO8859-1',
1258 'pt_pt.iso88591': 'pt_PT.ISO8859-1',
1259 'pt_pt.iso885915': 'pt_PT.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001260 'pt_pt.iso885915@euro': 'pt_PT.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001261 'pt_pt.utf8@euro': 'pt_PT.UTF-8',
1262 'pt_pt@euro': 'pt_PT.ISO8859-15',
1263 'ro': 'ro_RO.ISO8859-2',
1264 'ro_ro': 'ro_RO.ISO8859-2',
1265 'ro_ro.iso88592': 'ro_RO.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001266 'romanian': 'ro_RO.ISO8859-2',
1267 'ru': 'ru_RU.ISO8859-5',
1268 'ru_ru': 'ru_RU.ISO8859-5',
1269 'ru_ru.cp1251': 'ru_RU.CP1251',
1270 'ru_ru.iso88595': 'ru_RU.ISO8859-5',
1271 'ru_ru.koi8r': 'ru_RU.KOI8-R',
1272 'ru_ru.microsoftcp1251': 'ru_RU.CP1251',
1273 'ru_ua': 'ru_UA.KOI8-U',
1274 'ru_ua.cp1251': 'ru_UA.CP1251',
1275 'ru_ua.koi8u': 'ru_UA.KOI8-U',
1276 'ru_ua.microsoftcp1251': 'ru_UA.CP1251',
1277 'rumanian': 'ro_RO.ISO8859-2',
1278 'russian': 'ru_RU.ISO8859-5',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001279 'rw': 'rw_RW.ISO8859-1',
1280 'rw_rw': 'rw_RW.ISO8859-1',
1281 'rw_rw.iso88591': 'rw_RW.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001282 'se_no': 'se_NO.UTF-8',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001283 'serbocroatian': 'sr_CS.ISO8859-2',
1284 'sh': 'sr_CS.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001285 'sh_hr': 'sh_HR.ISO8859-2',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001286 'sh_hr.iso88592': 'hr_HR.ISO8859-2',
1287 'sh_sp': 'sr_CS.ISO8859-2',
1288 'sh_yu': 'sr_CS.ISO8859-2',
1289 'si': 'si_LK.UTF-8',
1290 'si_lk': 'si_LK.UTF-8',
1291 'sinhala': 'si_LK.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001292 'sk': 'sk_SK.ISO8859-2',
1293 'sk_sk': 'sk_SK.ISO8859-2',
1294 'sk_sk.iso88592': 'sk_SK.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001295 'sl': 'sl_SI.ISO8859-2',
1296 'sl_cs': 'sl_CS.ISO8859-2',
1297 'sl_si': 'sl_SI.ISO8859-2',
1298 'sl_si.iso88592': 'sl_SI.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001299 'slovak': 'sk_SK.ISO8859-2',
1300 'slovene': 'sl_SI.ISO8859-2',
1301 'slovenian': 'sl_SI.ISO8859-2',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001302 'sp': 'sr_CS.ISO8859-5',
1303 'sp_yu': 'sr_CS.ISO8859-5',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001304 'spanish': 'es_ES.ISO8859-1',
1305 'spanish.iso88591': 'es_ES.ISO8859-1',
1306 'spanish_spain': 'es_ES.ISO8859-1',
1307 'spanish_spain.8859': 'es_ES.ISO8859-1',
1308 'sq': 'sq_AL.ISO8859-2',
1309 'sq_al': 'sq_AL.ISO8859-2',
1310 'sq_al.iso88592': 'sq_AL.ISO8859-2',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001311 'sr': 'sr_CS.ISO8859-5',
1312 'sr@cyrillic': 'sr_CS.ISO8859-5',
1313 'sr@latn': 'sr_CS.ISO8859-2',
1314 'sr_cs.iso88592': 'sr_CS.ISO8859-2',
1315 'sr_cs.iso88592@latn': 'sr_CS.ISO8859-2',
1316 'sr_cs.iso88595': 'sr_CS.ISO8859-5',
1317 'sr_cs.utf8@latn': 'sr_CS.UTF-8',
1318 'sr_cs@latn': 'sr_CS.ISO8859-2',
1319 'sr_sp': 'sr_CS.ISO8859-2',
1320 'sr_yu': 'sr_CS.ISO8859-5',
1321 'sr_yu.cp1251@cyrillic': 'sr_CS.CP1251',
1322 'sr_yu.iso88592': 'sr_CS.ISO8859-2',
1323 'sr_yu.iso88595': 'sr_CS.ISO8859-5',
1324 'sr_yu.iso88595@cyrillic': 'sr_CS.ISO8859-5',
1325 'sr_yu.microsoftcp1251@cyrillic': 'sr_CS.CP1251',
1326 'sr_yu.utf8@cyrillic': 'sr_CS.UTF-8',
1327 'sr_yu@cyrillic': 'sr_CS.ISO8859-5',
1328 'ss': 'ss_ZA.ISO8859-1',
1329 'ss_za': 'ss_ZA.ISO8859-1',
1330 'ss_za.iso88591': 'ss_ZA.ISO8859-1',
1331 'st': 'st_ZA.ISO8859-1',
1332 'st_za': 'st_ZA.ISO8859-1',
1333 'st_za.iso88591': 'st_ZA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001334 'sv': 'sv_SE.ISO8859-1',
1335 'sv_fi': 'sv_FI.ISO8859-1',
1336 'sv_fi.iso88591': 'sv_FI.ISO8859-1',
1337 'sv_fi.iso885915': 'sv_FI.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001338 'sv_fi.iso885915@euro': 'sv_FI.ISO8859-15',
1339 'sv_fi.utf8@euro': 'sv_FI.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001340 'sv_fi@euro': 'sv_FI.ISO8859-15',
1341 'sv_se': 'sv_SE.ISO8859-1',
1342 'sv_se.88591': 'sv_SE.ISO8859-1',
1343 'sv_se.iso88591': 'sv_SE.ISO8859-1',
1344 'sv_se.iso885915': 'sv_SE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001345 'sv_se@euro': 'sv_SE.ISO8859-15',
1346 'swedish': 'sv_SE.ISO8859-1',
1347 'swedish.iso88591': 'sv_SE.ISO8859-1',
1348 'ta': 'ta_IN.TSCII-0',
1349 'ta_in': 'ta_IN.TSCII-0',
1350 'ta_in.tscii': 'ta_IN.TSCII-0',
1351 'ta_in.tscii0': 'ta_IN.TSCII-0',
1352 'tg': 'tg_TJ.KOI8-C',
1353 'tg_tj': 'tg_TJ.KOI8-C',
1354 'tg_tj.koi8c': 'tg_TJ.KOI8-C',
1355 'th': 'th_TH.ISO8859-11',
1356 'th_th': 'th_TH.ISO8859-11',
1357 'th_th.iso885911': 'th_TH.ISO8859-11',
1358 'th_th.tactis': 'th_TH.TIS620',
1359 'th_th.tis620': 'th_TH.TIS620',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001360 'thai': 'th_TH.ISO8859-11',
1361 'tl': 'tl_PH.ISO8859-1',
1362 'tl_ph': 'tl_PH.ISO8859-1',
1363 'tl_ph.iso88591': 'tl_PH.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001364 'tn': 'tn_ZA.ISO8859-15',
1365 'tn_za': 'tn_ZA.ISO8859-15',
1366 'tn_za.iso885915': 'tn_ZA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001367 'tr': 'tr_TR.ISO8859-9',
1368 'tr_tr': 'tr_TR.ISO8859-9',
1369 'tr_tr.iso88599': 'tr_TR.ISO8859-9',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001370 'ts': 'ts_ZA.ISO8859-1',
1371 'ts_za': 'ts_ZA.ISO8859-1',
1372 'ts_za.iso88591': 'ts_ZA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001373 'tt': 'tt_RU.TATAR-CYR',
1374 'tt_ru': 'tt_RU.TATAR-CYR',
1375 'tt_ru.koi8c': 'tt_RU.KOI8-C',
1376 'tt_ru.tatarcyr': 'tt_RU.TATAR-CYR',
1377 'turkish': 'tr_TR.ISO8859-9',
1378 'turkish.iso88599': 'tr_TR.ISO8859-9',
1379 'uk': 'uk_UA.KOI8-U',
1380 'uk_ua': 'uk_UA.KOI8-U',
1381 'uk_ua.cp1251': 'uk_UA.CP1251',
1382 'uk_ua.iso88595': 'uk_UA.ISO8859-5',
1383 'uk_ua.koi8u': 'uk_UA.KOI8-U',
1384 'uk_ua.microsoftcp1251': 'uk_UA.CP1251',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001385 'univ': 'en_US.utf',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001386 'universal': 'en_US.utf',
1387 'universal.utf8@ucs4': 'en_US.UTF-8',
1388 'ur': 'ur_PK.CP1256',
1389 'ur_pk': 'ur_PK.CP1256',
1390 'ur_pk.cp1256': 'ur_PK.CP1256',
1391 'ur_pk.microsoftcp1256': 'ur_PK.CP1256',
1392 'uz': 'uz_UZ.UTF-8',
1393 'uz_uz': 'uz_UZ.UTF-8',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001394 'uz_uz.iso88591': 'uz_UZ.ISO8859-1',
1395 'uz_uz.utf8@cyrillic': 'uz_UZ.UTF-8',
1396 'uz_uz@cyrillic': 'uz_UZ.UTF-8',
1397 've': 've_ZA.UTF-8',
1398 've_za': 've_ZA.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001399 'vi': 'vi_VN.TCVN',
1400 'vi_vn': 'vi_VN.TCVN',
1401 'vi_vn.tcvn': 'vi_VN.TCVN',
1402 'vi_vn.tcvn5712': 'vi_VN.TCVN',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001403 'vi_vn.viscii': 'vi_VN.VISCII',
1404 'vi_vn.viscii111': 'vi_VN.VISCII',
1405 'wa': 'wa_BE.ISO8859-1',
1406 'wa_be': 'wa_BE.ISO8859-1',
1407 'wa_be.iso88591': 'wa_BE.ISO8859-1',
1408 'wa_be.iso885915': 'wa_BE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001409 'wa_be.iso885915@euro': 'wa_BE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001410 'wa_be@euro': 'wa_BE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001411 'xh': 'xh_ZA.ISO8859-1',
1412 'xh_za': 'xh_ZA.ISO8859-1',
1413 'xh_za.iso88591': 'xh_ZA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001414 'yi': 'yi_US.CP1255',
1415 'yi_us': 'yi_US.CP1255',
1416 'yi_us.cp1255': 'yi_US.CP1255',
1417 'yi_us.microsoftcp1255': 'yi_US.CP1255',
1418 'zh': 'zh_CN.eucCN',
1419 'zh_cn': 'zh_CN.gb2312',
1420 'zh_cn.big5': 'zh_TW.big5',
1421 'zh_cn.euc': 'zh_CN.eucCN',
1422 'zh_cn.gb18030': 'zh_CN.gb18030',
1423 'zh_cn.gb2312': 'zh_CN.gb2312',
1424 'zh_cn.gbk': 'zh_CN.gbk',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001425 'zh_hk': 'zh_HK.big5hkscs',
1426 'zh_hk.big5': 'zh_HK.big5',
1427 'zh_hk.big5hkscs': 'zh_HK.big5hkscs',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001428 'zh_tw': 'zh_TW.big5',
1429 'zh_tw.big5': 'zh_TW.big5',
1430 'zh_tw.euc': 'zh_TW.eucTW',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001431 'zh_tw.euctw': 'zh_TW.eucTW',
1432 'zu': 'zu_ZA.ISO8859-1',
1433 'zu_za': 'zu_ZA.ISO8859-1',
1434 'zu_za.iso88591': 'zu_ZA.ISO8859-1',
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001435}
1436
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001437#
Georg Brandlb709c2c2006-01-20 09:07:35 +00001438# This maps Windows language identifiers to locale strings.
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001439#
Tim Peters777f1082006-01-20 20:03:24 +00001440# This list has been updated from
Georg Brandlb709c2c2006-01-20 09:07:35 +00001441# http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nls_238z.asp
1442# to include every locale up to Windows XP.
Fredrik Lundh37a09822002-10-19 20:19:10 +00001443#
Georg Brandl5035c1c2006-01-20 13:38:26 +00001444# NOTE: this mapping is incomplete. If your language is missing, please
1445# submit a bug report to Python bug manager, which you can find via:
1446# http://www.python.org/dev/
1447# Make sure you include the missing language identifier and the suggested
1448# locale code.
1449#
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001450
1451windows_locale = {
Georg Brandlb709c2c2006-01-20 09:07:35 +00001452 0x0436: "af_ZA", # Afrikaans
1453 0x041c: "sq_AL", # Albanian
1454 0x0401: "ar_SA", # Arabic - Saudi Arabia
1455 0x0801: "ar_IQ", # Arabic - Iraq
1456 0x0c01: "ar_EG", # Arabic - Egypt
1457 0x1001: "ar_LY", # Arabic - Libya
1458 0x1401: "ar_DZ", # Arabic - Algeria
1459 0x1801: "ar_MA", # Arabic - Morocco
1460 0x1c01: "ar_TN", # Arabic - Tunisia
1461 0x2001: "ar_OM", # Arabic - Oman
1462 0x2401: "ar_YE", # Arabic - Yemen
1463 0x2801: "ar_SY", # Arabic - Syria
1464 0x2c01: "ar_JO", # Arabic - Jordan
1465 0x3001: "ar_LB", # Arabic - Lebanon
1466 0x3401: "ar_KW", # Arabic - Kuwait
1467 0x3801: "ar_AE", # Arabic - United Arab Emirates
1468 0x3c01: "ar_BH", # Arabic - Bahrain
1469 0x4001: "ar_QA", # Arabic - Qatar
1470 0x042b: "hy_AM", # Armenian
1471 0x042c: "az_AZ", # Azeri Latin
1472 0x082c: "az_AZ", # Azeri - Cyrillic
1473 0x042d: "eu_ES", # Basque
1474 0x0423: "be_BY", # Belarusian
1475 0x0445: "bn_IN", # Begali
1476 0x201a: "bs_BA", # Bosnian
1477 0x141a: "bs_BA", # Bosnian - Cyrillic
1478 0x047e: "br_FR", # Breton - France
1479 0x0402: "bg_BG", # Bulgarian
1480 0x0403: "ca_ES", # Catalan
1481 0x0004: "zh_CHS",# Chinese - Simplified
1482 0x0404: "zh_TW", # Chinese - Taiwan
1483 0x0804: "zh_CN", # Chinese - PRC
1484 0x0c04: "zh_HK", # Chinese - Hong Kong S.A.R.
1485 0x1004: "zh_SG", # Chinese - Singapore
1486 0x1404: "zh_MO", # Chinese - Macao S.A.R.
1487 0x7c04: "zh_CHT",# Chinese - Traditional
1488 0x041a: "hr_HR", # Croatian
1489 0x101a: "hr_BA", # Croatian - Bosnia
1490 0x0405: "cs_CZ", # Czech
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001491 0x0406: "da_DK", # Danish
Georg Brandlb709c2c2006-01-20 09:07:35 +00001492 0x048c: "gbz_AF",# Dari - Afghanistan
1493 0x0465: "div_MV",# Divehi - Maldives
1494 0x0413: "nl_NL", # Dutch - The Netherlands
1495 0x0813: "nl_BE", # Dutch - Belgium
1496 0x0409: "en_US", # English - United States
1497 0x0809: "en_GB", # English - United Kingdom
1498 0x0c09: "en_AU", # English - Australia
1499 0x1009: "en_CA", # English - Canada
1500 0x1409: "en_NZ", # English - New Zealand
1501 0x1809: "en_IE", # English - Ireland
1502 0x1c09: "en_ZA", # English - South Africa
1503 0x2009: "en_JA", # English - Jamaica
1504 0x2409: "en_CB", # English - Carribbean
1505 0x2809: "en_BZ", # English - Belize
1506 0x2c09: "en_TT", # English - Trinidad
1507 0x3009: "en_ZW", # English - Zimbabwe
1508 0x3409: "en_PH", # English - Phillippines
1509 0x0425: "et_EE", # Estonian
1510 0x0438: "fo_FO", # Faroese
1511 0x0464: "fil_PH",# Filipino
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001512 0x040b: "fi_FI", # Finnish
Georg Brandlb709c2c2006-01-20 09:07:35 +00001513 0x040c: "fr_FR", # French - France
1514 0x080c: "fr_BE", # French - Belgium
1515 0x0c0c: "fr_CA", # French - Canada
1516 0x100c: "fr_CH", # French - Switzerland
1517 0x140c: "fr_LU", # French - Luxembourg
1518 0x180c: "fr_MC", # French - Monaco
1519 0x0462: "fy_NL", # Frisian - Netherlands
1520 0x0456: "gl_ES", # Galician
1521 0x0437: "ka_GE", # Georgian
1522 0x0407: "de_DE", # German - Germany
1523 0x0807: "de_CH", # German - Switzerland
1524 0x0c07: "de_AT", # German - Austria
1525 0x1007: "de_LU", # German - Luxembourg
1526 0x1407: "de_LI", # German - Liechtenstein
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001527 0x0408: "el_GR", # Greek
Georg Brandlb709c2c2006-01-20 09:07:35 +00001528 0x0447: "gu_IN", # Gujarati
1529 0x040d: "he_IL", # Hebrew
1530 0x0439: "hi_IN", # Hindi
1531 0x040e: "hu_HU", # Hungarian
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001532 0x040f: "is_IS", # Icelandic
Georg Brandlb709c2c2006-01-20 09:07:35 +00001533 0x0421: "id_ID", # Indonesian
1534 0x045d: "iu_CA", # Inuktitut
1535 0x085d: "iu_CA", # Inuktitut - Latin
1536 0x083c: "ga_IE", # Irish - Ireland
1537 0x0434: "xh_ZA", # Xhosa - South Africa
1538 0x0435: "zu_ZA", # Zulu
1539 0x0410: "it_IT", # Italian - Italy
1540 0x0810: "it_CH", # Italian - Switzerland
1541 0x0411: "ja_JP", # Japanese
1542 0x044b: "kn_IN", # Kannada - India
1543 0x043f: "kk_KZ", # Kazakh
1544 0x0457: "kok_IN",# Konkani
1545 0x0412: "ko_KR", # Korean
1546 0x0440: "ky_KG", # Kyrgyz
1547 0x0426: "lv_LV", # Latvian
1548 0x0427: "lt_LT", # Lithuanian
1549 0x046e: "lb_LU", # Luxembourgish
1550 0x042f: "mk_MK", # FYRO Macedonian
1551 0x043e: "ms_MY", # Malay - Malaysia
1552 0x083e: "ms_BN", # Malay - Brunei
1553 0x044c: "ml_IN", # Malayalam - India
1554 0x043a: "mt_MT", # Maltese
1555 0x0481: "mi_NZ", # Maori
1556 0x047a: "arn_CL",# Mapudungun
1557 0x044e: "mr_IN", # Marathi
1558 0x047c: "moh_CA",# Mohawk - Canada
1559 0x0450: "mn_MN", # Mongolian
1560 0x0461: "ne_NP", # Nepali
1561 0x0414: "nb_NO", # Norwegian - Bokmal
1562 0x0814: "nn_NO", # Norwegian - Nynorsk
1563 0x0482: "oc_FR", # Occitan - France
1564 0x0448: "or_IN", # Oriya - India
1565 0x0463: "ps_AF", # Pashto - Afghanistan
1566 0x0429: "fa_IR", # Persian
1567 0x0415: "pl_PL", # Polish
1568 0x0416: "pt_BR", # Portuguese - Brazil
1569 0x0816: "pt_PT", # Portuguese - Portugal
1570 0x0446: "pa_IN", # Punjabi
1571 0x046b: "quz_BO",# Quechua (Bolivia)
1572 0x086b: "quz_EC",# Quechua (Ecuador)
1573 0x0c6b: "quz_PE",# Quechua (Peru)
1574 0x0418: "ro_RO", # Romanian - Romania
1575 0x0417: "rm_CH", # Raeto-Romanese
1576 0x0419: "ru_RU", # Russian
1577 0x243b: "smn_FI",# Sami Finland
1578 0x103b: "smj_NO",# Sami Norway
1579 0x143b: "smj_SE",# Sami Sweden
1580 0x043b: "se_NO", # Sami Northern Norway
1581 0x083b: "se_SE", # Sami Northern Sweden
1582 0x0c3b: "se_FI", # Sami Northern Finland
1583 0x203b: "sms_FI",# Sami Skolt
1584 0x183b: "sma_NO",# Sami Southern Norway
1585 0x1c3b: "sma_SE",# Sami Southern Sweden
1586 0x044f: "sa_IN", # Sanskrit
1587 0x0c1a: "sr_SP", # Serbian - Cyrillic
1588 0x1c1a: "sr_BA", # Serbian - Bosnia Cyrillic
1589 0x081a: "sr_SP", # Serbian - Latin
1590 0x181a: "sr_BA", # Serbian - Bosnia Latin
1591 0x046c: "ns_ZA", # Northern Sotho
1592 0x0432: "tn_ZA", # Setswana - Southern Africa
1593 0x041b: "sk_SK", # Slovak
1594 0x0424: "sl_SI", # Slovenian
1595 0x040a: "es_ES", # Spanish - Spain
1596 0x080a: "es_MX", # Spanish - Mexico
1597 0x0c0a: "es_ES", # Spanish - Spain (Modern)
1598 0x100a: "es_GT", # Spanish - Guatemala
1599 0x140a: "es_CR", # Spanish - Costa Rica
1600 0x180a: "es_PA", # Spanish - Panama
1601 0x1c0a: "es_DO", # Spanish - Dominican Republic
1602 0x200a: "es_VE", # Spanish - Venezuela
1603 0x240a: "es_CO", # Spanish - Colombia
1604 0x280a: "es_PE", # Spanish - Peru
1605 0x2c0a: "es_AR", # Spanish - Argentina
1606 0x300a: "es_EC", # Spanish - Ecuador
1607 0x340a: "es_CL", # Spanish - Chile
1608 0x380a: "es_UR", # Spanish - Uruguay
1609 0x3c0a: "es_PY", # Spanish - Paraguay
1610 0x400a: "es_BO", # Spanish - Bolivia
1611 0x440a: "es_SV", # Spanish - El Salvador
1612 0x480a: "es_HN", # Spanish - Honduras
1613 0x4c0a: "es_NI", # Spanish - Nicaragua
1614 0x500a: "es_PR", # Spanish - Puerto Rico
1615 0x0441: "sw_KE", # Swahili
1616 0x041d: "sv_SE", # Swedish - Sweden
1617 0x081d: "sv_FI", # Swedish - Finland
1618 0x045a: "syr_SY",# Syriac
1619 0x0449: "ta_IN", # Tamil
1620 0x0444: "tt_RU", # Tatar
1621 0x044a: "te_IN", # Telugu
1622 0x041e: "th_TH", # Thai
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001623 0x041f: "tr_TR", # Turkish
Georg Brandlb709c2c2006-01-20 09:07:35 +00001624 0x0422: "uk_UA", # Ukrainian
1625 0x0420: "ur_PK", # Urdu
1626 0x0820: "ur_IN", # Urdu - India
1627 0x0443: "uz_UZ", # Uzbek - Latin
1628 0x0843: "uz_UZ", # Uzbek - Cyrillic
1629 0x042a: "vi_VN", # Vietnamese
1630 0x0452: "cy_GB", # Welsh
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001631}
1632
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001633def _print_locale():
1634
1635 """ Test function.
1636 """
1637 categories = {}
1638 def _init_categories(categories=categories):
1639 for k,v in globals().items():
1640 if k[:3] == 'LC_':
1641 categories[k] = v
1642 _init_categories()
1643 del categories['LC_ALL']
1644
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001645 print 'Locale defaults as determined by getdefaultlocale():'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001646 print '-'*72
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001647 lang, enc = getdefaultlocale()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001648 print 'Language: ', lang or '(undefined)'
1649 print 'Encoding: ', enc or '(undefined)'
1650 print
1651
1652 print 'Locale settings on startup:'
1653 print '-'*72
1654 for name,category in categories.items():
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001655 print name, '...'
1656 lang, enc = getlocale(category)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001657 print ' Language: ', lang or '(undefined)'
1658 print ' Encoding: ', enc or '(undefined)'
1659 print
1660
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001661 print
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001662 print 'Locale settings after calling resetlocale():'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001663 print '-'*72
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001664 resetlocale()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001665 for name,category in categories.items():
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001666 print name, '...'
1667 lang, enc = getlocale(category)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001668 print ' Language: ', lang or '(undefined)'
1669 print ' Encoding: ', enc or '(undefined)'
1670 print
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001671
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001672 try:
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001673 setlocale(LC_ALL, "")
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001674 except:
1675 print 'NOTE:'
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001676 print 'setlocale(LC_ALL, "") does not support the default locale'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001677 print 'given in the OS environment variables.'
1678 else:
1679 print
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001680 print 'Locale settings after calling setlocale(LC_ALL, ""):'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001681 print '-'*72
1682 for name,category in categories.items():
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001683 print name, '...'
1684 lang, enc = getlocale(category)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001685 print ' Language: ', lang or '(undefined)'
1686 print ' Encoding: ', enc or '(undefined)'
1687 print
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001688
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001689###
Guido van Rossumeef1d4e1997-11-19 19:01:43 +00001690
Tim Peters1baf8292001-01-24 10:13:46 +00001691try:
1692 LC_MESSAGES
Skip Montanaro0897f0c2002-03-25 21:40:36 +00001693except NameError:
Tim Peters1baf8292001-01-24 10:13:46 +00001694 pass
1695else:
1696 __all__.append("LC_MESSAGES")
1697
Guido van Rossumeef1d4e1997-11-19 19:01:43 +00001698if __name__=='__main__':
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001699 print 'Locale aliasing:'
1700 print
1701 _print_locale()
1702 print
1703 print 'Number formatting:'
1704 print
1705 _test()