blob: 62828fd7e485d0b7cd7a6cd8f2eedc372216830e [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
Georg Brandl1a3284e2007-12-02 09:40:06 +000015from builtins import str as _builtin_str
Antoine Pitrou83d6a872008-07-25 21:45:08 +000016import functools
Marc-André Lemburg5431bc32000-06-07 09:11:40 +000017
Fredrik Lundh6c86b992000-07-09 17:12:58 +000018# Try importing the _locale module.
19#
20# If this fails, fall back on a basic 'C' locale emulation.
Guido van Rossumeef1d4e1997-11-19 19:01:43 +000021
Tim Peters1baf8292001-01-24 10:13:46 +000022# Yuck: LC_MESSAGES is non-standard: can't tell whether it exists before
23# trying the import. So __all__ is also fiddled at the end of the file.
Guido van Rossum360e4b82007-05-14 22:51:27 +000024__all__ = ["getlocale", "getdefaultlocale", "getpreferredencoding", "Error",
25 "setlocale", "resetlocale", "localeconv", "strcoll", "strxfrm",
26 "str", "atof", "atoi", "format", "format_string", "currency",
27 "normalize", "LC_CTYPE", "LC_COLLATE", "LC_TIME", "LC_MONETARY",
28 "LC_NUMERIC", "LC_ALL", "CHAR_MAX"]
Skip Montanaro17ab1232001-01-24 06:27:27 +000029
Neal Norwitz48b98de2008-03-10 04:49:25 +000030def _strcoll(a,b):
31 """ strcoll(string,string) -> int.
32 Compares two strings according to the locale.
33 """
Mark Dickinsona56c4672009-01-27 18:17:45 +000034 return (a > b) - (a < b)
Neal Norwitz48b98de2008-03-10 04:49:25 +000035
36def _strxfrm(s):
37 """ strxfrm(string) -> string.
38 Returns a string that behaves for cmp locale-aware.
39 """
40 return s
41
Marc-André Lemburg23481142000-06-08 17:49:41 +000042try:
Fredrik Lundh6c86b992000-07-09 17:12:58 +000043
Marc-André Lemburg23481142000-06-08 17:49:41 +000044 from _locale import *
45
46except ImportError:
47
Fredrik Lundh6c86b992000-07-09 17:12:58 +000048 # Locale emulation
49
Marc-André Lemburg23481142000-06-08 17:49:41 +000050 CHAR_MAX = 127
51 LC_ALL = 6
52 LC_COLLATE = 3
53 LC_CTYPE = 0
54 LC_MESSAGES = 5
55 LC_MONETARY = 4
56 LC_NUMERIC = 1
57 LC_TIME = 2
58 Error = ValueError
59
60 def localeconv():
Fredrik Lundh6c86b992000-07-09 17:12:58 +000061 """ localeconv() -> dict.
Marc-André Lemburg23481142000-06-08 17:49:41 +000062 Returns numeric and monetary locale-specific parameters.
63 """
64 # 'C' locale default values
65 return {'grouping': [127],
66 'currency_symbol': '',
67 'n_sign_posn': 127,
Fredrik Lundh6c86b992000-07-09 17:12:58 +000068 'p_cs_precedes': 127,
69 'n_cs_precedes': 127,
70 'mon_grouping': [],
Marc-André Lemburg23481142000-06-08 17:49:41 +000071 'n_sep_by_space': 127,
72 'decimal_point': '.',
73 'negative_sign': '',
74 'positive_sign': '',
Fredrik Lundh6c86b992000-07-09 17:12:58 +000075 'p_sep_by_space': 127,
Marc-André Lemburg23481142000-06-08 17:49:41 +000076 'int_curr_symbol': '',
Fredrik Lundh6c86b992000-07-09 17:12:58 +000077 'p_sign_posn': 127,
Marc-André Lemburg23481142000-06-08 17:49:41 +000078 'thousands_sep': '',
Fredrik Lundh6c86b992000-07-09 17:12:58 +000079 'mon_thousands_sep': '',
80 'frac_digits': 127,
Marc-André Lemburg23481142000-06-08 17:49:41 +000081 'mon_decimal_point': '',
82 'int_frac_digits': 127}
Fredrik Lundh6c86b992000-07-09 17:12:58 +000083
Marc-André Lemburg23481142000-06-08 17:49:41 +000084 def setlocale(category, value=None):
Fredrik Lundh6c86b992000-07-09 17:12:58 +000085 """ setlocale(integer,string=None) -> string.
Marc-André Lemburg23481142000-06-08 17:49:41 +000086 Activates/queries locale processing.
87 """
Martin v. Löwis103d6e72003-03-30 15:42:13 +000088 if value not in (None, '', 'C'):
Collin Winterce36ad82007-08-30 01:19:48 +000089 raise Error('_locale emulation only supports "C" locale')
Marc-André Lemburg23481142000-06-08 17:49:41 +000090 return 'C'
91
Neal Norwitz48b98de2008-03-10 04:49:25 +000092# These may or may not exist in _locale, so be sure to set them.
93if 'strxfrm' not in globals():
94 strxfrm = _strxfrm
95if 'strcoll' not in globals():
96 strcoll = _strcoll
Marc-André Lemburg5431bc32000-06-07 09:11:40 +000097
Antoine Pitrou83d6a872008-07-25 21:45:08 +000098
99_localeconv = localeconv
100
101# With this dict, you can override some items of localeconv's return value.
102# This is useful for testing purposes.
103_override_localeconv = {}
104
105@functools.wraps(_localeconv)
106def localeconv():
107 d = _localeconv()
108 if _override_localeconv:
109 d.update(_override_localeconv)
110 return d
111
112
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000113### Number formatting APIs
114
115# Author: Martin von Loewis
Thomas Wouters477c8d52006-05-27 19:21:47 +0000116# improved by Georg Brandl
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000117
118#perform the grouping from right to left
Thomas Wouters477c8d52006-05-27 19:21:47 +0000119def _group(s, monetary=False):
120 conv = localeconv()
121 thousands_sep = conv[monetary and 'mon_thousands_sep' or 'thousands_sep']
122 grouping = conv[monetary and 'mon_grouping' or 'grouping']
123 if not grouping:
124 return (s, 0)
125 result = ""
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000126 seps = 0
127 spaces = ""
128 if s[-1] == ' ':
129 sp = s.find(' ')
130 spaces = s[sp:]
131 s = s[:sp]
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000132 while s and grouping:
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000133 # if grouping is -1, we are done
Thomas Wouters477c8d52006-05-27 19:21:47 +0000134 if grouping[0] == CHAR_MAX:
Guido van Rossum45e2fbc1998-03-26 21:13:24 +0000135 break
136 # 0: re-use last group ad infinitum
Thomas Wouters477c8d52006-05-27 19:21:47 +0000137 elif grouping[0] != 0:
Guido van Rossum45e2fbc1998-03-26 21:13:24 +0000138 #process last group
Thomas Wouters477c8d52006-05-27 19:21:47 +0000139 group = grouping[0]
140 grouping = grouping[1:]
Guido van Rossum45e2fbc1998-03-26 21:13:24 +0000141 if result:
Thomas Wouters477c8d52006-05-27 19:21:47 +0000142 result = s[-group:] + thousands_sep + result
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000143 seps += 1
Guido van Rossum45e2fbc1998-03-26 21:13:24 +0000144 else:
Thomas Wouters477c8d52006-05-27 19:21:47 +0000145 result = s[-group:]
146 s = s[:-group]
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000147 if s and s[-1] not in "0123456789":
148 # the leading string is only spaces and signs
Thomas Wouters477c8d52006-05-27 19:21:47 +0000149 return s + result + spaces, seps
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000150 if not result:
Thomas Wouters477c8d52006-05-27 19:21:47 +0000151 return s + spaces, seps
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000152 if s:
Thomas Wouters477c8d52006-05-27 19:21:47 +0000153 result = s + thousands_sep + result
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000154 seps += 1
Thomas Wouters477c8d52006-05-27 19:21:47 +0000155 return result + spaces, seps
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000156
Thomas Wouters477c8d52006-05-27 19:21:47 +0000157def format(percent, value, grouping=False, monetary=False, *additional):
158 """Returns the locale-aware substitution of a %? specifier
159 (percent).
160
161 additional is for format strings which contain one or more
162 '*' modifiers."""
163 # this is only for one-percent-specifier strings and this should be checked
164 if percent[0] != '%':
165 raise ValueError("format() must be given exactly one %char "
166 "format specifier")
167 if additional:
168 formatted = percent % ((value,) + additional)
169 else:
170 formatted = percent % value
171 # floats and decimal ints need special action!
172 if percent[-1] in 'eEfFgG':
173 seps = 0
174 parts = formatted.split('.')
175 if grouping:
176 parts[0], seps = _group(parts[0], monetary=monetary)
177 decimal_point = localeconv()[monetary and 'mon_decimal_point'
178 or 'decimal_point']
179 formatted = decimal_point.join(parts)
180 while seps:
181 sp = formatted.find(' ')
182 if sp == -1: break
183 formatted = formatted[:sp] + formatted[sp+1:]
184 seps -= 1
185 elif percent[-1] in 'diu':
186 if grouping:
187 formatted = _group(formatted, monetary=monetary)[0]
188 return formatted
189
Raymond Hettinger89e12962009-01-26 02:09:03 +0000190import re, collections
Thomas Wouters477c8d52006-05-27 19:21:47 +0000191_percent_re = re.compile(r'%(?:\((?P<key>.*?)\))?'
192 r'(?P<modifiers>[-#0-9 +*.hlL]*?)[eEfFgGdiouxXcrs%]')
193
194def format_string(f, val, grouping=False):
195 """Formats a string in the same way that the % formatting would use,
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000196 but takes the current locale into account.
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000197 Grouping is applied if the third parameter is true."""
Thomas Wouters477c8d52006-05-27 19:21:47 +0000198 percents = list(_percent_re.finditer(f))
199 new_f = _percent_re.sub('%s', f)
200
201 if isinstance(val, tuple):
202 new_val = list(val)
203 i = 0
204 for perc in percents:
205 starcount = perc.group('modifiers').count('*')
206 new_val[i] = format(perc.group(), new_val[i], grouping, False, *new_val[i+1:i+1+starcount])
207 del new_val[i+1:i+1+starcount]
208 i += (1 + starcount)
209 val = tuple(new_val)
Raymond Hettinger89e12962009-01-26 02:09:03 +0000210 elif isinstance(val, collections.Mapping):
Thomas Wouters477c8d52006-05-27 19:21:47 +0000211 for perc in percents:
212 key = perc.group("key")
213 val[key] = format(perc.group(), val[key], grouping)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000214 else:
Thomas Wouters477c8d52006-05-27 19:21:47 +0000215 # val is a single value
216 val = format(percents[0].group(), val, grouping)
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000217
Thomas Wouters477c8d52006-05-27 19:21:47 +0000218 return new_f % val
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000219
Thomas Wouters477c8d52006-05-27 19:21:47 +0000220def currency(val, symbol=True, grouping=False, international=False):
221 """Formats val according to the currency settings
222 in the current locale."""
223 conv = localeconv()
224
225 # check for illegal values
226 digits = conv[international and 'int_frac_digits' or 'frac_digits']
227 if digits == 127:
228 raise ValueError("Currency formatting is not possible using "
229 "the 'C' locale.")
230
231 s = format('%%.%if' % digits, abs(val), grouping, monetary=True)
232 # '<' and '>' are markers if the sign must be inserted between symbol and value
233 s = '<' + s + '>'
234
235 if symbol:
236 smb = conv[international and 'int_curr_symbol' or 'currency_symbol']
237 precedes = conv[val<0 and 'n_cs_precedes' or 'p_cs_precedes']
238 separated = conv[val<0 and 'n_sep_by_space' or 'p_sep_by_space']
239
240 if precedes:
241 s = smb + (separated and ' ' or '') + s
242 else:
243 s = s + (separated and ' ' or '') + smb
244
245 sign_pos = conv[val<0 and 'n_sign_posn' or 'p_sign_posn']
246 sign = conv[val<0 and 'negative_sign' or 'positive_sign']
247
248 if sign_pos == 0:
249 s = '(' + s + ')'
250 elif sign_pos == 1:
251 s = sign + s
252 elif sign_pos == 2:
253 s = s + sign
254 elif sign_pos == 3:
255 s = s.replace('<', sign)
256 elif sign_pos == 4:
257 s = s.replace('>', sign)
258 else:
259 # the default if nothing specified;
260 # this should be the most fitting sign position
261 s = sign + s
262
263 return s.replace('<', '').replace('>', '')
Martin v. Löwisdb786872001-01-21 18:52:33 +0000264
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000265def str(val):
266 """Convert float to integer, taking the locale into account."""
Thomas Wouters477c8d52006-05-27 19:21:47 +0000267 return format("%.12g", val)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000268
Thomas Wouters477c8d52006-05-27 19:21:47 +0000269def atof(string, func=float):
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000270 "Parses a string as a float according to the locale settings."
271 #First, get rid of the grouping
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000272 ts = localeconv()['thousands_sep']
273 if ts:
Skip Montanaro249369c2004-04-10 16:39:32 +0000274 string = string.replace(ts, '')
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000275 #next, replace the decimal point with a dot
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000276 dd = localeconv()['decimal_point']
277 if dd:
Skip Montanaro249369c2004-04-10 16:39:32 +0000278 string = string.replace(dd, '.')
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000279 #finally, parse the string
Skip Montanaro249369c2004-04-10 16:39:32 +0000280 return func(string)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000281
282def atoi(str):
283 "Converts a string to an integer according to the locale settings."
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000284 return atof(str, int)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000285
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000286def _test():
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000287 setlocale(LC_ALL, "")
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000288 #do grouping
Thomas Wouters477c8d52006-05-27 19:21:47 +0000289 s1 = format("%d", 123456789,1)
Guido van Rossumbe19ed72007-02-09 05:37:30 +0000290 print(s1, "is", atoi(s1))
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000291 #standard formatting
Thomas Wouters477c8d52006-05-27 19:21:47 +0000292 s1 = str(3.14)
Guido van Rossumbe19ed72007-02-09 05:37:30 +0000293 print(s1, "is", atof(s1))
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000294
295### Locale name aliasing engine
296
297# Author: Marc-Andre Lemburg, mal@lemburg.com
Fredrik Lundh37a09822002-10-19 20:19:10 +0000298# Various tweaks by Fredrik Lundh <fredrik@pythonware.com>
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000299
300# store away the low-level version of setlocale (it's
301# overridden below)
302_setlocale = setlocale
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000303
304def normalize(localename):
305
306 """ Returns a normalized locale code for the given locale
307 name.
308
309 The returned locale code is formatted for use with
310 setlocale().
311
312 If normalization fails, the original name is returned
313 unchanged.
314
315 If the given encoding is not known, the function defaults to
316 the default encoding for the locale code just like setlocale()
317 does.
318
319 """
320 # Normalize the locale name and extract the encoding
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000321 fullname = localename.lower()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000322 if ':' in fullname:
323 # ':' is sometimes used as encoding delimiter.
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000324 fullname = fullname.replace(':', '.')
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000325 if '.' in fullname:
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000326 langname, encoding = fullname.split('.')[:2]
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000327 fullname = langname + '.' + encoding
328 else:
329 langname = fullname
330 encoding = ''
331
332 # First lookup: fullname (possibly with encoding)
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000333 norm_encoding = encoding.replace('-', '')
334 norm_encoding = norm_encoding.replace('_', '')
335 lookup_name = langname + '.' + encoding
336 code = locale_alias.get(lookup_name, None)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000337 if code is not None:
338 return code
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000339 #print 'first lookup failed'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000340
341 # Second try: langname (without encoding)
342 code = locale_alias.get(langname, None)
343 if code is not None:
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000344 #print 'langname lookup succeeded'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000345 if '.' in code:
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000346 langname, defenc = code.split('.')
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000347 else:
348 langname = code
349 defenc = ''
350 if encoding:
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000351 # Convert the encoding to a C lib compatible encoding string
352 norm_encoding = encodings.normalize_encoding(encoding)
353 #print 'norm encoding: %r' % norm_encoding
354 norm_encoding = encodings.aliases.aliases.get(norm_encoding,
355 norm_encoding)
356 #print 'aliased encoding: %r' % norm_encoding
357 encoding = locale_encoding_alias.get(norm_encoding,
358 norm_encoding)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000359 else:
360 encoding = defenc
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000361 #print 'found encoding %r' % encoding
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000362 if encoding:
363 return langname + '.' + encoding
364 else:
365 return langname
366
367 else:
368 return localename
369
370def _parse_localename(localename):
371
372 """ Parses the locale code for localename and returns the
373 result as tuple (language code, encoding).
374
375 The localename is normalized and passed through the locale
376 alias engine. A ValueError is raised in case the locale name
377 cannot be parsed.
378
379 The language code corresponds to RFC 1766. code and encoding
380 can be None in case the values cannot be determined or are
Jeremy Hyltona05e2932000-06-28 14:48:01 +0000381 unknown to this implementation.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000382
383 """
384 code = normalize(localename)
Georg Brandlb709c2c2006-01-20 09:07:35 +0000385 if '@' in code:
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000386 # Deal with locale modifiers
387 code, modifier = code.split('@')
388 if modifier == 'euro' and '.' not in code:
389 # Assume Latin-9 for @euro locales. This is bogus,
390 # since some systems may use other encodings for these
391 # locales. Also, we ignore other modifiers.
392 return code, 'iso-8859-15'
Tim Peters230a60c2002-11-09 05:08:07 +0000393
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000394 if '.' in code:
Raymond Hettinger346e67f2005-01-01 06:10:26 +0000395 return tuple(code.split('.')[:2])
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000396 elif code == 'C':
397 return None, None
Collin Winterce36ad82007-08-30 01:19:48 +0000398 raise ValueError('unknown locale: %s' % localename)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000399
400def _build_localename(localetuple):
401
402 """ Builds a locale code from the given tuple (language code,
403 encoding).
404
405 No aliasing or normalizing takes place.
406
407 """
408 language, encoding = localetuple
409 if language is None:
410 language = 'C'
411 if encoding is None:
412 return language
413 else:
414 return language + '.' + encoding
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000415
Matthias Klosef3f231f2005-09-20 07:02:49 +0000416def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000417
418 """ Tries to determine the default locale settings and returns
419 them as tuple (language code, encoding).
420
421 According to POSIX, a program which has not called
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000422 setlocale(LC_ALL, "") runs using the portable 'C' locale.
423 Calling setlocale(LC_ALL, "") lets it use the default locale as
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000424 defined by the LANG variable. Since we don't want to interfere
Thomas Wouters7e474022000-07-16 12:04:32 +0000425 with the current locale setting we thus emulate the behavior
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000426 in the way described above.
427
428 To maintain compatibility with other platforms, not only the
429 LANG variable is tested, but a list of variables given as
430 envvars parameter. The first found to be defined will be
431 used. envvars defaults to the search path used in GNU gettext;
432 it must always contain the variable name 'LANG'.
433
434 Except for the code 'C', the language code corresponds to RFC
435 1766. code and encoding can be None in case the values cannot
436 be determined.
437
438 """
Fredrik Lundh04661322000-07-09 23:16:10 +0000439
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000440 try:
441 # check if it's supported by the _locale module
442 import _locale
443 code, encoding = _locale._getdefaultlocale()
Fredrik Lundh04661322000-07-09 23:16:10 +0000444 except (ImportError, AttributeError):
445 pass
446 else:
Fredrik Lundh663809e2000-07-10 19:32:19 +0000447 # make sure the code/encoding values are valid
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000448 if sys.platform == "win32" and code and code[:2] == "0x":
449 # map windows language identifier to language name
450 code = windows_locale.get(int(code, 0))
Fredrik Lundh663809e2000-07-10 19:32:19 +0000451 # ...add other platform-specific processing here, if
452 # necessary...
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000453 return code, encoding
Fredrik Lundh04661322000-07-09 23:16:10 +0000454
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000455 # fall back on POSIX behaviour
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000456 import os
457 lookup = os.environ.get
458 for variable in envvars:
459 localename = lookup(variable,None)
Martin v. Löwisc8ae31d2004-07-26 12:45:18 +0000460 if localename:
Matthias Klosef3f231f2005-09-20 07:02:49 +0000461 if variable == 'LANGUAGE':
462 localename = localename.split(':')[0]
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000463 break
464 else:
465 localename = 'C'
466 return _parse_localename(localename)
467
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000468
469def getlocale(category=LC_CTYPE):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000470
471 """ Returns the current setting for the given locale category as
472 tuple (language code, encoding).
473
474 category may be one of the LC_* value except LC_ALL. It
475 defaults to LC_CTYPE.
476
477 Except for the code 'C', the language code corresponds to RFC
478 1766. code and encoding can be None in case the values cannot
479 be determined.
480
481 """
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000482 localename = _setlocale(category)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000483 if category == LC_ALL and ';' in localename:
Collin Winterce36ad82007-08-30 01:19:48 +0000484 raise TypeError('category LC_ALL is not supported')
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000485 return _parse_localename(localename)
486
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000487def setlocale(category, locale=None):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000488
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000489 """ Set the locale for the given category. The locale can be
490 a string, a locale tuple (language code, encoding), or None.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000491
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000492 Locale tuples are converted to strings the locale aliasing
493 engine. Locale strings are passed directly to the C lib.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000494
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000495 category may be given as one of the LC_* values.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000496
497 """
Guido van Rossum3172c5d2007-10-16 18:12:55 +0000498 if locale and not isinstance(locale, _builtin_str):
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000499 # convert to string
500 locale = normalize(_build_localename(locale))
501 return _setlocale(category, locale)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000502
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000503def resetlocale(category=LC_ALL):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000504
505 """ Sets the locale for category to the default setting.
506
507 The default setting is determined by calling
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000508 getdefaultlocale(). category defaults to LC_ALL.
509
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000510 """
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000511 _setlocale(category, _build_localename(getdefaultlocale()))
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000512
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000513if sys.platform in ('win32', 'darwin', 'mac'):
514 # On Win32, this will return the ANSI code page
515 # On the Mac, it should return the system encoding;
516 # it might return "ascii" instead
517 def getpreferredencoding(do_setlocale = True):
518 """Return the charset that the user is likely using."""
519 import _locale
Tim Petersa326f472002-11-05 03:49:09 +0000520 return _locale._getdefaultlocale()[1]
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000521else:
522 # On Unix, if CODESET is available, use that.
523 try:
524 CODESET
525 except NameError:
526 # Fall back to parsing environment variables :-(
527 def getpreferredencoding(do_setlocale = True):
528 """Return the charset that the user is likely using,
529 by looking at environment variables."""
Martin v. Löwis071ef772008-03-08 11:24:24 +0000530 res = getdefaultlocale()[1]
531 if res is None:
532 # LANG not set, default conservatively to ASCII
533 res = 'ascii'
534 return res
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000535 else:
536 def getpreferredencoding(do_setlocale = True):
537 """Return the charset that the user is likely using,
538 according to the system configuration."""
539 if do_setlocale:
540 oldloc = setlocale(LC_CTYPE)
541 setlocale(LC_CTYPE, "")
542 result = nl_langinfo(CODESET)
543 setlocale(LC_CTYPE, oldloc)
544 return result
545 else:
546 return nl_langinfo(CODESET)
Tim Peters230a60c2002-11-09 05:08:07 +0000547
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000548
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000549### Database
550#
551# The following data was extracted from the locale.alias file which
552# comes with X11 and then hand edited removing the explicit encoding
553# definitions and adding some more aliases. The file is usually
554# available as /usr/lib/X11/locale/locale.alias.
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000555#
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000556
557#
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000558# The local_encoding_alias table maps lowercase encoding alias names
559# to C locale encoding names (case-sensitive). Note that normalize()
560# first looks up the encoding in the encodings.aliases dictionary and
561# then applies this mapping to find the correct C lib name for the
562# encoding.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000563#
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000564locale_encoding_alias = {
565
566 # Mappings for non-standard encoding names used in locale names
567 '437': 'C',
568 'c': 'C',
569 'en': 'ISO8859-1',
570 'jis': 'JIS7',
571 'jis7': 'JIS7',
572 'ajec': 'eucJP',
573
574 # Mappings from Python codec names to C lib encoding names
575 'ascii': 'ISO8859-1',
576 'latin_1': 'ISO8859-1',
577 'iso8859_1': 'ISO8859-1',
578 'iso8859_10': 'ISO8859-10',
579 'iso8859_11': 'ISO8859-11',
580 'iso8859_13': 'ISO8859-13',
581 'iso8859_14': 'ISO8859-14',
582 'iso8859_15': 'ISO8859-15',
583 'iso8859_2': 'ISO8859-2',
584 'iso8859_3': 'ISO8859-3',
585 'iso8859_4': 'ISO8859-4',
586 'iso8859_5': 'ISO8859-5',
587 'iso8859_6': 'ISO8859-6',
588 'iso8859_7': 'ISO8859-7',
589 'iso8859_8': 'ISO8859-8',
590 'iso8859_9': 'ISO8859-9',
591 'iso2022_jp': 'JIS7',
592 'shift_jis': 'SJIS',
593 'tactis': 'TACTIS',
594 'euc_jp': 'eucJP',
595 'euc_kr': 'eucKR',
Marc-André Lemburgb4cebd42004-12-13 19:56:01 +0000596 'utf_8': 'UTF8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000597 'koi8_r': 'KOI8-R',
598 'koi8_u': 'KOI8-U',
599 # XXX This list is still incomplete. If you know more
600 # mappings, please file a bug report. Thanks.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000601}
602
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000603#
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000604# The locale_alias table maps lowercase alias names to C locale names
605# (case-sensitive). Encodings are always separated from the locale
606# name using a dot ('.'); they should only be given in case the
607# language name is needed to interpret the given encoding alias
608# correctly (CJK codes often have this need).
609#
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000610# Note that the normalize() function which uses this tables
611# removes '_' and '-' characters from the encoding part of the
612# locale name before doing the lookup. This saves a lot of
613# space in the table.
614#
615# MAL 2004-12-10:
616# Updated alias mapping to most recent locale.alias file
617# from X.org distribution using makelocalealias.py.
618#
619# These are the differences compared to the old mapping (Python 2.4
620# and older):
621#
622# updated 'bg' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
623# updated 'bg_bg' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
624# updated 'bulgarian' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
625# updated 'cz' -> 'cz_CZ.ISO8859-2' to 'cs_CZ.ISO8859-2'
626# updated 'cz_cz' -> 'cz_CZ.ISO8859-2' to 'cs_CZ.ISO8859-2'
627# updated 'czech' -> 'cs_CS.ISO8859-2' to 'cs_CZ.ISO8859-2'
628# updated 'dutch' -> 'nl_BE.ISO8859-1' to 'nl_NL.ISO8859-1'
629# updated 'et' -> 'et_EE.ISO8859-4' to 'et_EE.ISO8859-15'
630# updated 'et_ee' -> 'et_EE.ISO8859-4' to 'et_EE.ISO8859-15'
631# updated 'fi' -> 'fi_FI.ISO8859-1' to 'fi_FI.ISO8859-15'
632# updated 'fi_fi' -> 'fi_FI.ISO8859-1' to 'fi_FI.ISO8859-15'
633# updated 'iw' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
634# updated 'iw_il' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
635# updated 'japanese' -> 'ja_JP.SJIS' to 'ja_JP.eucJP'
636# updated 'lt' -> 'lt_LT.ISO8859-4' to 'lt_LT.ISO8859-13'
637# updated 'lv' -> 'lv_LV.ISO8859-4' to 'lv_LV.ISO8859-13'
638# updated 'sl' -> 'sl_CS.ISO8859-2' to 'sl_SI.ISO8859-2'
639# updated 'slovene' -> 'sl_CS.ISO8859-2' to 'sl_SI.ISO8859-2'
640# updated 'th_th' -> 'th_TH.TACTIS' to 'th_TH.ISO8859-11'
641# updated 'zh_cn' -> 'zh_CN.eucCN' to 'zh_CN.gb2312'
642# updated 'zh_cn.big5' -> 'zh_TW.eucTW' to 'zh_TW.big5'
643# updated 'zh_tw' -> 'zh_TW.eucTW' to 'zh_TW.big5'
644#
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000645# MAL 2008-05-30:
646# Updated alias mapping to most recent locale.alias file
647# from X.org distribution using makelocalealias.py.
648#
649# These are the differences compared to the old mapping (Python 2.5
650# and older):
651#
652# updated 'cs_cs.iso88592' -> 'cs_CZ.ISO8859-2' to 'cs_CS.ISO8859-2'
653# updated 'serbocroatian' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
654# updated 'sh' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
655# updated 'sh_hr.iso88592' -> 'sh_HR.ISO8859-2' to 'hr_HR.ISO8859-2'
656# updated 'sh_sp' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
657# updated 'sh_yu' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
658# updated 'sp' -> 'sp_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
659# updated 'sp_yu' -> 'sp_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
660# updated 'sr' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
661# updated 'sr@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
662# updated 'sr_sp' -> 'sr_SP.ISO8859-2' to 'sr_CS.ISO8859-2'
663# updated 'sr_yu' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
664# updated 'sr_yu.cp1251@cyrillic' -> 'sr_YU.CP1251' to 'sr_CS.CP1251'
665# updated 'sr_yu.iso88592' -> 'sr_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
666# updated 'sr_yu.iso88595' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
667# updated 'sr_yu.iso88595@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
668# updated 'sr_yu.microsoftcp1251@cyrillic' -> 'sr_YU.CP1251' to 'sr_CS.CP1251'
669# updated 'sr_yu.utf8@cyrillic' -> 'sr_YU.UTF-8' to 'sr_CS.UTF-8'
670# updated 'sr_yu@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
671
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000672locale_alias = {
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000673 'a3': 'a3_AZ.KOI8-C',
674 'a3_az': 'a3_AZ.KOI8-C',
675 'a3_az.koi8c': 'a3_AZ.KOI8-C',
676 'af': 'af_ZA.ISO8859-1',
677 'af_za': 'af_ZA.ISO8859-1',
678 'af_za.iso88591': 'af_ZA.ISO8859-1',
679 'am': 'am_ET.UTF-8',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000680 'am_et': 'am_ET.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000681 'american': 'en_US.ISO8859-1',
682 'american.iso88591': 'en_US.ISO8859-1',
683 'ar': 'ar_AA.ISO8859-6',
684 'ar_aa': 'ar_AA.ISO8859-6',
685 'ar_aa.iso88596': 'ar_AA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000686 'ar_ae': 'ar_AE.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000687 'ar_ae.iso88596': 'ar_AE.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000688 'ar_bh': 'ar_BH.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000689 'ar_bh.iso88596': 'ar_BH.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000690 'ar_dz': 'ar_DZ.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000691 'ar_dz.iso88596': 'ar_DZ.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000692 'ar_eg': 'ar_EG.ISO8859-6',
693 'ar_eg.iso88596': 'ar_EG.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000694 'ar_iq': 'ar_IQ.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000695 'ar_iq.iso88596': 'ar_IQ.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000696 'ar_jo': 'ar_JO.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000697 'ar_jo.iso88596': 'ar_JO.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000698 'ar_kw': 'ar_KW.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000699 'ar_kw.iso88596': 'ar_KW.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000700 'ar_lb': 'ar_LB.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000701 'ar_lb.iso88596': 'ar_LB.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000702 'ar_ly': 'ar_LY.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000703 'ar_ly.iso88596': 'ar_LY.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000704 'ar_ma': 'ar_MA.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000705 'ar_ma.iso88596': 'ar_MA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000706 'ar_om': 'ar_OM.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000707 'ar_om.iso88596': 'ar_OM.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000708 'ar_qa': 'ar_QA.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000709 'ar_qa.iso88596': 'ar_QA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000710 'ar_sa': 'ar_SA.ISO8859-6',
711 'ar_sa.iso88596': 'ar_SA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000712 'ar_sd': 'ar_SD.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000713 'ar_sd.iso88596': 'ar_SD.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000714 'ar_sy': 'ar_SY.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000715 'ar_sy.iso88596': 'ar_SY.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000716 'ar_tn': 'ar_TN.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000717 'ar_tn.iso88596': 'ar_TN.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000718 'ar_ye': 'ar_YE.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000719 'ar_ye.iso88596': 'ar_YE.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000720 'arabic': 'ar_AA.ISO8859-6',
721 'arabic.iso88596': 'ar_AA.ISO8859-6',
722 'az': 'az_AZ.ISO8859-9E',
723 'az_az': 'az_AZ.ISO8859-9E',
724 'az_az.iso88599e': 'az_AZ.ISO8859-9E',
725 'be': 'be_BY.CP1251',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000726 'be_by': 'be_BY.CP1251',
727 'be_by.cp1251': 'be_BY.CP1251',
728 'be_by.microsoftcp1251': 'be_BY.CP1251',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000729 'bg': 'bg_BG.CP1251',
730 'bg_bg': 'bg_BG.CP1251',
731 'bg_bg.cp1251': 'bg_BG.CP1251',
732 'bg_bg.iso88595': 'bg_BG.ISO8859-5',
733 'bg_bg.koi8r': 'bg_BG.KOI8-R',
734 'bg_bg.microsoftcp1251': 'bg_BG.CP1251',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000735 'bn_in': 'bn_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000736 'bokmal': 'nb_NO.ISO8859-1',
737 'bokm\xe5l': 'nb_NO.ISO8859-1',
738 'br': 'br_FR.ISO8859-1',
739 'br_fr': 'br_FR.ISO8859-1',
740 'br_fr.iso88591': 'br_FR.ISO8859-1',
741 'br_fr.iso885914': 'br_FR.ISO8859-14',
742 'br_fr.iso885915': 'br_FR.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000743 'br_fr.iso885915@euro': 'br_FR.ISO8859-15',
744 'br_fr.utf8@euro': 'br_FR.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000745 'br_fr@euro': 'br_FR.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000746 'bs': 'bs_BA.ISO8859-2',
747 'bs_ba': 'bs_BA.ISO8859-2',
748 'bs_ba.iso88592': 'bs_BA.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000749 'bulgarian': 'bg_BG.CP1251',
750 'c': 'C',
751 'c-french': 'fr_CA.ISO8859-1',
752 'c-french.iso88591': 'fr_CA.ISO8859-1',
753 'c.en': 'C',
754 'c.iso88591': 'en_US.ISO8859-1',
755 'c_c': 'C',
756 'c_c.c': 'C',
757 'ca': 'ca_ES.ISO8859-1',
758 'ca_es': 'ca_ES.ISO8859-1',
759 'ca_es.iso88591': 'ca_ES.ISO8859-1',
760 'ca_es.iso885915': 'ca_ES.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000761 'ca_es.iso885915@euro': 'ca_ES.ISO8859-15',
762 'ca_es.utf8@euro': 'ca_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000763 'ca_es@euro': 'ca_ES.ISO8859-15',
764 'catalan': 'ca_ES.ISO8859-1',
765 'cextend': 'en_US.ISO8859-1',
766 'cextend.en': 'en_US.ISO8859-1',
767 'chinese-s': 'zh_CN.eucCN',
768 'chinese-t': 'zh_TW.eucTW',
769 'croatian': 'hr_HR.ISO8859-2',
770 'cs': 'cs_CZ.ISO8859-2',
771 'cs_cs': 'cs_CZ.ISO8859-2',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000772 'cs_cs.iso88592': 'cs_CS.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000773 'cs_cz': 'cs_CZ.ISO8859-2',
774 'cs_cz.iso88592': 'cs_CZ.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000775 'cy': 'cy_GB.ISO8859-1',
776 'cy_gb': 'cy_GB.ISO8859-1',
777 'cy_gb.iso88591': 'cy_GB.ISO8859-1',
778 'cy_gb.iso885914': 'cy_GB.ISO8859-14',
779 'cy_gb.iso885915': 'cy_GB.ISO8859-15',
780 'cy_gb@euro': 'cy_GB.ISO8859-15',
781 'cz': 'cs_CZ.ISO8859-2',
782 'cz_cz': 'cs_CZ.ISO8859-2',
783 'czech': 'cs_CZ.ISO8859-2',
784 'da': 'da_DK.ISO8859-1',
785 'da_dk': 'da_DK.ISO8859-1',
786 'da_dk.88591': 'da_DK.ISO8859-1',
787 'da_dk.885915': 'da_DK.ISO8859-15',
788 'da_dk.iso88591': 'da_DK.ISO8859-1',
789 'da_dk.iso885915': 'da_DK.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000790 'da_dk@euro': 'da_DK.ISO8859-15',
791 'danish': 'da_DK.ISO8859-1',
792 'danish.iso88591': 'da_DK.ISO8859-1',
793 'dansk': 'da_DK.ISO8859-1',
794 'de': 'de_DE.ISO8859-1',
795 'de_at': 'de_AT.ISO8859-1',
796 'de_at.iso88591': 'de_AT.ISO8859-1',
797 'de_at.iso885915': 'de_AT.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000798 'de_at.iso885915@euro': 'de_AT.ISO8859-15',
799 'de_at.utf8@euro': 'de_AT.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000800 'de_at@euro': 'de_AT.ISO8859-15',
801 'de_be': 'de_BE.ISO8859-1',
802 'de_be.iso88591': 'de_BE.ISO8859-1',
803 'de_be.iso885915': 'de_BE.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000804 'de_be.iso885915@euro': 'de_BE.ISO8859-15',
805 'de_be.utf8@euro': 'de_BE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000806 'de_be@euro': 'de_BE.ISO8859-15',
807 'de_ch': 'de_CH.ISO8859-1',
808 'de_ch.iso88591': 'de_CH.ISO8859-1',
809 'de_ch.iso885915': 'de_CH.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000810 'de_ch@euro': 'de_CH.ISO8859-15',
811 'de_de': 'de_DE.ISO8859-1',
812 'de_de.88591': 'de_DE.ISO8859-1',
813 'de_de.885915': 'de_DE.ISO8859-15',
814 'de_de.885915@euro': 'de_DE.ISO8859-15',
815 'de_de.iso88591': 'de_DE.ISO8859-1',
816 'de_de.iso885915': 'de_DE.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000817 'de_de.iso885915@euro': 'de_DE.ISO8859-15',
818 'de_de.utf8@euro': 'de_DE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000819 'de_de@euro': 'de_DE.ISO8859-15',
820 'de_lu': 'de_LU.ISO8859-1',
821 'de_lu.iso88591': 'de_LU.ISO8859-1',
822 'de_lu.iso885915': 'de_LU.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000823 'de_lu.iso885915@euro': 'de_LU.ISO8859-15',
824 'de_lu.utf8@euro': 'de_LU.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000825 'de_lu@euro': 'de_LU.ISO8859-15',
826 'deutsch': 'de_DE.ISO8859-1',
827 'dutch': 'nl_NL.ISO8859-1',
828 'dutch.iso88591': 'nl_BE.ISO8859-1',
829 'ee': 'ee_EE.ISO8859-4',
830 'ee_ee': 'ee_EE.ISO8859-4',
831 'ee_ee.iso88594': 'ee_EE.ISO8859-4',
832 'eesti': 'et_EE.ISO8859-1',
833 'el': 'el_GR.ISO8859-7',
834 'el_gr': 'el_GR.ISO8859-7',
835 'el_gr.iso88597': 'el_GR.ISO8859-7',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000836 'el_gr@euro': 'el_GR.ISO8859-15',
837 'en': 'en_US.ISO8859-1',
838 'en.iso88591': 'en_US.ISO8859-1',
839 'en_au': 'en_AU.ISO8859-1',
840 'en_au.iso88591': 'en_AU.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000841 'en_be': 'en_BE.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000842 'en_be@euro': 'en_BE.ISO8859-15',
843 'en_bw': 'en_BW.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000844 'en_bw.iso88591': 'en_BW.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000845 'en_ca': 'en_CA.ISO8859-1',
846 'en_ca.iso88591': 'en_CA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000847 'en_gb': 'en_GB.ISO8859-1',
848 'en_gb.88591': 'en_GB.ISO8859-1',
849 'en_gb.iso88591': 'en_GB.ISO8859-1',
850 'en_gb.iso885915': 'en_GB.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000851 'en_gb@euro': 'en_GB.ISO8859-15',
852 'en_hk': 'en_HK.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000853 'en_hk.iso88591': 'en_HK.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000854 'en_ie': 'en_IE.ISO8859-1',
855 'en_ie.iso88591': 'en_IE.ISO8859-1',
856 'en_ie.iso885915': 'en_IE.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000857 'en_ie.iso885915@euro': 'en_IE.ISO8859-15',
858 'en_ie.utf8@euro': 'en_IE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000859 'en_ie@euro': 'en_IE.ISO8859-15',
860 'en_in': 'en_IN.ISO8859-1',
861 'en_nz': 'en_NZ.ISO8859-1',
862 'en_nz.iso88591': 'en_NZ.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000863 'en_ph': 'en_PH.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000864 'en_ph.iso88591': 'en_PH.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000865 'en_sg': 'en_SG.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000866 'en_sg.iso88591': 'en_SG.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000867 'en_uk': 'en_GB.ISO8859-1',
868 'en_us': 'en_US.ISO8859-1',
869 'en_us.88591': 'en_US.ISO8859-1',
870 'en_us.885915': 'en_US.ISO8859-15',
871 'en_us.iso88591': 'en_US.ISO8859-1',
872 'en_us.iso885915': 'en_US.ISO8859-15',
873 'en_us.iso885915@euro': 'en_US.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000874 'en_us@euro': 'en_US.ISO8859-15',
875 'en_us@euro@euro': 'en_US.ISO8859-15',
876 'en_za': 'en_ZA.ISO8859-1',
877 'en_za.88591': 'en_ZA.ISO8859-1',
878 'en_za.iso88591': 'en_ZA.ISO8859-1',
879 'en_za.iso885915': 'en_ZA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000880 'en_za@euro': 'en_ZA.ISO8859-15',
881 'en_zw': 'en_ZW.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000882 'en_zw.iso88591': 'en_ZW.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000883 'eng_gb': 'en_GB.ISO8859-1',
884 'eng_gb.8859': 'en_GB.ISO8859-1',
885 'english': 'en_EN.ISO8859-1',
886 'english.iso88591': 'en_EN.ISO8859-1',
887 'english_uk': 'en_GB.ISO8859-1',
888 'english_uk.8859': 'en_GB.ISO8859-1',
889 'english_united-states': 'en_US.ISO8859-1',
890 'english_united-states.437': 'C',
891 'english_us': 'en_US.ISO8859-1',
892 'english_us.8859': 'en_US.ISO8859-1',
893 'english_us.ascii': 'en_US.ISO8859-1',
894 'eo': 'eo_XX.ISO8859-3',
895 'eo_eo': 'eo_EO.ISO8859-3',
896 'eo_eo.iso88593': 'eo_EO.ISO8859-3',
897 'eo_xx': 'eo_XX.ISO8859-3',
898 'eo_xx.iso88593': 'eo_XX.ISO8859-3',
899 'es': 'es_ES.ISO8859-1',
900 'es_ar': 'es_AR.ISO8859-1',
901 'es_ar.iso88591': 'es_AR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000902 'es_bo': 'es_BO.ISO8859-1',
903 'es_bo.iso88591': 'es_BO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000904 'es_cl': 'es_CL.ISO8859-1',
905 'es_cl.iso88591': 'es_CL.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000906 'es_co': 'es_CO.ISO8859-1',
907 'es_co.iso88591': 'es_CO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000908 'es_cr': 'es_CR.ISO8859-1',
909 'es_cr.iso88591': 'es_CR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000910 'es_do': 'es_DO.ISO8859-1',
911 'es_do.iso88591': 'es_DO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000912 'es_ec': 'es_EC.ISO8859-1',
913 'es_ec.iso88591': 'es_EC.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000914 'es_es': 'es_ES.ISO8859-1',
915 'es_es.88591': 'es_ES.ISO8859-1',
916 'es_es.iso88591': 'es_ES.ISO8859-1',
917 'es_es.iso885915': 'es_ES.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000918 'es_es.iso885915@euro': 'es_ES.ISO8859-15',
919 'es_es.utf8@euro': 'es_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000920 'es_es@euro': 'es_ES.ISO8859-15',
921 'es_gt': 'es_GT.ISO8859-1',
922 'es_gt.iso88591': 'es_GT.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000923 'es_hn': 'es_HN.ISO8859-1',
924 'es_hn.iso88591': 'es_HN.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000925 'es_mx': 'es_MX.ISO8859-1',
926 'es_mx.iso88591': 'es_MX.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000927 'es_ni': 'es_NI.ISO8859-1',
928 'es_ni.iso88591': 'es_NI.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000929 'es_pa': 'es_PA.ISO8859-1',
930 'es_pa.iso88591': 'es_PA.ISO8859-1',
931 'es_pa.iso885915': 'es_PA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000932 'es_pa@euro': 'es_PA.ISO8859-15',
933 'es_pe': 'es_PE.ISO8859-1',
934 'es_pe.iso88591': 'es_PE.ISO8859-1',
935 'es_pe.iso885915': 'es_PE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000936 'es_pe@euro': 'es_PE.ISO8859-15',
937 'es_pr': 'es_PR.ISO8859-1',
938 'es_pr.iso88591': 'es_PR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000939 'es_py': 'es_PY.ISO8859-1',
940 'es_py.iso88591': 'es_PY.ISO8859-1',
941 'es_py.iso885915': 'es_PY.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000942 'es_py@euro': 'es_PY.ISO8859-15',
943 'es_sv': 'es_SV.ISO8859-1',
944 'es_sv.iso88591': 'es_SV.ISO8859-1',
945 'es_sv.iso885915': 'es_SV.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000946 'es_sv@euro': 'es_SV.ISO8859-15',
947 'es_us': 'es_US.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000948 'es_us.iso88591': 'es_US.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000949 'es_uy': 'es_UY.ISO8859-1',
950 'es_uy.iso88591': 'es_UY.ISO8859-1',
951 'es_uy.iso885915': 'es_UY.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000952 'es_uy@euro': 'es_UY.ISO8859-15',
953 'es_ve': 'es_VE.ISO8859-1',
954 'es_ve.iso88591': 'es_VE.ISO8859-1',
955 'es_ve.iso885915': 'es_VE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000956 'es_ve@euro': 'es_VE.ISO8859-15',
957 'estonian': 'et_EE.ISO8859-1',
958 'et': 'et_EE.ISO8859-15',
959 'et_ee': 'et_EE.ISO8859-15',
960 'et_ee.iso88591': 'et_EE.ISO8859-1',
961 'et_ee.iso885913': 'et_EE.ISO8859-13',
962 'et_ee.iso885915': 'et_EE.ISO8859-15',
963 'et_ee.iso88594': 'et_EE.ISO8859-4',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000964 'et_ee@euro': 'et_EE.ISO8859-15',
965 'eu': 'eu_ES.ISO8859-1',
966 'eu_es': 'eu_ES.ISO8859-1',
967 'eu_es.iso88591': 'eu_ES.ISO8859-1',
968 'eu_es.iso885915': 'eu_ES.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000969 'eu_es.iso885915@euro': 'eu_ES.ISO8859-15',
970 'eu_es.utf8@euro': 'eu_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000971 'eu_es@euro': 'eu_ES.ISO8859-15',
972 'fa': 'fa_IR.UTF-8',
973 'fa_ir': 'fa_IR.UTF-8',
974 'fa_ir.isiri3342': 'fa_IR.ISIRI-3342',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000975 'fi': 'fi_FI.ISO8859-15',
976 'fi_fi': 'fi_FI.ISO8859-15',
977 'fi_fi.88591': 'fi_FI.ISO8859-1',
978 'fi_fi.iso88591': 'fi_FI.ISO8859-1',
979 'fi_fi.iso885915': 'fi_FI.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000980 'fi_fi.iso885915@euro': 'fi_FI.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000981 'fi_fi.utf8@euro': 'fi_FI.UTF-8',
982 'fi_fi@euro': 'fi_FI.ISO8859-15',
983 'finnish': 'fi_FI.ISO8859-1',
984 'finnish.iso88591': 'fi_FI.ISO8859-1',
985 'fo': 'fo_FO.ISO8859-1',
986 'fo_fo': 'fo_FO.ISO8859-1',
987 'fo_fo.iso88591': 'fo_FO.ISO8859-1',
988 'fo_fo.iso885915': 'fo_FO.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000989 'fo_fo@euro': 'fo_FO.ISO8859-15',
990 'fr': 'fr_FR.ISO8859-1',
991 'fr_be': 'fr_BE.ISO8859-1',
992 'fr_be.88591': 'fr_BE.ISO8859-1',
993 'fr_be.iso88591': 'fr_BE.ISO8859-1',
994 'fr_be.iso885915': 'fr_BE.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000995 'fr_be.iso885915@euro': 'fr_BE.ISO8859-15',
996 'fr_be.utf8@euro': 'fr_BE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000997 'fr_be@euro': 'fr_BE.ISO8859-15',
998 'fr_ca': 'fr_CA.ISO8859-1',
999 'fr_ca.88591': 'fr_CA.ISO8859-1',
1000 'fr_ca.iso88591': 'fr_CA.ISO8859-1',
1001 'fr_ca.iso885915': 'fr_CA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001002 'fr_ca@euro': 'fr_CA.ISO8859-15',
1003 'fr_ch': 'fr_CH.ISO8859-1',
1004 'fr_ch.88591': 'fr_CH.ISO8859-1',
1005 'fr_ch.iso88591': 'fr_CH.ISO8859-1',
1006 'fr_ch.iso885915': 'fr_CH.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001007 'fr_ch@euro': 'fr_CH.ISO8859-15',
1008 'fr_fr': 'fr_FR.ISO8859-1',
1009 'fr_fr.88591': 'fr_FR.ISO8859-1',
1010 'fr_fr.iso88591': 'fr_FR.ISO8859-1',
1011 'fr_fr.iso885915': 'fr_FR.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001012 'fr_fr.iso885915@euro': 'fr_FR.ISO8859-15',
1013 'fr_fr.utf8@euro': 'fr_FR.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001014 'fr_fr@euro': 'fr_FR.ISO8859-15',
1015 'fr_lu': 'fr_LU.ISO8859-1',
1016 'fr_lu.88591': 'fr_LU.ISO8859-1',
1017 'fr_lu.iso88591': 'fr_LU.ISO8859-1',
1018 'fr_lu.iso885915': 'fr_LU.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001019 'fr_lu.iso885915@euro': 'fr_LU.ISO8859-15',
1020 'fr_lu.utf8@euro': 'fr_LU.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001021 'fr_lu@euro': 'fr_LU.ISO8859-15',
1022 'fran\xe7ais': 'fr_FR.ISO8859-1',
1023 'fre_fr': 'fr_FR.ISO8859-1',
1024 'fre_fr.8859': 'fr_FR.ISO8859-1',
1025 'french': 'fr_FR.ISO8859-1',
1026 'french.iso88591': 'fr_CH.ISO8859-1',
1027 'french_france': 'fr_FR.ISO8859-1',
1028 'french_france.8859': 'fr_FR.ISO8859-1',
1029 'ga': 'ga_IE.ISO8859-1',
1030 'ga_ie': 'ga_IE.ISO8859-1',
1031 'ga_ie.iso88591': 'ga_IE.ISO8859-1',
1032 'ga_ie.iso885914': 'ga_IE.ISO8859-14',
1033 'ga_ie.iso885915': 'ga_IE.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001034 'ga_ie.iso885915@euro': 'ga_IE.ISO8859-15',
1035 'ga_ie.utf8@euro': 'ga_IE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001036 'ga_ie@euro': 'ga_IE.ISO8859-15',
1037 'galego': 'gl_ES.ISO8859-1',
1038 'galician': 'gl_ES.ISO8859-1',
1039 'gd': 'gd_GB.ISO8859-1',
1040 'gd_gb': 'gd_GB.ISO8859-1',
1041 'gd_gb.iso88591': 'gd_GB.ISO8859-1',
1042 'gd_gb.iso885914': 'gd_GB.ISO8859-14',
1043 'gd_gb.iso885915': 'gd_GB.ISO8859-15',
1044 'gd_gb@euro': 'gd_GB.ISO8859-15',
1045 'ger_de': 'de_DE.ISO8859-1',
1046 'ger_de.8859': 'de_DE.ISO8859-1',
1047 'german': 'de_DE.ISO8859-1',
1048 'german.iso88591': 'de_CH.ISO8859-1',
1049 'german_germany': 'de_DE.ISO8859-1',
1050 'german_germany.8859': 'de_DE.ISO8859-1',
1051 'gl': 'gl_ES.ISO8859-1',
1052 'gl_es': 'gl_ES.ISO8859-1',
1053 'gl_es.iso88591': 'gl_ES.ISO8859-1',
1054 'gl_es.iso885915': 'gl_ES.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001055 'gl_es.iso885915@euro': 'gl_ES.ISO8859-15',
1056 'gl_es.utf8@euro': 'gl_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001057 'gl_es@euro': 'gl_ES.ISO8859-15',
1058 'greek': 'el_GR.ISO8859-7',
1059 'greek.iso88597': 'el_GR.ISO8859-7',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001060 'gu_in': 'gu_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001061 'gv': 'gv_GB.ISO8859-1',
1062 'gv_gb': 'gv_GB.ISO8859-1',
1063 'gv_gb.iso88591': 'gv_GB.ISO8859-1',
1064 'gv_gb.iso885914': 'gv_GB.ISO8859-14',
1065 'gv_gb.iso885915': 'gv_GB.ISO8859-15',
1066 'gv_gb@euro': 'gv_GB.ISO8859-15',
1067 'he': 'he_IL.ISO8859-8',
1068 'he_il': 'he_IL.ISO8859-8',
1069 'he_il.cp1255': 'he_IL.CP1255',
1070 'he_il.iso88598': 'he_IL.ISO8859-8',
1071 'he_il.microsoftcp1255': 'he_IL.CP1255',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001072 'hebrew': 'iw_IL.ISO8859-8',
1073 'hebrew.iso88598': 'iw_IL.ISO8859-8',
1074 'hi': 'hi_IN.ISCII-DEV',
1075 'hi_in': 'hi_IN.ISCII-DEV',
1076 'hi_in.isciidev': 'hi_IN.ISCII-DEV',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001077 'hr': 'hr_HR.ISO8859-2',
1078 'hr_hr': 'hr_HR.ISO8859-2',
1079 'hr_hr.iso88592': 'hr_HR.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001080 'hrvatski': 'hr_HR.ISO8859-2',
1081 'hu': 'hu_HU.ISO8859-2',
1082 'hu_hu': 'hu_HU.ISO8859-2',
1083 'hu_hu.iso88592': 'hu_HU.ISO8859-2',
1084 'hungarian': 'hu_HU.ISO8859-2',
1085 'icelandic': 'is_IS.ISO8859-1',
1086 'icelandic.iso88591': 'is_IS.ISO8859-1',
1087 'id': 'id_ID.ISO8859-1',
1088 'id_id': 'id_ID.ISO8859-1',
1089 'in': 'id_ID.ISO8859-1',
1090 'in_id': 'id_ID.ISO8859-1',
1091 'is': 'is_IS.ISO8859-1',
1092 'is_is': 'is_IS.ISO8859-1',
1093 'is_is.iso88591': 'is_IS.ISO8859-1',
1094 'is_is.iso885915': 'is_IS.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001095 'is_is@euro': 'is_IS.ISO8859-15',
1096 'iso-8859-1': 'en_US.ISO8859-1',
1097 'iso-8859-15': 'en_US.ISO8859-15',
1098 'iso8859-1': 'en_US.ISO8859-1',
1099 'iso8859-15': 'en_US.ISO8859-15',
1100 'iso_8859_1': 'en_US.ISO8859-1',
1101 'iso_8859_15': 'en_US.ISO8859-15',
1102 'it': 'it_IT.ISO8859-1',
1103 'it_ch': 'it_CH.ISO8859-1',
1104 'it_ch.iso88591': 'it_CH.ISO8859-1',
1105 'it_ch.iso885915': 'it_CH.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001106 'it_ch@euro': 'it_CH.ISO8859-15',
1107 'it_it': 'it_IT.ISO8859-1',
1108 'it_it.88591': 'it_IT.ISO8859-1',
1109 'it_it.iso88591': 'it_IT.ISO8859-1',
1110 'it_it.iso885915': 'it_IT.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001111 'it_it.iso885915@euro': 'it_IT.ISO8859-15',
1112 'it_it.utf8@euro': 'it_IT.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001113 'it_it@euro': 'it_IT.ISO8859-15',
1114 'italian': 'it_IT.ISO8859-1',
1115 'italian.iso88591': 'it_IT.ISO8859-1',
1116 'iu': 'iu_CA.NUNACOM-8',
1117 'iu_ca': 'iu_CA.NUNACOM-8',
1118 'iu_ca.nunacom8': 'iu_CA.NUNACOM-8',
1119 'iw': 'he_IL.ISO8859-8',
1120 'iw_il': 'he_IL.ISO8859-8',
1121 'iw_il.iso88598': 'he_IL.ISO8859-8',
1122 'ja': 'ja_JP.eucJP',
1123 'ja.jis': 'ja_JP.JIS7',
1124 'ja.sjis': 'ja_JP.SJIS',
1125 'ja_jp': 'ja_JP.eucJP',
1126 'ja_jp.ajec': 'ja_JP.eucJP',
1127 'ja_jp.euc': 'ja_JP.eucJP',
1128 'ja_jp.eucjp': 'ja_JP.eucJP',
1129 'ja_jp.iso-2022-jp': 'ja_JP.JIS7',
1130 'ja_jp.iso2022jp': 'ja_JP.JIS7',
1131 'ja_jp.jis': 'ja_JP.JIS7',
1132 'ja_jp.jis7': 'ja_JP.JIS7',
1133 'ja_jp.mscode': 'ja_JP.SJIS',
1134 'ja_jp.sjis': 'ja_JP.SJIS',
1135 'ja_jp.ujis': 'ja_JP.eucJP',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001136 'japan': 'ja_JP.eucJP',
1137 'japanese': 'ja_JP.eucJP',
1138 'japanese-euc': 'ja_JP.eucJP',
1139 'japanese.euc': 'ja_JP.eucJP',
1140 'japanese.sjis': 'ja_JP.SJIS',
1141 'jp_jp': 'ja_JP.eucJP',
1142 'ka': 'ka_GE.GEORGIAN-ACADEMY',
1143 'ka_ge': 'ka_GE.GEORGIAN-ACADEMY',
1144 'ka_ge.georgianacademy': 'ka_GE.GEORGIAN-ACADEMY',
1145 'ka_ge.georgianps': 'ka_GE.GEORGIAN-PS',
1146 'ka_ge.georgianrs': 'ka_GE.GEORGIAN-ACADEMY',
1147 'kl': 'kl_GL.ISO8859-1',
1148 'kl_gl': 'kl_GL.ISO8859-1',
1149 'kl_gl.iso88591': 'kl_GL.ISO8859-1',
1150 'kl_gl.iso885915': 'kl_GL.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001151 'kl_gl@euro': 'kl_GL.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001152 'km_kh': 'km_KH.UTF-8',
1153 'kn_in': 'kn_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001154 'ko': 'ko_KR.eucKR',
1155 'ko_kr': 'ko_KR.eucKR',
1156 'ko_kr.euc': 'ko_KR.eucKR',
1157 'ko_kr.euckr': 'ko_KR.eucKR',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001158 'korean': 'ko_KR.eucKR',
1159 'korean.euc': 'ko_KR.eucKR',
1160 'kw': 'kw_GB.ISO8859-1',
1161 'kw_gb': 'kw_GB.ISO8859-1',
1162 'kw_gb.iso88591': 'kw_GB.ISO8859-1',
1163 'kw_gb.iso885914': 'kw_GB.ISO8859-14',
1164 'kw_gb.iso885915': 'kw_GB.ISO8859-15',
1165 'kw_gb@euro': 'kw_GB.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001166 'ky': 'ky_KG.UTF-8',
1167 'ky_kg': 'ky_KG.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001168 'lithuanian': 'lt_LT.ISO8859-13',
1169 'lo': 'lo_LA.MULELAO-1',
1170 'lo_la': 'lo_LA.MULELAO-1',
1171 'lo_la.cp1133': 'lo_LA.IBM-CP1133',
1172 'lo_la.ibmcp1133': 'lo_LA.IBM-CP1133',
1173 'lo_la.mulelao1': 'lo_LA.MULELAO-1',
1174 'lt': 'lt_LT.ISO8859-13',
1175 'lt_lt': 'lt_LT.ISO8859-13',
1176 'lt_lt.iso885913': 'lt_LT.ISO8859-13',
1177 'lt_lt.iso88594': 'lt_LT.ISO8859-4',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001178 'lv': 'lv_LV.ISO8859-13',
1179 'lv_lv': 'lv_LV.ISO8859-13',
1180 'lv_lv.iso885913': 'lv_LV.ISO8859-13',
1181 'lv_lv.iso88594': 'lv_LV.ISO8859-4',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001182 'mi': 'mi_NZ.ISO8859-1',
1183 'mi_nz': 'mi_NZ.ISO8859-1',
1184 'mi_nz.iso88591': 'mi_NZ.ISO8859-1',
1185 'mk': 'mk_MK.ISO8859-5',
1186 'mk_mk': 'mk_MK.ISO8859-5',
1187 'mk_mk.cp1251': 'mk_MK.CP1251',
1188 'mk_mk.iso88595': 'mk_MK.ISO8859-5',
1189 'mk_mk.microsoftcp1251': 'mk_MK.CP1251',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001190 'mr_in': 'mr_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001191 'ms': 'ms_MY.ISO8859-1',
1192 'ms_my': 'ms_MY.ISO8859-1',
1193 'ms_my.iso88591': 'ms_MY.ISO8859-1',
1194 'mt': 'mt_MT.ISO8859-3',
1195 'mt_mt': 'mt_MT.ISO8859-3',
1196 'mt_mt.iso88593': 'mt_MT.ISO8859-3',
1197 'nb': 'nb_NO.ISO8859-1',
1198 'nb_no': 'nb_NO.ISO8859-1',
1199 'nb_no.88591': 'nb_NO.ISO8859-1',
1200 'nb_no.iso88591': 'nb_NO.ISO8859-1',
1201 'nb_no.iso885915': 'nb_NO.ISO8859-15',
1202 'nb_no@euro': 'nb_NO.ISO8859-15',
1203 'nl': 'nl_NL.ISO8859-1',
1204 'nl_be': 'nl_BE.ISO8859-1',
1205 'nl_be.88591': 'nl_BE.ISO8859-1',
1206 'nl_be.iso88591': 'nl_BE.ISO8859-1',
1207 'nl_be.iso885915': 'nl_BE.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001208 'nl_be.iso885915@euro': 'nl_BE.ISO8859-15',
1209 'nl_be.utf8@euro': 'nl_BE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001210 'nl_be@euro': 'nl_BE.ISO8859-15',
1211 'nl_nl': 'nl_NL.ISO8859-1',
1212 'nl_nl.88591': 'nl_NL.ISO8859-1',
1213 'nl_nl.iso88591': 'nl_NL.ISO8859-1',
1214 'nl_nl.iso885915': 'nl_NL.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001215 'nl_nl.iso885915@euro': 'nl_NL.ISO8859-15',
1216 'nl_nl.utf8@euro': 'nl_NL.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001217 'nl_nl@euro': 'nl_NL.ISO8859-15',
1218 'nn': 'nn_NO.ISO8859-1',
1219 'nn_no': 'nn_NO.ISO8859-1',
1220 'nn_no.88591': 'nn_NO.ISO8859-1',
1221 'nn_no.iso88591': 'nn_NO.ISO8859-1',
1222 'nn_no.iso885915': 'nn_NO.ISO8859-15',
1223 'nn_no@euro': 'nn_NO.ISO8859-15',
1224 'no': 'no_NO.ISO8859-1',
1225 'no@nynorsk': 'ny_NO.ISO8859-1',
1226 'no_no': 'no_NO.ISO8859-1',
1227 'no_no.88591': 'no_NO.ISO8859-1',
1228 'no_no.iso88591': 'no_NO.ISO8859-1',
1229 'no_no.iso885915': 'no_NO.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001230 'no_no@euro': 'no_NO.ISO8859-15',
1231 'norwegian': 'no_NO.ISO8859-1',
1232 'norwegian.iso88591': 'no_NO.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001233 'nr': 'nr_ZA.ISO8859-1',
1234 'nr_za': 'nr_ZA.ISO8859-1',
1235 'nr_za.iso88591': 'nr_ZA.ISO8859-1',
1236 'nso': 'nso_ZA.ISO8859-15',
1237 'nso_za': 'nso_ZA.ISO8859-15',
1238 'nso_za.iso885915': 'nso_ZA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001239 'ny': 'ny_NO.ISO8859-1',
1240 'ny_no': 'ny_NO.ISO8859-1',
1241 'ny_no.88591': 'ny_NO.ISO8859-1',
1242 'ny_no.iso88591': 'ny_NO.ISO8859-1',
1243 'ny_no.iso885915': 'ny_NO.ISO8859-15',
1244 'ny_no@euro': 'ny_NO.ISO8859-15',
1245 'nynorsk': 'nn_NO.ISO8859-1',
1246 'oc': 'oc_FR.ISO8859-1',
1247 'oc_fr': 'oc_FR.ISO8859-1',
1248 'oc_fr.iso88591': 'oc_FR.ISO8859-1',
1249 'oc_fr.iso885915': 'oc_FR.ISO8859-15',
1250 'oc_fr@euro': 'oc_FR.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001251 'pa_in': 'pa_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001252 'pd': 'pd_US.ISO8859-1',
1253 'pd_de': 'pd_DE.ISO8859-1',
1254 'pd_de.iso88591': 'pd_DE.ISO8859-1',
1255 'pd_de.iso885915': 'pd_DE.ISO8859-15',
1256 'pd_de@euro': 'pd_DE.ISO8859-15',
1257 'pd_us': 'pd_US.ISO8859-1',
1258 'pd_us.iso88591': 'pd_US.ISO8859-1',
1259 'pd_us.iso885915': 'pd_US.ISO8859-15',
1260 'pd_us@euro': 'pd_US.ISO8859-15',
1261 'ph': 'ph_PH.ISO8859-1',
1262 'ph_ph': 'ph_PH.ISO8859-1',
1263 'ph_ph.iso88591': 'ph_PH.ISO8859-1',
1264 'pl': 'pl_PL.ISO8859-2',
1265 'pl_pl': 'pl_PL.ISO8859-2',
1266 'pl_pl.iso88592': 'pl_PL.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001267 'polish': 'pl_PL.ISO8859-2',
1268 'portuguese': 'pt_PT.ISO8859-1',
1269 'portuguese.iso88591': 'pt_PT.ISO8859-1',
1270 'portuguese_brazil': 'pt_BR.ISO8859-1',
1271 'portuguese_brazil.8859': 'pt_BR.ISO8859-1',
1272 'posix': 'C',
1273 'posix-utf2': 'C',
1274 'pp': 'pp_AN.ISO8859-1',
1275 'pp_an': 'pp_AN.ISO8859-1',
1276 'pp_an.iso88591': 'pp_AN.ISO8859-1',
1277 'pt': 'pt_PT.ISO8859-1',
1278 'pt_br': 'pt_BR.ISO8859-1',
1279 'pt_br.88591': 'pt_BR.ISO8859-1',
1280 'pt_br.iso88591': 'pt_BR.ISO8859-1',
1281 'pt_br.iso885915': 'pt_BR.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001282 'pt_br@euro': 'pt_BR.ISO8859-15',
1283 'pt_pt': 'pt_PT.ISO8859-1',
1284 'pt_pt.88591': 'pt_PT.ISO8859-1',
1285 'pt_pt.iso88591': 'pt_PT.ISO8859-1',
1286 'pt_pt.iso885915': 'pt_PT.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001287 'pt_pt.iso885915@euro': 'pt_PT.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001288 'pt_pt.utf8@euro': 'pt_PT.UTF-8',
1289 'pt_pt@euro': 'pt_PT.ISO8859-15',
1290 'ro': 'ro_RO.ISO8859-2',
1291 'ro_ro': 'ro_RO.ISO8859-2',
1292 'ro_ro.iso88592': 'ro_RO.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001293 'romanian': 'ro_RO.ISO8859-2',
1294 'ru': 'ru_RU.ISO8859-5',
1295 'ru_ru': 'ru_RU.ISO8859-5',
1296 'ru_ru.cp1251': 'ru_RU.CP1251',
1297 'ru_ru.iso88595': 'ru_RU.ISO8859-5',
1298 'ru_ru.koi8r': 'ru_RU.KOI8-R',
1299 'ru_ru.microsoftcp1251': 'ru_RU.CP1251',
1300 'ru_ua': 'ru_UA.KOI8-U',
1301 'ru_ua.cp1251': 'ru_UA.CP1251',
1302 'ru_ua.koi8u': 'ru_UA.KOI8-U',
1303 'ru_ua.microsoftcp1251': 'ru_UA.CP1251',
1304 'rumanian': 'ro_RO.ISO8859-2',
1305 'russian': 'ru_RU.ISO8859-5',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001306 'rw': 'rw_RW.ISO8859-1',
1307 'rw_rw': 'rw_RW.ISO8859-1',
1308 'rw_rw.iso88591': 'rw_RW.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001309 'se_no': 'se_NO.UTF-8',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001310 'serbocroatian': 'sr_CS.ISO8859-2',
1311 'sh': 'sr_CS.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001312 'sh_hr': 'sh_HR.ISO8859-2',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001313 'sh_hr.iso88592': 'hr_HR.ISO8859-2',
1314 'sh_sp': 'sr_CS.ISO8859-2',
1315 'sh_yu': 'sr_CS.ISO8859-2',
1316 'si': 'si_LK.UTF-8',
1317 'si_lk': 'si_LK.UTF-8',
1318 'sinhala': 'si_LK.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001319 'sk': 'sk_SK.ISO8859-2',
1320 'sk_sk': 'sk_SK.ISO8859-2',
1321 'sk_sk.iso88592': 'sk_SK.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001322 'sl': 'sl_SI.ISO8859-2',
1323 'sl_cs': 'sl_CS.ISO8859-2',
1324 'sl_si': 'sl_SI.ISO8859-2',
1325 'sl_si.iso88592': 'sl_SI.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001326 'slovak': 'sk_SK.ISO8859-2',
1327 'slovene': 'sl_SI.ISO8859-2',
1328 'slovenian': 'sl_SI.ISO8859-2',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001329 'sp': 'sr_CS.ISO8859-5',
1330 'sp_yu': 'sr_CS.ISO8859-5',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001331 'spanish': 'es_ES.ISO8859-1',
1332 'spanish.iso88591': 'es_ES.ISO8859-1',
1333 'spanish_spain': 'es_ES.ISO8859-1',
1334 'spanish_spain.8859': 'es_ES.ISO8859-1',
1335 'sq': 'sq_AL.ISO8859-2',
1336 'sq_al': 'sq_AL.ISO8859-2',
1337 'sq_al.iso88592': 'sq_AL.ISO8859-2',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001338 'sr': 'sr_CS.ISO8859-5',
1339 'sr@cyrillic': 'sr_CS.ISO8859-5',
1340 'sr@latn': 'sr_CS.ISO8859-2',
1341 'sr_cs.iso88592': 'sr_CS.ISO8859-2',
1342 'sr_cs.iso88592@latn': 'sr_CS.ISO8859-2',
1343 'sr_cs.iso88595': 'sr_CS.ISO8859-5',
1344 'sr_cs.utf8@latn': 'sr_CS.UTF-8',
1345 'sr_cs@latn': 'sr_CS.ISO8859-2',
1346 'sr_sp': 'sr_CS.ISO8859-2',
1347 'sr_yu': 'sr_CS.ISO8859-5',
1348 'sr_yu.cp1251@cyrillic': 'sr_CS.CP1251',
1349 'sr_yu.iso88592': 'sr_CS.ISO8859-2',
1350 'sr_yu.iso88595': 'sr_CS.ISO8859-5',
1351 'sr_yu.iso88595@cyrillic': 'sr_CS.ISO8859-5',
1352 'sr_yu.microsoftcp1251@cyrillic': 'sr_CS.CP1251',
1353 'sr_yu.utf8@cyrillic': 'sr_CS.UTF-8',
1354 'sr_yu@cyrillic': 'sr_CS.ISO8859-5',
1355 'ss': 'ss_ZA.ISO8859-1',
1356 'ss_za': 'ss_ZA.ISO8859-1',
1357 'ss_za.iso88591': 'ss_ZA.ISO8859-1',
1358 'st': 'st_ZA.ISO8859-1',
1359 'st_za': 'st_ZA.ISO8859-1',
1360 'st_za.iso88591': 'st_ZA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001361 'sv': 'sv_SE.ISO8859-1',
1362 'sv_fi': 'sv_FI.ISO8859-1',
1363 'sv_fi.iso88591': 'sv_FI.ISO8859-1',
1364 'sv_fi.iso885915': 'sv_FI.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001365 'sv_fi.iso885915@euro': 'sv_FI.ISO8859-15',
1366 'sv_fi.utf8@euro': 'sv_FI.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001367 'sv_fi@euro': 'sv_FI.ISO8859-15',
1368 'sv_se': 'sv_SE.ISO8859-1',
1369 'sv_se.88591': 'sv_SE.ISO8859-1',
1370 'sv_se.iso88591': 'sv_SE.ISO8859-1',
1371 'sv_se.iso885915': 'sv_SE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001372 'sv_se@euro': 'sv_SE.ISO8859-15',
1373 'swedish': 'sv_SE.ISO8859-1',
1374 'swedish.iso88591': 'sv_SE.ISO8859-1',
1375 'ta': 'ta_IN.TSCII-0',
1376 'ta_in': 'ta_IN.TSCII-0',
1377 'ta_in.tscii': 'ta_IN.TSCII-0',
1378 'ta_in.tscii0': 'ta_IN.TSCII-0',
1379 'tg': 'tg_TJ.KOI8-C',
1380 'tg_tj': 'tg_TJ.KOI8-C',
1381 'tg_tj.koi8c': 'tg_TJ.KOI8-C',
1382 'th': 'th_TH.ISO8859-11',
1383 'th_th': 'th_TH.ISO8859-11',
1384 'th_th.iso885911': 'th_TH.ISO8859-11',
1385 'th_th.tactis': 'th_TH.TIS620',
1386 'th_th.tis620': 'th_TH.TIS620',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001387 'thai': 'th_TH.ISO8859-11',
1388 'tl': 'tl_PH.ISO8859-1',
1389 'tl_ph': 'tl_PH.ISO8859-1',
1390 'tl_ph.iso88591': 'tl_PH.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001391 'tn': 'tn_ZA.ISO8859-15',
1392 'tn_za': 'tn_ZA.ISO8859-15',
1393 'tn_za.iso885915': 'tn_ZA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001394 'tr': 'tr_TR.ISO8859-9',
1395 'tr_tr': 'tr_TR.ISO8859-9',
1396 'tr_tr.iso88599': 'tr_TR.ISO8859-9',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001397 'ts': 'ts_ZA.ISO8859-1',
1398 'ts_za': 'ts_ZA.ISO8859-1',
1399 'ts_za.iso88591': 'ts_ZA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001400 'tt': 'tt_RU.TATAR-CYR',
1401 'tt_ru': 'tt_RU.TATAR-CYR',
1402 'tt_ru.koi8c': 'tt_RU.KOI8-C',
1403 'tt_ru.tatarcyr': 'tt_RU.TATAR-CYR',
1404 'turkish': 'tr_TR.ISO8859-9',
1405 'turkish.iso88599': 'tr_TR.ISO8859-9',
1406 'uk': 'uk_UA.KOI8-U',
1407 'uk_ua': 'uk_UA.KOI8-U',
1408 'uk_ua.cp1251': 'uk_UA.CP1251',
1409 'uk_ua.iso88595': 'uk_UA.ISO8859-5',
1410 'uk_ua.koi8u': 'uk_UA.KOI8-U',
1411 'uk_ua.microsoftcp1251': 'uk_UA.CP1251',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001412 'univ': 'en_US.utf',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001413 'universal': 'en_US.utf',
1414 'universal.utf8@ucs4': 'en_US.UTF-8',
1415 'ur': 'ur_PK.CP1256',
1416 'ur_pk': 'ur_PK.CP1256',
1417 'ur_pk.cp1256': 'ur_PK.CP1256',
1418 'ur_pk.microsoftcp1256': 'ur_PK.CP1256',
1419 'uz': 'uz_UZ.UTF-8',
1420 'uz_uz': 'uz_UZ.UTF-8',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001421 'uz_uz.iso88591': 'uz_UZ.ISO8859-1',
1422 'uz_uz.utf8@cyrillic': 'uz_UZ.UTF-8',
1423 'uz_uz@cyrillic': 'uz_UZ.UTF-8',
1424 've': 've_ZA.UTF-8',
1425 've_za': 've_ZA.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001426 'vi': 'vi_VN.TCVN',
1427 'vi_vn': 'vi_VN.TCVN',
1428 'vi_vn.tcvn': 'vi_VN.TCVN',
1429 'vi_vn.tcvn5712': 'vi_VN.TCVN',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001430 'vi_vn.viscii': 'vi_VN.VISCII',
1431 'vi_vn.viscii111': 'vi_VN.VISCII',
1432 'wa': 'wa_BE.ISO8859-1',
1433 'wa_be': 'wa_BE.ISO8859-1',
1434 'wa_be.iso88591': 'wa_BE.ISO8859-1',
1435 'wa_be.iso885915': 'wa_BE.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001436 'wa_be.iso885915@euro': 'wa_BE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001437 'wa_be@euro': 'wa_BE.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001438 'xh': 'xh_ZA.ISO8859-1',
1439 'xh_za': 'xh_ZA.ISO8859-1',
1440 'xh_za.iso88591': 'xh_ZA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001441 'yi': 'yi_US.CP1255',
1442 'yi_us': 'yi_US.CP1255',
1443 'yi_us.cp1255': 'yi_US.CP1255',
1444 'yi_us.microsoftcp1255': 'yi_US.CP1255',
1445 'zh': 'zh_CN.eucCN',
1446 'zh_cn': 'zh_CN.gb2312',
1447 'zh_cn.big5': 'zh_TW.big5',
1448 'zh_cn.euc': 'zh_CN.eucCN',
1449 'zh_cn.gb18030': 'zh_CN.gb18030',
1450 'zh_cn.gb2312': 'zh_CN.gb2312',
1451 'zh_cn.gbk': 'zh_CN.gbk',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001452 'zh_hk': 'zh_HK.big5hkscs',
1453 'zh_hk.big5': 'zh_HK.big5',
1454 'zh_hk.big5hkscs': 'zh_HK.big5hkscs',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001455 'zh_tw': 'zh_TW.big5',
1456 'zh_tw.big5': 'zh_TW.big5',
1457 'zh_tw.euc': 'zh_TW.eucTW',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001458 'zh_tw.euctw': 'zh_TW.eucTW',
1459 'zu': 'zu_ZA.ISO8859-1',
1460 'zu_za': 'zu_ZA.ISO8859-1',
1461 'zu_za.iso88591': 'zu_ZA.ISO8859-1',
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001462}
1463
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001464#
Georg Brandlb709c2c2006-01-20 09:07:35 +00001465# This maps Windows language identifiers to locale strings.
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001466#
Tim Peters777f1082006-01-20 20:03:24 +00001467# This list has been updated from
Georg Brandlb709c2c2006-01-20 09:07:35 +00001468# http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nls_238z.asp
1469# to include every locale up to Windows XP.
Fredrik Lundh37a09822002-10-19 20:19:10 +00001470#
Georg Brandl5035c1c2006-01-20 13:38:26 +00001471# NOTE: this mapping is incomplete. If your language is missing, please
1472# submit a bug report to Python bug manager, which you can find via:
1473# http://www.python.org/dev/
1474# Make sure you include the missing language identifier and the suggested
1475# locale code.
1476#
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001477
1478windows_locale = {
Georg Brandlb709c2c2006-01-20 09:07:35 +00001479 0x0436: "af_ZA", # Afrikaans
1480 0x041c: "sq_AL", # Albanian
1481 0x0401: "ar_SA", # Arabic - Saudi Arabia
1482 0x0801: "ar_IQ", # Arabic - Iraq
1483 0x0c01: "ar_EG", # Arabic - Egypt
1484 0x1001: "ar_LY", # Arabic - Libya
1485 0x1401: "ar_DZ", # Arabic - Algeria
1486 0x1801: "ar_MA", # Arabic - Morocco
1487 0x1c01: "ar_TN", # Arabic - Tunisia
1488 0x2001: "ar_OM", # Arabic - Oman
1489 0x2401: "ar_YE", # Arabic - Yemen
1490 0x2801: "ar_SY", # Arabic - Syria
1491 0x2c01: "ar_JO", # Arabic - Jordan
1492 0x3001: "ar_LB", # Arabic - Lebanon
1493 0x3401: "ar_KW", # Arabic - Kuwait
1494 0x3801: "ar_AE", # Arabic - United Arab Emirates
1495 0x3c01: "ar_BH", # Arabic - Bahrain
1496 0x4001: "ar_QA", # Arabic - Qatar
1497 0x042b: "hy_AM", # Armenian
1498 0x042c: "az_AZ", # Azeri Latin
1499 0x082c: "az_AZ", # Azeri - Cyrillic
1500 0x042d: "eu_ES", # Basque
1501 0x0423: "be_BY", # Belarusian
1502 0x0445: "bn_IN", # Begali
1503 0x201a: "bs_BA", # Bosnian
1504 0x141a: "bs_BA", # Bosnian - Cyrillic
1505 0x047e: "br_FR", # Breton - France
1506 0x0402: "bg_BG", # Bulgarian
1507 0x0403: "ca_ES", # Catalan
1508 0x0004: "zh_CHS",# Chinese - Simplified
1509 0x0404: "zh_TW", # Chinese - Taiwan
1510 0x0804: "zh_CN", # Chinese - PRC
1511 0x0c04: "zh_HK", # Chinese - Hong Kong S.A.R.
1512 0x1004: "zh_SG", # Chinese - Singapore
1513 0x1404: "zh_MO", # Chinese - Macao S.A.R.
1514 0x7c04: "zh_CHT",# Chinese - Traditional
1515 0x041a: "hr_HR", # Croatian
1516 0x101a: "hr_BA", # Croatian - Bosnia
1517 0x0405: "cs_CZ", # Czech
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001518 0x0406: "da_DK", # Danish
Georg Brandlb709c2c2006-01-20 09:07:35 +00001519 0x048c: "gbz_AF",# Dari - Afghanistan
1520 0x0465: "div_MV",# Divehi - Maldives
1521 0x0413: "nl_NL", # Dutch - The Netherlands
1522 0x0813: "nl_BE", # Dutch - Belgium
1523 0x0409: "en_US", # English - United States
1524 0x0809: "en_GB", # English - United Kingdom
1525 0x0c09: "en_AU", # English - Australia
1526 0x1009: "en_CA", # English - Canada
1527 0x1409: "en_NZ", # English - New Zealand
1528 0x1809: "en_IE", # English - Ireland
1529 0x1c09: "en_ZA", # English - South Africa
1530 0x2009: "en_JA", # English - Jamaica
1531 0x2409: "en_CB", # English - Carribbean
1532 0x2809: "en_BZ", # English - Belize
1533 0x2c09: "en_TT", # English - Trinidad
1534 0x3009: "en_ZW", # English - Zimbabwe
1535 0x3409: "en_PH", # English - Phillippines
1536 0x0425: "et_EE", # Estonian
1537 0x0438: "fo_FO", # Faroese
1538 0x0464: "fil_PH",# Filipino
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001539 0x040b: "fi_FI", # Finnish
Georg Brandlb709c2c2006-01-20 09:07:35 +00001540 0x040c: "fr_FR", # French - France
1541 0x080c: "fr_BE", # French - Belgium
1542 0x0c0c: "fr_CA", # French - Canada
1543 0x100c: "fr_CH", # French - Switzerland
1544 0x140c: "fr_LU", # French - Luxembourg
1545 0x180c: "fr_MC", # French - Monaco
1546 0x0462: "fy_NL", # Frisian - Netherlands
1547 0x0456: "gl_ES", # Galician
1548 0x0437: "ka_GE", # Georgian
1549 0x0407: "de_DE", # German - Germany
1550 0x0807: "de_CH", # German - Switzerland
1551 0x0c07: "de_AT", # German - Austria
1552 0x1007: "de_LU", # German - Luxembourg
1553 0x1407: "de_LI", # German - Liechtenstein
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001554 0x0408: "el_GR", # Greek
Georg Brandlb709c2c2006-01-20 09:07:35 +00001555 0x0447: "gu_IN", # Gujarati
1556 0x040d: "he_IL", # Hebrew
1557 0x0439: "hi_IN", # Hindi
1558 0x040e: "hu_HU", # Hungarian
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001559 0x040f: "is_IS", # Icelandic
Georg Brandlb709c2c2006-01-20 09:07:35 +00001560 0x0421: "id_ID", # Indonesian
1561 0x045d: "iu_CA", # Inuktitut
1562 0x085d: "iu_CA", # Inuktitut - Latin
1563 0x083c: "ga_IE", # Irish - Ireland
1564 0x0434: "xh_ZA", # Xhosa - South Africa
1565 0x0435: "zu_ZA", # Zulu
1566 0x0410: "it_IT", # Italian - Italy
1567 0x0810: "it_CH", # Italian - Switzerland
1568 0x0411: "ja_JP", # Japanese
1569 0x044b: "kn_IN", # Kannada - India
1570 0x043f: "kk_KZ", # Kazakh
1571 0x0457: "kok_IN",# Konkani
1572 0x0412: "ko_KR", # Korean
1573 0x0440: "ky_KG", # Kyrgyz
1574 0x0426: "lv_LV", # Latvian
1575 0x0427: "lt_LT", # Lithuanian
1576 0x046e: "lb_LU", # Luxembourgish
1577 0x042f: "mk_MK", # FYRO Macedonian
1578 0x043e: "ms_MY", # Malay - Malaysia
1579 0x083e: "ms_BN", # Malay - Brunei
1580 0x044c: "ml_IN", # Malayalam - India
1581 0x043a: "mt_MT", # Maltese
1582 0x0481: "mi_NZ", # Maori
1583 0x047a: "arn_CL",# Mapudungun
1584 0x044e: "mr_IN", # Marathi
1585 0x047c: "moh_CA",# Mohawk - Canada
1586 0x0450: "mn_MN", # Mongolian
1587 0x0461: "ne_NP", # Nepali
1588 0x0414: "nb_NO", # Norwegian - Bokmal
1589 0x0814: "nn_NO", # Norwegian - Nynorsk
1590 0x0482: "oc_FR", # Occitan - France
1591 0x0448: "or_IN", # Oriya - India
1592 0x0463: "ps_AF", # Pashto - Afghanistan
1593 0x0429: "fa_IR", # Persian
1594 0x0415: "pl_PL", # Polish
1595 0x0416: "pt_BR", # Portuguese - Brazil
1596 0x0816: "pt_PT", # Portuguese - Portugal
1597 0x0446: "pa_IN", # Punjabi
1598 0x046b: "quz_BO",# Quechua (Bolivia)
1599 0x086b: "quz_EC",# Quechua (Ecuador)
1600 0x0c6b: "quz_PE",# Quechua (Peru)
1601 0x0418: "ro_RO", # Romanian - Romania
1602 0x0417: "rm_CH", # Raeto-Romanese
1603 0x0419: "ru_RU", # Russian
1604 0x243b: "smn_FI",# Sami Finland
1605 0x103b: "smj_NO",# Sami Norway
1606 0x143b: "smj_SE",# Sami Sweden
1607 0x043b: "se_NO", # Sami Northern Norway
1608 0x083b: "se_SE", # Sami Northern Sweden
1609 0x0c3b: "se_FI", # Sami Northern Finland
1610 0x203b: "sms_FI",# Sami Skolt
1611 0x183b: "sma_NO",# Sami Southern Norway
1612 0x1c3b: "sma_SE",# Sami Southern Sweden
1613 0x044f: "sa_IN", # Sanskrit
1614 0x0c1a: "sr_SP", # Serbian - Cyrillic
1615 0x1c1a: "sr_BA", # Serbian - Bosnia Cyrillic
1616 0x081a: "sr_SP", # Serbian - Latin
1617 0x181a: "sr_BA", # Serbian - Bosnia Latin
1618 0x046c: "ns_ZA", # Northern Sotho
1619 0x0432: "tn_ZA", # Setswana - Southern Africa
1620 0x041b: "sk_SK", # Slovak
1621 0x0424: "sl_SI", # Slovenian
1622 0x040a: "es_ES", # Spanish - Spain
1623 0x080a: "es_MX", # Spanish - Mexico
1624 0x0c0a: "es_ES", # Spanish - Spain (Modern)
1625 0x100a: "es_GT", # Spanish - Guatemala
1626 0x140a: "es_CR", # Spanish - Costa Rica
1627 0x180a: "es_PA", # Spanish - Panama
1628 0x1c0a: "es_DO", # Spanish - Dominican Republic
1629 0x200a: "es_VE", # Spanish - Venezuela
1630 0x240a: "es_CO", # Spanish - Colombia
1631 0x280a: "es_PE", # Spanish - Peru
1632 0x2c0a: "es_AR", # Spanish - Argentina
1633 0x300a: "es_EC", # Spanish - Ecuador
1634 0x340a: "es_CL", # Spanish - Chile
1635 0x380a: "es_UR", # Spanish - Uruguay
1636 0x3c0a: "es_PY", # Spanish - Paraguay
1637 0x400a: "es_BO", # Spanish - Bolivia
1638 0x440a: "es_SV", # Spanish - El Salvador
1639 0x480a: "es_HN", # Spanish - Honduras
1640 0x4c0a: "es_NI", # Spanish - Nicaragua
1641 0x500a: "es_PR", # Spanish - Puerto Rico
1642 0x0441: "sw_KE", # Swahili
1643 0x041d: "sv_SE", # Swedish - Sweden
1644 0x081d: "sv_FI", # Swedish - Finland
1645 0x045a: "syr_SY",# Syriac
1646 0x0449: "ta_IN", # Tamil
1647 0x0444: "tt_RU", # Tatar
1648 0x044a: "te_IN", # Telugu
1649 0x041e: "th_TH", # Thai
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001650 0x041f: "tr_TR", # Turkish
Georg Brandlb709c2c2006-01-20 09:07:35 +00001651 0x0422: "uk_UA", # Ukrainian
1652 0x0420: "ur_PK", # Urdu
1653 0x0820: "ur_IN", # Urdu - India
1654 0x0443: "uz_UZ", # Uzbek - Latin
1655 0x0843: "uz_UZ", # Uzbek - Cyrillic
1656 0x042a: "vi_VN", # Vietnamese
1657 0x0452: "cy_GB", # Welsh
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001658}
1659
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001660def _print_locale():
1661
1662 """ Test function.
1663 """
1664 categories = {}
1665 def _init_categories(categories=categories):
1666 for k,v in globals().items():
1667 if k[:3] == 'LC_':
1668 categories[k] = v
1669 _init_categories()
1670 del categories['LC_ALL']
1671
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001672 print('Locale defaults as determined by getdefaultlocale():')
1673 print('-'*72)
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001674 lang, enc = getdefaultlocale()
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001675 print('Language: ', lang or '(undefined)')
1676 print('Encoding: ', enc or '(undefined)')
1677 print()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001678
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001679 print('Locale settings on startup:')
1680 print('-'*72)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001681 for name,category in categories.items():
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001682 print(name, '...')
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001683 lang, enc = getlocale(category)
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001684 print(' Language: ', lang or '(undefined)')
1685 print(' Encoding: ', enc or '(undefined)')
1686 print()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001687
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001688 print()
1689 print('Locale settings after calling resetlocale():')
1690 print('-'*72)
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001691 resetlocale()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001692 for name,category in categories.items():
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001693 print(name, '...')
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001694 lang, enc = getlocale(category)
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001695 print(' Language: ', lang or '(undefined)')
1696 print(' Encoding: ', enc or '(undefined)')
1697 print()
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001698
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001699 try:
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001700 setlocale(LC_ALL, "")
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001701 except:
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001702 print('NOTE:')
1703 print('setlocale(LC_ALL, "") does not support the default locale')
1704 print('given in the OS environment variables.')
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001705 else:
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001706 print()
1707 print('Locale settings after calling setlocale(LC_ALL, ""):')
1708 print('-'*72)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001709 for name,category in categories.items():
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001710 print(name, '...')
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001711 lang, enc = getlocale(category)
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001712 print(' Language: ', lang or '(undefined)')
1713 print(' Encoding: ', enc or '(undefined)')
1714 print()
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001715
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001716###
Guido van Rossumeef1d4e1997-11-19 19:01:43 +00001717
Tim Peters1baf8292001-01-24 10:13:46 +00001718try:
1719 LC_MESSAGES
Skip Montanaro0897f0c2002-03-25 21:40:36 +00001720except NameError:
Tim Peters1baf8292001-01-24 10:13:46 +00001721 pass
1722else:
1723 __all__.append("LC_MESSAGES")
1724
Guido van Rossumeef1d4e1997-11-19 19:01:43 +00001725if __name__=='__main__':
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001726 print('Locale aliasing:')
1727 print()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001728 _print_locale()
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001729 print()
1730 print('Number formatting:')
1731 print()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001732 _test()