blob: 0c4d6527e9096bcab5d4de92384d1c79ca2f113a [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
R. David Murraya83da352009-04-01 03:21:43 +000014import sys
15import encodings
16import encodings.aliases
17import re
18import operator
Antoine Pitrouba54eda2008-07-25 20:40:19 +000019import functools
Marc-André Lemburg5431bc32000-06-07 09:11:40 +000020
Fredrik Lundh6c86b992000-07-09 17:12:58 +000021# Try importing the _locale module.
22#
23# If this fails, fall back on a basic 'C' locale emulation.
Guido van Rossumeef1d4e1997-11-19 19:01:43 +000024
Tim Peters1baf8292001-01-24 10:13:46 +000025# Yuck: LC_MESSAGES is non-standard: can't tell whether it exists before
26# trying the import. So __all__ is also fiddled at the end of the file.
Georg Brandl09728b72007-05-01 06:08:15 +000027__all__ = ["getlocale", "getdefaultlocale", "getpreferredencoding", "Error",
28 "setlocale", "resetlocale", "localeconv", "strcoll", "strxfrm",
29 "str", "atof", "atoi", "format", "format_string", "currency",
30 "normalize", "LC_CTYPE", "LC_COLLATE", "LC_TIME", "LC_MONETARY",
31 "LC_NUMERIC", "LC_ALL", "CHAR_MAX"]
Skip Montanaro17ab1232001-01-24 06:27:27 +000032
Marc-André Lemburg23481142000-06-08 17:49:41 +000033try:
Fredrik Lundh6c86b992000-07-09 17:12:58 +000034
Marc-André Lemburg23481142000-06-08 17:49:41 +000035 from _locale import *
36
37except ImportError:
38
Fredrik Lundh6c86b992000-07-09 17:12:58 +000039 # Locale emulation
40
Marc-André Lemburg23481142000-06-08 17:49:41 +000041 CHAR_MAX = 127
42 LC_ALL = 6
43 LC_COLLATE = 3
44 LC_CTYPE = 0
45 LC_MESSAGES = 5
46 LC_MONETARY = 4
47 LC_NUMERIC = 1
48 LC_TIME = 2
49 Error = ValueError
50
51 def localeconv():
Fredrik Lundh6c86b992000-07-09 17:12:58 +000052 """ localeconv() -> dict.
Marc-André Lemburg23481142000-06-08 17:49:41 +000053 Returns numeric and monetary locale-specific parameters.
54 """
55 # 'C' locale default values
56 return {'grouping': [127],
57 'currency_symbol': '',
58 'n_sign_posn': 127,
Fredrik Lundh6c86b992000-07-09 17:12:58 +000059 'p_cs_precedes': 127,
60 'n_cs_precedes': 127,
61 'mon_grouping': [],
Marc-André Lemburg23481142000-06-08 17:49:41 +000062 'n_sep_by_space': 127,
63 'decimal_point': '.',
64 'negative_sign': '',
65 'positive_sign': '',
Fredrik Lundh6c86b992000-07-09 17:12:58 +000066 'p_sep_by_space': 127,
Marc-André Lemburg23481142000-06-08 17:49:41 +000067 'int_curr_symbol': '',
Fredrik Lundh6c86b992000-07-09 17:12:58 +000068 'p_sign_posn': 127,
Marc-André Lemburg23481142000-06-08 17:49:41 +000069 'thousands_sep': '',
Fredrik Lundh6c86b992000-07-09 17:12:58 +000070 'mon_thousands_sep': '',
71 'frac_digits': 127,
Marc-André Lemburg23481142000-06-08 17:49:41 +000072 'mon_decimal_point': '',
73 'int_frac_digits': 127}
Fredrik Lundh6c86b992000-07-09 17:12:58 +000074
Marc-André Lemburg23481142000-06-08 17:49:41 +000075 def setlocale(category, value=None):
Fredrik Lundh6c86b992000-07-09 17:12:58 +000076 """ setlocale(integer,string=None) -> string.
Marc-André Lemburg23481142000-06-08 17:49:41 +000077 Activates/queries locale processing.
78 """
Martin v. Löwis103d6e72003-03-30 15:42:13 +000079 if value not in (None, '', 'C'):
Fredrik Lundh6c86b992000-07-09 17:12:58 +000080 raise Error, '_locale emulation only supports "C" locale'
Marc-André Lemburg23481142000-06-08 17:49:41 +000081 return 'C'
82
83 def strcoll(a,b):
Fredrik Lundh6c86b992000-07-09 17:12:58 +000084 """ strcoll(string,string) -> int.
Marc-André Lemburg23481142000-06-08 17:49:41 +000085 Compares two strings according to the locale.
86 """
87 return cmp(a,b)
88
89 def strxfrm(s):
Fredrik Lundh6c86b992000-07-09 17:12:58 +000090 """ strxfrm(string) -> string.
Marc-André Lemburg23481142000-06-08 17:49:41 +000091 Returns a string that behaves for cmp locale-aware.
92 """
93 return s
Marc-André Lemburg5431bc32000-06-07 09:11:40 +000094
Antoine Pitrouba54eda2008-07-25 20:40:19 +000095
96_localeconv = localeconv
97
98# With this dict, you can override some items of localeconv's return value.
99# This is useful for testing purposes.
100_override_localeconv = {}
101
102@functools.wraps(_localeconv)
103def localeconv():
104 d = _localeconv()
105 if _override_localeconv:
106 d.update(_override_localeconv)
107 return d
108
109
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000110### Number formatting APIs
111
112# Author: Martin von Loewis
Georg Brandlb89316f2006-05-17 15:51:16 +0000113# improved by Georg Brandl
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000114
Antoine Pitroufeeafff2009-03-14 00:07:21 +0000115# Iterate over grouping intervals
116def _grouping_intervals(grouping):
Mark Dickinson4b456732009-08-04 21:56:04 +0000117 last_interval = None
Antoine Pitroufeeafff2009-03-14 00:07:21 +0000118 for interval in grouping:
119 # if grouping is -1, we are done
120 if interval == CHAR_MAX:
121 return
122 # 0: re-use last group ad infinitum
123 if interval == 0:
Mark Dickinson4b456732009-08-04 21:56:04 +0000124 if last_interval is None:
125 raise ValueError("invalid grouping")
Antoine Pitroufeeafff2009-03-14 00:07:21 +0000126 while True:
127 yield last_interval
128 yield interval
129 last_interval = interval
130
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000131#perform the grouping from right to left
Georg Brandlb89316f2006-05-17 15:51:16 +0000132def _group(s, monetary=False):
133 conv = localeconv()
134 thousands_sep = conv[monetary and 'mon_thousands_sep' or 'thousands_sep']
135 grouping = conv[monetary and 'mon_grouping' or 'grouping']
136 if not grouping:
137 return (s, 0)
138 result = ""
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000139 seps = 0
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000140 if s[-1] == ' ':
Antoine Pitroufeeafff2009-03-14 00:07:21 +0000141 stripped = s.rstrip()
142 right_spaces = s[len(stripped):]
143 s = stripped
144 else:
145 right_spaces = ''
146 left_spaces = ''
147 groups = []
148 for interval in _grouping_intervals(grouping):
149 if not s or s[-1] not in "0123456789":
150 # only non-digit characters remain (sign, spaces)
151 left_spaces = s
152 s = ''
Guido van Rossum45e2fbc1998-03-26 21:13:24 +0000153 break
Antoine Pitroufeeafff2009-03-14 00:07:21 +0000154 groups.append(s[-interval:])
155 s = s[:-interval]
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000156 if s:
Antoine Pitroufeeafff2009-03-14 00:07:21 +0000157 groups.append(s)
158 groups.reverse()
159 return (
160 left_spaces + thousands_sep.join(groups) + right_spaces,
Antoine Pitrou7c33bd52009-03-18 17:10:04 +0000161 len(thousands_sep) * (len(groups) - 1)
Antoine Pitroufeeafff2009-03-14 00:07:21 +0000162 )
163
164# Strip a given amount of excess padding from the given string
165def _strip_padding(s, amount):
166 lpos = 0
167 while amount and s[lpos] == ' ':
168 lpos += 1
169 amount -= 1
170 rpos = len(s) - 1
171 while amount and s[rpos] == ' ':
172 rpos -= 1
173 amount -= 1
174 return s[lpos:rpos+1]
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000175
R. David Murraya83da352009-04-01 03:21:43 +0000176_percent_re = re.compile(r'%(?:\((?P<key>.*?)\))?'
177 r'(?P<modifiers>[-#0-9 +*.hlL]*?)[eEfFgGdiouxXcrs%]')
178
Georg Brandlb89316f2006-05-17 15:51:16 +0000179def format(percent, value, grouping=False, monetary=False, *additional):
180 """Returns the locale-aware substitution of a %? specifier
181 (percent).
Tim Petersfd4c4192006-05-18 02:06:40 +0000182
Georg Brandlb89316f2006-05-17 15:51:16 +0000183 additional is for format strings which contain one or more
184 '*' modifiers."""
185 # this is only for one-percent-specifier strings and this should be checked
R. David Murraya83da352009-04-01 03:21:43 +0000186 match = _percent_re.match(percent)
187 if not match or len(match.group())!= len(percent):
188 raise ValueError(("format() must be given exactly one %%char "
189 "format specifier, %s not valid") % repr(percent))
190 return _format(percent, value, grouping, monetary, *additional)
191
192def _format(percent, value, grouping=False, monetary=False, *additional):
Georg Brandlb89316f2006-05-17 15:51:16 +0000193 if additional:
194 formatted = percent % ((value,) + additional)
195 else:
196 formatted = percent % value
197 # floats and decimal ints need special action!
198 if percent[-1] in 'eEfFgG':
199 seps = 0
200 parts = formatted.split('.')
201 if grouping:
202 parts[0], seps = _group(parts[0], monetary=monetary)
203 decimal_point = localeconv()[monetary and 'mon_decimal_point'
204 or 'decimal_point']
205 formatted = decimal_point.join(parts)
Antoine Pitroufeeafff2009-03-14 00:07:21 +0000206 if seps:
207 formatted = _strip_padding(formatted, seps)
Georg Brandlb89316f2006-05-17 15:51:16 +0000208 elif percent[-1] in 'diu':
Antoine Pitroufeeafff2009-03-14 00:07:21 +0000209 seps = 0
Georg Brandlb89316f2006-05-17 15:51:16 +0000210 if grouping:
Antoine Pitroufeeafff2009-03-14 00:07:21 +0000211 formatted, seps = _group(formatted, monetary=monetary)
212 if seps:
213 formatted = _strip_padding(formatted, seps)
Georg Brandlb89316f2006-05-17 15:51:16 +0000214 return formatted
215
Georg Brandlb89316f2006-05-17 15:51:16 +0000216def format_string(f, val, grouping=False):
217 """Formats a string in the same way that the % formatting would use,
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000218 but takes the current locale into account.
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000219 Grouping is applied if the third parameter is true."""
Georg Brandlb89316f2006-05-17 15:51:16 +0000220 percents = list(_percent_re.finditer(f))
221 new_f = _percent_re.sub('%s', f)
222
R. David Murray3939dcd2010-04-26 21:17:14 +0000223 if operator.isMappingType(val):
224 new_val = []
225 for perc in percents:
226 if perc.group()[-1]=='%':
227 new_val.append('%')
228 else:
229 new_val.append(format(perc.group(), val, grouping))
230 else:
231 if not isinstance(val, tuple):
232 val = (val,)
233 new_val = []
Georg Brandlb89316f2006-05-17 15:51:16 +0000234 i = 0
235 for perc in percents:
R. David Murray3939dcd2010-04-26 21:17:14 +0000236 if perc.group()[-1]=='%':
237 new_val.append('%')
238 else:
239 starcount = perc.group('modifiers').count('*')
240 new_val.append(_format(perc.group(),
241 val[i],
242 grouping,
243 False,
244 *val[i+1:i+1+starcount]))
245 i += (1 + starcount)
246 val = tuple(new_val)
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000247
Georg Brandlb89316f2006-05-17 15:51:16 +0000248 return new_f % val
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000249
Georg Brandlb89316f2006-05-17 15:51:16 +0000250def currency(val, symbol=True, grouping=False, international=False):
251 """Formats val according to the currency settings
252 in the current locale."""
253 conv = localeconv()
254
255 # check for illegal values
256 digits = conv[international and 'int_frac_digits' or 'frac_digits']
257 if digits == 127:
258 raise ValueError("Currency formatting is not possible using "
259 "the 'C' locale.")
260
261 s = format('%%.%if' % digits, abs(val), grouping, monetary=True)
262 # '<' and '>' are markers if the sign must be inserted between symbol and value
263 s = '<' + s + '>'
264
265 if symbol:
266 smb = conv[international and 'int_curr_symbol' or 'currency_symbol']
267 precedes = conv[val<0 and 'n_cs_precedes' or 'p_cs_precedes']
268 separated = conv[val<0 and 'n_sep_by_space' or 'p_sep_by_space']
269
270 if precedes:
271 s = smb + (separated and ' ' or '') + s
272 else:
273 s = s + (separated and ' ' or '') + smb
274
275 sign_pos = conv[val<0 and 'n_sign_posn' or 'p_sign_posn']
276 sign = conv[val<0 and 'negative_sign' or 'positive_sign']
277
278 if sign_pos == 0:
279 s = '(' + s + ')'
280 elif sign_pos == 1:
281 s = sign + s
282 elif sign_pos == 2:
283 s = s + sign
284 elif sign_pos == 3:
285 s = s.replace('<', sign)
286 elif sign_pos == 4:
287 s = s.replace('>', sign)
288 else:
289 # the default if nothing specified;
290 # this should be the most fitting sign position
291 s = sign + s
292
293 return s.replace('<', '').replace('>', '')
Martin v. Löwisdb786872001-01-21 18:52:33 +0000294
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000295def str(val):
296 """Convert float to integer, taking the locale into account."""
Georg Brandlb89316f2006-05-17 15:51:16 +0000297 return format("%.12g", val)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000298
Georg Brandlb89316f2006-05-17 15:51:16 +0000299def atof(string, func=float):
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000300 "Parses a string as a float according to the locale settings."
301 #First, get rid of the grouping
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000302 ts = localeconv()['thousands_sep']
303 if ts:
Skip Montanaro249369c2004-04-10 16:39:32 +0000304 string = string.replace(ts, '')
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000305 #next, replace the decimal point with a dot
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000306 dd = localeconv()['decimal_point']
307 if dd:
Skip Montanaro249369c2004-04-10 16:39:32 +0000308 string = string.replace(dd, '.')
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000309 #finally, parse the string
Skip Montanaro249369c2004-04-10 16:39:32 +0000310 return func(string)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000311
312def atoi(str):
313 "Converts a string to an integer according to the locale settings."
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000314 return atof(str, int)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000315
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000316def _test():
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000317 setlocale(LC_ALL, "")
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000318 #do grouping
Georg Brandlb89316f2006-05-17 15:51:16 +0000319 s1 = format("%d", 123456789,1)
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000320 print s1, "is", atoi(s1)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000321 #standard formatting
Georg Brandlb89316f2006-05-17 15:51:16 +0000322 s1 = str(3.14)
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000323 print s1, "is", atof(s1)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000324
325### Locale name aliasing engine
326
327# Author: Marc-Andre Lemburg, mal@lemburg.com
Fredrik Lundh37a09822002-10-19 20:19:10 +0000328# Various tweaks by Fredrik Lundh <fredrik@pythonware.com>
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000329
330# store away the low-level version of setlocale (it's
331# overridden below)
332_setlocale = setlocale
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000333
Antoine Pitrou4cfae022011-07-24 02:51:01 +0200334# Avoid relying on the locale-dependent .lower() method
335# (see issue #1813).
336_ascii_lower_map = ''.join(
337 chr(x + 32 if x >= ord('A') and x <= ord('Z') else x)
338 for x in range(256)
339)
340
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000341def normalize(localename):
342
343 """ Returns a normalized locale code for the given locale
344 name.
345
346 The returned locale code is formatted for use with
347 setlocale().
348
349 If normalization fails, the original name is returned
350 unchanged.
351
352 If the given encoding is not known, the function defaults to
353 the default encoding for the locale code just like setlocale()
354 does.
355
356 """
357 # Normalize the locale name and extract the encoding
Barry Warsawedfba822011-08-15 19:17:12 -0400358 if isinstance(localename, unicode):
359 localename = localename.encode('ascii')
Antoine Pitrou4cfae022011-07-24 02:51:01 +0200360 fullname = localename.translate(_ascii_lower_map)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000361 if ':' in fullname:
362 # ':' is sometimes used as encoding delimiter.
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000363 fullname = fullname.replace(':', '.')
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000364 if '.' in fullname:
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000365 langname, encoding = fullname.split('.')[:2]
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000366 fullname = langname + '.' + encoding
367 else:
368 langname = fullname
369 encoding = ''
370
371 # First lookup: fullname (possibly with encoding)
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000372 norm_encoding = encoding.replace('-', '')
373 norm_encoding = norm_encoding.replace('_', '')
374 lookup_name = langname + '.' + encoding
375 code = locale_alias.get(lookup_name, None)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000376 if code is not None:
377 return code
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000378 #print 'first lookup failed'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000379
380 # Second try: langname (without encoding)
381 code = locale_alias.get(langname, None)
382 if code is not None:
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000383 #print 'langname lookup succeeded'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000384 if '.' in code:
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000385 langname, defenc = code.split('.')
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000386 else:
387 langname = code
388 defenc = ''
389 if encoding:
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000390 # Convert the encoding to a C lib compatible encoding string
391 norm_encoding = encodings.normalize_encoding(encoding)
392 #print 'norm encoding: %r' % norm_encoding
393 norm_encoding = encodings.aliases.aliases.get(norm_encoding,
394 norm_encoding)
395 #print 'aliased encoding: %r' % norm_encoding
396 encoding = locale_encoding_alias.get(norm_encoding,
397 norm_encoding)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000398 else:
399 encoding = defenc
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000400 #print 'found encoding %r' % encoding
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000401 if encoding:
402 return langname + '.' + encoding
403 else:
404 return langname
405
406 else:
407 return localename
408
409def _parse_localename(localename):
410
411 """ Parses the locale code for localename and returns the
412 result as tuple (language code, encoding).
413
414 The localename is normalized and passed through the locale
415 alias engine. A ValueError is raised in case the locale name
416 cannot be parsed.
417
418 The language code corresponds to RFC 1766. code and encoding
419 can be None in case the values cannot be determined or are
Jeremy Hyltona05e2932000-06-28 14:48:01 +0000420 unknown to this implementation.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000421
422 """
423 code = normalize(localename)
Georg Brandlb709c2c2006-01-20 09:07:35 +0000424 if '@' in code:
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000425 # Deal with locale modifiers
426 code, modifier = code.split('@')
427 if modifier == 'euro' and '.' not in code:
428 # Assume Latin-9 for @euro locales. This is bogus,
429 # since some systems may use other encodings for these
430 # locales. Also, we ignore other modifiers.
431 return code, 'iso-8859-15'
Tim Peters230a60c2002-11-09 05:08:07 +0000432
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000433 if '.' in code:
Raymond Hettinger346e67f2005-01-01 06:10:26 +0000434 return tuple(code.split('.')[:2])
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000435 elif code == 'C':
436 return None, None
Andrew M. Kuchling1f877ef2001-08-13 14:50:44 +0000437 raise ValueError, 'unknown locale: %s' % localename
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000438
439def _build_localename(localetuple):
440
441 """ Builds a locale code from the given tuple (language code,
442 encoding).
443
444 No aliasing or normalizing takes place.
445
446 """
447 language, encoding = localetuple
448 if language is None:
449 language = 'C'
450 if encoding is None:
451 return language
452 else:
453 return language + '.' + encoding
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000454
Matthias Klosef3f231f2005-09-20 07:02:49 +0000455def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000456
457 """ Tries to determine the default locale settings and returns
458 them as tuple (language code, encoding).
459
460 According to POSIX, a program which has not called
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000461 setlocale(LC_ALL, "") runs using the portable 'C' locale.
462 Calling setlocale(LC_ALL, "") lets it use the default locale as
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000463 defined by the LANG variable. Since we don't want to interfere
Thomas Wouters7e474022000-07-16 12:04:32 +0000464 with the current locale setting we thus emulate the behavior
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000465 in the way described above.
466
467 To maintain compatibility with other platforms, not only the
468 LANG variable is tested, but a list of variables given as
469 envvars parameter. The first found to be defined will be
470 used. envvars defaults to the search path used in GNU gettext;
471 it must always contain the variable name 'LANG'.
472
473 Except for the code 'C', the language code corresponds to RFC
474 1766. code and encoding can be None in case the values cannot
475 be determined.
476
477 """
Fredrik Lundh04661322000-07-09 23:16:10 +0000478
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000479 try:
480 # check if it's supported by the _locale module
481 import _locale
482 code, encoding = _locale._getdefaultlocale()
Fredrik Lundh04661322000-07-09 23:16:10 +0000483 except (ImportError, AttributeError):
484 pass
485 else:
Fredrik Lundh663809e2000-07-10 19:32:19 +0000486 # make sure the code/encoding values are valid
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000487 if sys.platform == "win32" and code and code[:2] == "0x":
488 # map windows language identifier to language name
489 code = windows_locale.get(int(code, 0))
Fredrik Lundh663809e2000-07-10 19:32:19 +0000490 # ...add other platform-specific processing here, if
491 # necessary...
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000492 return code, encoding
Fredrik Lundh04661322000-07-09 23:16:10 +0000493
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000494 # fall back on POSIX behaviour
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000495 import os
496 lookup = os.environ.get
497 for variable in envvars:
498 localename = lookup(variable,None)
Martin v. Löwisc8ae31d2004-07-26 12:45:18 +0000499 if localename:
Matthias Klosef3f231f2005-09-20 07:02:49 +0000500 if variable == 'LANGUAGE':
501 localename = localename.split(':')[0]
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000502 break
503 else:
504 localename = 'C'
505 return _parse_localename(localename)
506
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000507
508def getlocale(category=LC_CTYPE):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000509
510 """ Returns the current setting for the given locale category as
511 tuple (language code, encoding).
512
513 category may be one of the LC_* value except LC_ALL. It
514 defaults to LC_CTYPE.
515
516 Except for the code 'C', the language code corresponds to RFC
517 1766. code and encoding can be None in case the values cannot
518 be determined.
519
520 """
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000521 localename = _setlocale(category)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000522 if category == LC_ALL and ';' in localename:
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000523 raise TypeError, 'category LC_ALL is not supported'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000524 return _parse_localename(localename)
525
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000526def setlocale(category, locale=None):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000527
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000528 """ Set the locale for the given category. The locale can be
529 a string, a locale tuple (language code, encoding), or None.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000530
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000531 Locale tuples are converted to strings the locale aliasing
532 engine. Locale strings are passed directly to the C lib.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000533
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000534 category may be given as one of the LC_* values.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000535
536 """
Victor Stinnerecb863b2011-06-20 22:07:06 +0200537 if locale and type(locale) is not type(""):
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000538 # convert to string
539 locale = normalize(_build_localename(locale))
540 return _setlocale(category, locale)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000541
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000542def resetlocale(category=LC_ALL):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000543
544 """ Sets the locale for category to the default setting.
545
546 The default setting is determined by calling
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000547 getdefaultlocale(). category defaults to LC_ALL.
548
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000549 """
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000550 _setlocale(category, _build_localename(getdefaultlocale()))
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000551
Benjamin Petersone021c9c2009-06-07 16:24:48 +0000552if sys.platform.startswith("win"):
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000553 # On Win32, this will return the ANSI code page
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000554 def getpreferredencoding(do_setlocale = True):
555 """Return the charset that the user is likely using."""
556 import _locale
Tim Petersa326f472002-11-05 03:49:09 +0000557 return _locale._getdefaultlocale()[1]
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000558else:
559 # On Unix, if CODESET is available, use that.
560 try:
561 CODESET
562 except NameError:
563 # Fall back to parsing environment variables :-(
564 def getpreferredencoding(do_setlocale = True):
565 """Return the charset that the user is likely using,
566 by looking at environment variables."""
567 return getdefaultlocale()[1]
568 else:
569 def getpreferredencoding(do_setlocale = True):
570 """Return the charset that the user is likely using,
571 according to the system configuration."""
572 if do_setlocale:
573 oldloc = setlocale(LC_CTYPE)
Jeroen Ruigrok van der Werven041f4652009-05-06 05:25:42 +0000574 try:
575 setlocale(LC_CTYPE, "")
Jeroen Ruigrok van der Wervenc924b3d2009-05-06 13:16:36 +0000576 except Error:
Jeroen Ruigrok van der Werven041f4652009-05-06 05:25:42 +0000577 pass
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000578 result = nl_langinfo(CODESET)
579 setlocale(LC_CTYPE, oldloc)
580 return result
581 else:
582 return nl_langinfo(CODESET)
Tim Peters230a60c2002-11-09 05:08:07 +0000583
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000584
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000585### Database
586#
587# The following data was extracted from the locale.alias file which
588# comes with X11 and then hand edited removing the explicit encoding
589# definitions and adding some more aliases. The file is usually
590# available as /usr/lib/X11/locale/locale.alias.
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000591#
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000592
593#
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000594# The local_encoding_alias table maps lowercase encoding alias names
595# to C locale encoding names (case-sensitive). Note that normalize()
596# first looks up the encoding in the encodings.aliases dictionary and
597# then applies this mapping to find the correct C lib name for the
598# encoding.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000599#
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000600locale_encoding_alias = {
601
602 # Mappings for non-standard encoding names used in locale names
603 '437': 'C',
604 'c': 'C',
605 'en': 'ISO8859-1',
606 'jis': 'JIS7',
607 'jis7': 'JIS7',
608 'ajec': 'eucJP',
609
610 # Mappings from Python codec names to C lib encoding names
611 'ascii': 'ISO8859-1',
612 'latin_1': 'ISO8859-1',
613 'iso8859_1': 'ISO8859-1',
614 'iso8859_10': 'ISO8859-10',
615 'iso8859_11': 'ISO8859-11',
616 'iso8859_13': 'ISO8859-13',
617 'iso8859_14': 'ISO8859-14',
618 'iso8859_15': 'ISO8859-15',
Jeroen Ruigrok van der Werven51133d42009-05-08 13:07:39 +0000619 'iso8859_16': 'ISO8859-16',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000620 'iso8859_2': 'ISO8859-2',
621 'iso8859_3': 'ISO8859-3',
622 'iso8859_4': 'ISO8859-4',
623 'iso8859_5': 'ISO8859-5',
624 'iso8859_6': 'ISO8859-6',
625 'iso8859_7': 'ISO8859-7',
626 'iso8859_8': 'ISO8859-8',
627 'iso8859_9': 'ISO8859-9',
628 'iso2022_jp': 'JIS7',
629 'shift_jis': 'SJIS',
630 'tactis': 'TACTIS',
631 'euc_jp': 'eucJP',
632 'euc_kr': 'eucKR',
Ronald Oussoren372954e2011-05-17 13:22:30 +0200633 'utf_8': 'UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000634 'koi8_r': 'KOI8-R',
635 'koi8_u': 'KOI8-U',
636 # XXX This list is still incomplete. If you know more
637 # mappings, please file a bug report. Thanks.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000638}
639
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000640#
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000641# The locale_alias table maps lowercase alias names to C locale names
642# (case-sensitive). Encodings are always separated from the locale
643# name using a dot ('.'); they should only be given in case the
644# language name is needed to interpret the given encoding alias
645# correctly (CJK codes often have this need).
646#
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000647# Note that the normalize() function which uses this tables
648# removes '_' and '-' characters from the encoding part of the
649# locale name before doing the lookup. This saves a lot of
650# space in the table.
651#
652# MAL 2004-12-10:
653# Updated alias mapping to most recent locale.alias file
654# from X.org distribution using makelocalealias.py.
655#
656# These are the differences compared to the old mapping (Python 2.4
657# and older):
658#
659# updated 'bg' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
660# updated 'bg_bg' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
661# updated 'bulgarian' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
662# updated 'cz' -> 'cz_CZ.ISO8859-2' to 'cs_CZ.ISO8859-2'
663# updated 'cz_cz' -> 'cz_CZ.ISO8859-2' to 'cs_CZ.ISO8859-2'
664# updated 'czech' -> 'cs_CS.ISO8859-2' to 'cs_CZ.ISO8859-2'
665# updated 'dutch' -> 'nl_BE.ISO8859-1' to 'nl_NL.ISO8859-1'
666# updated 'et' -> 'et_EE.ISO8859-4' to 'et_EE.ISO8859-15'
667# updated 'et_ee' -> 'et_EE.ISO8859-4' to 'et_EE.ISO8859-15'
668# updated 'fi' -> 'fi_FI.ISO8859-1' to 'fi_FI.ISO8859-15'
669# updated 'fi_fi' -> 'fi_FI.ISO8859-1' to 'fi_FI.ISO8859-15'
670# updated 'iw' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
671# updated 'iw_il' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
672# updated 'japanese' -> 'ja_JP.SJIS' to 'ja_JP.eucJP'
673# updated 'lt' -> 'lt_LT.ISO8859-4' to 'lt_LT.ISO8859-13'
674# updated 'lv' -> 'lv_LV.ISO8859-4' to 'lv_LV.ISO8859-13'
675# updated 'sl' -> 'sl_CS.ISO8859-2' to 'sl_SI.ISO8859-2'
676# updated 'slovene' -> 'sl_CS.ISO8859-2' to 'sl_SI.ISO8859-2'
677# updated 'th_th' -> 'th_TH.TACTIS' to 'th_TH.ISO8859-11'
678# updated 'zh_cn' -> 'zh_CN.eucCN' to 'zh_CN.gb2312'
679# updated 'zh_cn.big5' -> 'zh_TW.eucTW' to 'zh_TW.big5'
680# updated 'zh_tw' -> 'zh_TW.eucTW' to 'zh_TW.big5'
681#
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000682# MAL 2008-05-30:
683# Updated alias mapping to most recent locale.alias file
684# from X.org distribution using makelocalealias.py.
685#
686# These are the differences compared to the old mapping (Python 2.5
687# and older):
688#
689# updated 'cs_cs.iso88592' -> 'cs_CZ.ISO8859-2' to 'cs_CS.ISO8859-2'
690# updated 'serbocroatian' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
691# updated 'sh' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
692# updated 'sh_hr.iso88592' -> 'sh_HR.ISO8859-2' to 'hr_HR.ISO8859-2'
693# updated 'sh_sp' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
694# updated 'sh_yu' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
695# updated 'sp' -> 'sp_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
696# updated 'sp_yu' -> 'sp_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
697# updated 'sr' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
698# updated 'sr@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
699# updated 'sr_sp' -> 'sr_SP.ISO8859-2' to 'sr_CS.ISO8859-2'
700# updated 'sr_yu' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
701# updated 'sr_yu.cp1251@cyrillic' -> 'sr_YU.CP1251' to 'sr_CS.CP1251'
702# updated 'sr_yu.iso88592' -> 'sr_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
703# updated 'sr_yu.iso88595' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
704# updated 'sr_yu.iso88595@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
705# updated 'sr_yu.microsoftcp1251@cyrillic' -> 'sr_YU.CP1251' to 'sr_CS.CP1251'
706# updated 'sr_yu.utf8@cyrillic' -> 'sr_YU.UTF-8' to 'sr_CS.UTF-8'
707# updated 'sr_yu@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
Antoine Pitroufc531532010-04-11 22:32:39 +0000708#
709# AP 2010-04-12:
710# Updated alias mapping to most recent locale.alias file
711# from X.org distribution using makelocalealias.py.
712#
713# These are the differences compared to the old mapping (Python 2.6.5
714# and older):
715#
716# updated 'ru' -> 'ru_RU.ISO8859-5' to 'ru_RU.UTF-8'
717# updated 'ru_ru' -> 'ru_RU.ISO8859-5' to 'ru_RU.UTF-8'
718# updated 'serbocroatian' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
719# updated 'sh' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
720# updated 'sh_yu' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
721# updated 'sr' -> 'sr_CS.ISO8859-5' to 'sr_RS.UTF-8'
722# updated 'sr@cyrillic' -> 'sr_CS.ISO8859-5' to 'sr_RS.UTF-8'
723# updated 'sr@latn' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
724# updated 'sr_cs.utf8@latn' -> 'sr_CS.UTF-8' to 'sr_RS.UTF-8@latin'
725# updated 'sr_cs@latn' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
726# updated 'sr_yu' -> 'sr_CS.ISO8859-5' to 'sr_RS.UTF-8@latin'
727# updated 'sr_yu.utf8@cyrillic' -> 'sr_CS.UTF-8' to 'sr_RS.UTF-8'
728# updated 'sr_yu@cyrillic' -> 'sr_CS.ISO8859-5' to 'sr_RS.UTF-8'
729#
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000730
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000731locale_alias = {
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000732 'a3': 'a3_AZ.KOI8-C',
733 'a3_az': 'a3_AZ.KOI8-C',
734 'a3_az.koi8c': 'a3_AZ.KOI8-C',
735 'af': 'af_ZA.ISO8859-1',
736 'af_za': 'af_ZA.ISO8859-1',
737 'af_za.iso88591': 'af_ZA.ISO8859-1',
738 'am': 'am_ET.UTF-8',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000739 'am_et': 'am_ET.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000740 'american': 'en_US.ISO8859-1',
741 'american.iso88591': 'en_US.ISO8859-1',
742 'ar': 'ar_AA.ISO8859-6',
743 'ar_aa': 'ar_AA.ISO8859-6',
744 'ar_aa.iso88596': 'ar_AA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000745 'ar_ae': 'ar_AE.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000746 'ar_ae.iso88596': 'ar_AE.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000747 'ar_bh': 'ar_BH.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000748 'ar_bh.iso88596': 'ar_BH.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000749 'ar_dz': 'ar_DZ.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000750 'ar_dz.iso88596': 'ar_DZ.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000751 'ar_eg': 'ar_EG.ISO8859-6',
752 'ar_eg.iso88596': 'ar_EG.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000753 'ar_iq': 'ar_IQ.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000754 'ar_iq.iso88596': 'ar_IQ.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000755 'ar_jo': 'ar_JO.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000756 'ar_jo.iso88596': 'ar_JO.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000757 'ar_kw': 'ar_KW.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000758 'ar_kw.iso88596': 'ar_KW.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000759 'ar_lb': 'ar_LB.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000760 'ar_lb.iso88596': 'ar_LB.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000761 'ar_ly': 'ar_LY.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000762 'ar_ly.iso88596': 'ar_LY.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000763 'ar_ma': 'ar_MA.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000764 'ar_ma.iso88596': 'ar_MA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000765 'ar_om': 'ar_OM.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000766 'ar_om.iso88596': 'ar_OM.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000767 'ar_qa': 'ar_QA.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000768 'ar_qa.iso88596': 'ar_QA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000769 'ar_sa': 'ar_SA.ISO8859-6',
770 'ar_sa.iso88596': 'ar_SA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000771 'ar_sd': 'ar_SD.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000772 'ar_sd.iso88596': 'ar_SD.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000773 'ar_sy': 'ar_SY.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000774 'ar_sy.iso88596': 'ar_SY.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000775 'ar_tn': 'ar_TN.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000776 'ar_tn.iso88596': 'ar_TN.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000777 'ar_ye': 'ar_YE.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000778 'ar_ye.iso88596': 'ar_YE.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000779 'arabic': 'ar_AA.ISO8859-6',
780 'arabic.iso88596': 'ar_AA.ISO8859-6',
Antoine Pitroufc531532010-04-11 22:32:39 +0000781 'as': 'as_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000782 'az': 'az_AZ.ISO8859-9E',
783 'az_az': 'az_AZ.ISO8859-9E',
784 'az_az.iso88599e': 'az_AZ.ISO8859-9E',
785 'be': 'be_BY.CP1251',
Antoine Pitroufc531532010-04-11 22:32:39 +0000786 'be@latin': 'be_BY.UTF-8@latin',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000787 'be_by': 'be_BY.CP1251',
788 'be_by.cp1251': 'be_BY.CP1251',
789 'be_by.microsoftcp1251': 'be_BY.CP1251',
Antoine Pitroufc531532010-04-11 22:32:39 +0000790 'be_by.utf8@latin': 'be_BY.UTF-8@latin',
791 'be_by@latin': 'be_BY.UTF-8@latin',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000792 'bg': 'bg_BG.CP1251',
793 'bg_bg': 'bg_BG.CP1251',
794 'bg_bg.cp1251': 'bg_BG.CP1251',
795 'bg_bg.iso88595': 'bg_BG.ISO8859-5',
796 'bg_bg.koi8r': 'bg_BG.KOI8-R',
797 'bg_bg.microsoftcp1251': 'bg_BG.CP1251',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000798 'bn_in': 'bn_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000799 'bokmal': 'nb_NO.ISO8859-1',
800 'bokm\xe5l': 'nb_NO.ISO8859-1',
801 'br': 'br_FR.ISO8859-1',
802 'br_fr': 'br_FR.ISO8859-1',
803 'br_fr.iso88591': 'br_FR.ISO8859-1',
804 'br_fr.iso885914': 'br_FR.ISO8859-14',
805 'br_fr.iso885915': 'br_FR.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000806 'br_fr.iso885915@euro': 'br_FR.ISO8859-15',
807 'br_fr.utf8@euro': 'br_FR.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000808 'br_fr@euro': 'br_FR.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000809 'bs': 'bs_BA.ISO8859-2',
810 'bs_ba': 'bs_BA.ISO8859-2',
811 'bs_ba.iso88592': 'bs_BA.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000812 'bulgarian': 'bg_BG.CP1251',
813 'c': 'C',
814 'c-french': 'fr_CA.ISO8859-1',
815 'c-french.iso88591': 'fr_CA.ISO8859-1',
816 'c.en': 'C',
817 'c.iso88591': 'en_US.ISO8859-1',
818 'c_c': 'C',
819 'c_c.c': 'C',
820 'ca': 'ca_ES.ISO8859-1',
Antoine Pitroufc531532010-04-11 22:32:39 +0000821 'ca_ad': 'ca_AD.ISO8859-1',
822 'ca_ad.iso88591': 'ca_AD.ISO8859-1',
823 'ca_ad.iso885915': 'ca_AD.ISO8859-15',
824 'ca_ad.iso885915@euro': 'ca_AD.ISO8859-15',
825 'ca_ad.utf8@euro': 'ca_AD.UTF-8',
826 'ca_ad@euro': 'ca_AD.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000827 'ca_es': 'ca_ES.ISO8859-1',
828 'ca_es.iso88591': 'ca_ES.ISO8859-1',
829 'ca_es.iso885915': 'ca_ES.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000830 'ca_es.iso885915@euro': 'ca_ES.ISO8859-15',
831 'ca_es.utf8@euro': 'ca_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000832 'ca_es@euro': 'ca_ES.ISO8859-15',
Antoine Pitroufc531532010-04-11 22:32:39 +0000833 'ca_fr': 'ca_FR.ISO8859-1',
834 'ca_fr.iso88591': 'ca_FR.ISO8859-1',
835 'ca_fr.iso885915': 'ca_FR.ISO8859-15',
836 'ca_fr.iso885915@euro': 'ca_FR.ISO8859-15',
837 'ca_fr.utf8@euro': 'ca_FR.UTF-8',
838 'ca_fr@euro': 'ca_FR.ISO8859-15',
839 'ca_it': 'ca_IT.ISO8859-1',
840 'ca_it.iso88591': 'ca_IT.ISO8859-1',
841 'ca_it.iso885915': 'ca_IT.ISO8859-15',
842 'ca_it.iso885915@euro': 'ca_IT.ISO8859-15',
843 'ca_it.utf8@euro': 'ca_IT.UTF-8',
844 'ca_it@euro': 'ca_IT.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000845 'catalan': 'ca_ES.ISO8859-1',
846 'cextend': 'en_US.ISO8859-1',
847 'cextend.en': 'en_US.ISO8859-1',
848 'chinese-s': 'zh_CN.eucCN',
849 'chinese-t': 'zh_TW.eucTW',
850 'croatian': 'hr_HR.ISO8859-2',
851 'cs': 'cs_CZ.ISO8859-2',
852 'cs_cs': 'cs_CZ.ISO8859-2',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000853 'cs_cs.iso88592': 'cs_CS.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000854 'cs_cz': 'cs_CZ.ISO8859-2',
855 'cs_cz.iso88592': 'cs_CZ.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000856 'cy': 'cy_GB.ISO8859-1',
857 'cy_gb': 'cy_GB.ISO8859-1',
858 'cy_gb.iso88591': 'cy_GB.ISO8859-1',
859 'cy_gb.iso885914': 'cy_GB.ISO8859-14',
860 'cy_gb.iso885915': 'cy_GB.ISO8859-15',
861 'cy_gb@euro': 'cy_GB.ISO8859-15',
862 'cz': 'cs_CZ.ISO8859-2',
863 'cz_cz': 'cs_CZ.ISO8859-2',
864 'czech': 'cs_CZ.ISO8859-2',
865 'da': 'da_DK.ISO8859-1',
Antoine Pitroufc531532010-04-11 22:32:39 +0000866 'da.iso885915': 'da_DK.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000867 'da_dk': 'da_DK.ISO8859-1',
868 'da_dk.88591': 'da_DK.ISO8859-1',
869 'da_dk.885915': 'da_DK.ISO8859-15',
870 'da_dk.iso88591': 'da_DK.ISO8859-1',
871 'da_dk.iso885915': 'da_DK.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000872 'da_dk@euro': 'da_DK.ISO8859-15',
873 'danish': 'da_DK.ISO8859-1',
874 'danish.iso88591': 'da_DK.ISO8859-1',
875 'dansk': 'da_DK.ISO8859-1',
876 'de': 'de_DE.ISO8859-1',
Antoine Pitroufc531532010-04-11 22:32:39 +0000877 'de.iso885915': 'de_DE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000878 'de_at': 'de_AT.ISO8859-1',
879 'de_at.iso88591': 'de_AT.ISO8859-1',
880 'de_at.iso885915': 'de_AT.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000881 'de_at.iso885915@euro': 'de_AT.ISO8859-15',
882 'de_at.utf8@euro': 'de_AT.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000883 'de_at@euro': 'de_AT.ISO8859-15',
884 'de_be': 'de_BE.ISO8859-1',
885 'de_be.iso88591': 'de_BE.ISO8859-1',
886 'de_be.iso885915': 'de_BE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000887 'de_be.iso885915@euro': 'de_BE.ISO8859-15',
888 'de_be.utf8@euro': 'de_BE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000889 'de_be@euro': 'de_BE.ISO8859-15',
890 'de_ch': 'de_CH.ISO8859-1',
891 'de_ch.iso88591': 'de_CH.ISO8859-1',
892 'de_ch.iso885915': 'de_CH.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000893 'de_ch@euro': 'de_CH.ISO8859-15',
894 'de_de': 'de_DE.ISO8859-1',
895 'de_de.88591': 'de_DE.ISO8859-1',
896 'de_de.885915': 'de_DE.ISO8859-15',
897 'de_de.885915@euro': 'de_DE.ISO8859-15',
898 'de_de.iso88591': 'de_DE.ISO8859-1',
899 'de_de.iso885915': 'de_DE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000900 'de_de.iso885915@euro': 'de_DE.ISO8859-15',
901 'de_de.utf8@euro': 'de_DE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000902 'de_de@euro': 'de_DE.ISO8859-15',
903 'de_lu': 'de_LU.ISO8859-1',
904 'de_lu.iso88591': 'de_LU.ISO8859-1',
905 'de_lu.iso885915': 'de_LU.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000906 'de_lu.iso885915@euro': 'de_LU.ISO8859-15',
907 'de_lu.utf8@euro': 'de_LU.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000908 'de_lu@euro': 'de_LU.ISO8859-15',
909 'deutsch': 'de_DE.ISO8859-1',
910 'dutch': 'nl_NL.ISO8859-1',
911 'dutch.iso88591': 'nl_BE.ISO8859-1',
912 'ee': 'ee_EE.ISO8859-4',
913 'ee_ee': 'ee_EE.ISO8859-4',
914 'ee_ee.iso88594': 'ee_EE.ISO8859-4',
915 'eesti': 'et_EE.ISO8859-1',
916 'el': 'el_GR.ISO8859-7',
917 'el_gr': 'el_GR.ISO8859-7',
918 'el_gr.iso88597': 'el_GR.ISO8859-7',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000919 'el_gr@euro': 'el_GR.ISO8859-15',
920 'en': 'en_US.ISO8859-1',
921 'en.iso88591': 'en_US.ISO8859-1',
922 'en_au': 'en_AU.ISO8859-1',
923 'en_au.iso88591': 'en_AU.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000924 'en_be': 'en_BE.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000925 'en_be@euro': 'en_BE.ISO8859-15',
926 'en_bw': 'en_BW.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000927 'en_bw.iso88591': 'en_BW.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000928 'en_ca': 'en_CA.ISO8859-1',
929 'en_ca.iso88591': 'en_CA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000930 'en_gb': 'en_GB.ISO8859-1',
931 'en_gb.88591': 'en_GB.ISO8859-1',
932 'en_gb.iso88591': 'en_GB.ISO8859-1',
933 'en_gb.iso885915': 'en_GB.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000934 'en_gb@euro': 'en_GB.ISO8859-15',
935 'en_hk': 'en_HK.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000936 'en_hk.iso88591': 'en_HK.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000937 'en_ie': 'en_IE.ISO8859-1',
938 'en_ie.iso88591': 'en_IE.ISO8859-1',
939 'en_ie.iso885915': 'en_IE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000940 'en_ie.iso885915@euro': 'en_IE.ISO8859-15',
941 'en_ie.utf8@euro': 'en_IE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000942 'en_ie@euro': 'en_IE.ISO8859-15',
943 'en_in': 'en_IN.ISO8859-1',
944 'en_nz': 'en_NZ.ISO8859-1',
945 'en_nz.iso88591': 'en_NZ.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000946 'en_ph': 'en_PH.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000947 'en_ph.iso88591': 'en_PH.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000948 'en_sg': 'en_SG.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000949 'en_sg.iso88591': 'en_SG.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000950 'en_uk': 'en_GB.ISO8859-1',
951 'en_us': 'en_US.ISO8859-1',
952 'en_us.88591': 'en_US.ISO8859-1',
953 'en_us.885915': 'en_US.ISO8859-15',
954 'en_us.iso88591': 'en_US.ISO8859-1',
955 'en_us.iso885915': 'en_US.ISO8859-15',
956 'en_us.iso885915@euro': 'en_US.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000957 'en_us@euro': 'en_US.ISO8859-15',
958 'en_us@euro@euro': 'en_US.ISO8859-15',
959 'en_za': 'en_ZA.ISO8859-1',
960 'en_za.88591': 'en_ZA.ISO8859-1',
961 'en_za.iso88591': 'en_ZA.ISO8859-1',
962 'en_za.iso885915': 'en_ZA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000963 'en_za@euro': 'en_ZA.ISO8859-15',
964 'en_zw': 'en_ZW.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000965 'en_zw.iso88591': 'en_ZW.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000966 'eng_gb': 'en_GB.ISO8859-1',
967 'eng_gb.8859': 'en_GB.ISO8859-1',
968 'english': 'en_EN.ISO8859-1',
969 'english.iso88591': 'en_EN.ISO8859-1',
970 'english_uk': 'en_GB.ISO8859-1',
971 'english_uk.8859': 'en_GB.ISO8859-1',
972 'english_united-states': 'en_US.ISO8859-1',
973 'english_united-states.437': 'C',
974 'english_us': 'en_US.ISO8859-1',
975 'english_us.8859': 'en_US.ISO8859-1',
976 'english_us.ascii': 'en_US.ISO8859-1',
977 'eo': 'eo_XX.ISO8859-3',
978 'eo_eo': 'eo_EO.ISO8859-3',
979 'eo_eo.iso88593': 'eo_EO.ISO8859-3',
980 'eo_xx': 'eo_XX.ISO8859-3',
981 'eo_xx.iso88593': 'eo_XX.ISO8859-3',
982 'es': 'es_ES.ISO8859-1',
983 'es_ar': 'es_AR.ISO8859-1',
984 'es_ar.iso88591': 'es_AR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000985 'es_bo': 'es_BO.ISO8859-1',
986 'es_bo.iso88591': 'es_BO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000987 'es_cl': 'es_CL.ISO8859-1',
988 'es_cl.iso88591': 'es_CL.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000989 'es_co': 'es_CO.ISO8859-1',
990 'es_co.iso88591': 'es_CO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000991 'es_cr': 'es_CR.ISO8859-1',
992 'es_cr.iso88591': 'es_CR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000993 'es_do': 'es_DO.ISO8859-1',
994 'es_do.iso88591': 'es_DO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000995 'es_ec': 'es_EC.ISO8859-1',
996 'es_ec.iso88591': 'es_EC.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000997 'es_es': 'es_ES.ISO8859-1',
998 'es_es.88591': 'es_ES.ISO8859-1',
999 'es_es.iso88591': 'es_ES.ISO8859-1',
1000 'es_es.iso885915': 'es_ES.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001001 'es_es.iso885915@euro': 'es_ES.ISO8859-15',
1002 'es_es.utf8@euro': 'es_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001003 'es_es@euro': 'es_ES.ISO8859-15',
1004 'es_gt': 'es_GT.ISO8859-1',
1005 'es_gt.iso88591': 'es_GT.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001006 'es_hn': 'es_HN.ISO8859-1',
1007 'es_hn.iso88591': 'es_HN.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001008 'es_mx': 'es_MX.ISO8859-1',
1009 'es_mx.iso88591': 'es_MX.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001010 'es_ni': 'es_NI.ISO8859-1',
1011 'es_ni.iso88591': 'es_NI.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001012 'es_pa': 'es_PA.ISO8859-1',
1013 'es_pa.iso88591': 'es_PA.ISO8859-1',
1014 'es_pa.iso885915': 'es_PA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001015 'es_pa@euro': 'es_PA.ISO8859-15',
1016 'es_pe': 'es_PE.ISO8859-1',
1017 'es_pe.iso88591': 'es_PE.ISO8859-1',
1018 'es_pe.iso885915': 'es_PE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001019 'es_pe@euro': 'es_PE.ISO8859-15',
1020 'es_pr': 'es_PR.ISO8859-1',
1021 'es_pr.iso88591': 'es_PR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001022 'es_py': 'es_PY.ISO8859-1',
1023 'es_py.iso88591': 'es_PY.ISO8859-1',
1024 'es_py.iso885915': 'es_PY.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001025 'es_py@euro': 'es_PY.ISO8859-15',
1026 'es_sv': 'es_SV.ISO8859-1',
1027 'es_sv.iso88591': 'es_SV.ISO8859-1',
1028 'es_sv.iso885915': 'es_SV.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001029 'es_sv@euro': 'es_SV.ISO8859-15',
1030 'es_us': 'es_US.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001031 'es_us.iso88591': 'es_US.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001032 'es_uy': 'es_UY.ISO8859-1',
1033 'es_uy.iso88591': 'es_UY.ISO8859-1',
1034 'es_uy.iso885915': 'es_UY.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001035 'es_uy@euro': 'es_UY.ISO8859-15',
1036 'es_ve': 'es_VE.ISO8859-1',
1037 'es_ve.iso88591': 'es_VE.ISO8859-1',
1038 'es_ve.iso885915': 'es_VE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001039 'es_ve@euro': 'es_VE.ISO8859-15',
1040 'estonian': 'et_EE.ISO8859-1',
1041 'et': 'et_EE.ISO8859-15',
1042 'et_ee': 'et_EE.ISO8859-15',
1043 'et_ee.iso88591': 'et_EE.ISO8859-1',
1044 'et_ee.iso885913': 'et_EE.ISO8859-13',
1045 'et_ee.iso885915': 'et_EE.ISO8859-15',
1046 'et_ee.iso88594': 'et_EE.ISO8859-4',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001047 'et_ee@euro': 'et_EE.ISO8859-15',
1048 'eu': 'eu_ES.ISO8859-1',
1049 'eu_es': 'eu_ES.ISO8859-1',
1050 'eu_es.iso88591': 'eu_ES.ISO8859-1',
1051 'eu_es.iso885915': 'eu_ES.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001052 'eu_es.iso885915@euro': 'eu_ES.ISO8859-15',
1053 'eu_es.utf8@euro': 'eu_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001054 'eu_es@euro': 'eu_ES.ISO8859-15',
1055 'fa': 'fa_IR.UTF-8',
1056 'fa_ir': 'fa_IR.UTF-8',
1057 'fa_ir.isiri3342': 'fa_IR.ISIRI-3342',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001058 'fi': 'fi_FI.ISO8859-15',
Antoine Pitroufc531532010-04-11 22:32:39 +00001059 'fi.iso885915': 'fi_FI.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001060 'fi_fi': 'fi_FI.ISO8859-15',
1061 'fi_fi.88591': 'fi_FI.ISO8859-1',
1062 'fi_fi.iso88591': 'fi_FI.ISO8859-1',
1063 'fi_fi.iso885915': 'fi_FI.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001064 'fi_fi.iso885915@euro': 'fi_FI.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001065 'fi_fi.utf8@euro': 'fi_FI.UTF-8',
1066 'fi_fi@euro': 'fi_FI.ISO8859-15',
1067 'finnish': 'fi_FI.ISO8859-1',
1068 'finnish.iso88591': 'fi_FI.ISO8859-1',
1069 'fo': 'fo_FO.ISO8859-1',
1070 'fo_fo': 'fo_FO.ISO8859-1',
1071 'fo_fo.iso88591': 'fo_FO.ISO8859-1',
1072 'fo_fo.iso885915': 'fo_FO.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001073 'fo_fo@euro': 'fo_FO.ISO8859-15',
1074 'fr': 'fr_FR.ISO8859-1',
Antoine Pitroufc531532010-04-11 22:32:39 +00001075 'fr.iso885915': 'fr_FR.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001076 'fr_be': 'fr_BE.ISO8859-1',
1077 'fr_be.88591': 'fr_BE.ISO8859-1',
1078 'fr_be.iso88591': 'fr_BE.ISO8859-1',
1079 'fr_be.iso885915': 'fr_BE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001080 'fr_be.iso885915@euro': 'fr_BE.ISO8859-15',
1081 'fr_be.utf8@euro': 'fr_BE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001082 'fr_be@euro': 'fr_BE.ISO8859-15',
1083 'fr_ca': 'fr_CA.ISO8859-1',
1084 'fr_ca.88591': 'fr_CA.ISO8859-1',
1085 'fr_ca.iso88591': 'fr_CA.ISO8859-1',
1086 'fr_ca.iso885915': 'fr_CA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001087 'fr_ca@euro': 'fr_CA.ISO8859-15',
1088 'fr_ch': 'fr_CH.ISO8859-1',
1089 'fr_ch.88591': 'fr_CH.ISO8859-1',
1090 'fr_ch.iso88591': 'fr_CH.ISO8859-1',
1091 'fr_ch.iso885915': 'fr_CH.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001092 'fr_ch@euro': 'fr_CH.ISO8859-15',
1093 'fr_fr': 'fr_FR.ISO8859-1',
1094 'fr_fr.88591': 'fr_FR.ISO8859-1',
1095 'fr_fr.iso88591': 'fr_FR.ISO8859-1',
1096 'fr_fr.iso885915': 'fr_FR.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001097 'fr_fr.iso885915@euro': 'fr_FR.ISO8859-15',
1098 'fr_fr.utf8@euro': 'fr_FR.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001099 'fr_fr@euro': 'fr_FR.ISO8859-15',
1100 'fr_lu': 'fr_LU.ISO8859-1',
1101 'fr_lu.88591': 'fr_LU.ISO8859-1',
1102 'fr_lu.iso88591': 'fr_LU.ISO8859-1',
1103 'fr_lu.iso885915': 'fr_LU.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001104 'fr_lu.iso885915@euro': 'fr_LU.ISO8859-15',
1105 'fr_lu.utf8@euro': 'fr_LU.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001106 'fr_lu@euro': 'fr_LU.ISO8859-15',
1107 'fran\xe7ais': 'fr_FR.ISO8859-1',
1108 'fre_fr': 'fr_FR.ISO8859-1',
1109 'fre_fr.8859': 'fr_FR.ISO8859-1',
1110 'french': 'fr_FR.ISO8859-1',
1111 'french.iso88591': 'fr_CH.ISO8859-1',
1112 'french_france': 'fr_FR.ISO8859-1',
1113 'french_france.8859': 'fr_FR.ISO8859-1',
1114 'ga': 'ga_IE.ISO8859-1',
1115 'ga_ie': 'ga_IE.ISO8859-1',
1116 'ga_ie.iso88591': 'ga_IE.ISO8859-1',
1117 'ga_ie.iso885914': 'ga_IE.ISO8859-14',
1118 'ga_ie.iso885915': 'ga_IE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001119 'ga_ie.iso885915@euro': 'ga_IE.ISO8859-15',
1120 'ga_ie.utf8@euro': 'ga_IE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001121 'ga_ie@euro': 'ga_IE.ISO8859-15',
1122 'galego': 'gl_ES.ISO8859-1',
1123 'galician': 'gl_ES.ISO8859-1',
1124 'gd': 'gd_GB.ISO8859-1',
1125 'gd_gb': 'gd_GB.ISO8859-1',
1126 'gd_gb.iso88591': 'gd_GB.ISO8859-1',
1127 'gd_gb.iso885914': 'gd_GB.ISO8859-14',
1128 'gd_gb.iso885915': 'gd_GB.ISO8859-15',
1129 'gd_gb@euro': 'gd_GB.ISO8859-15',
1130 'ger_de': 'de_DE.ISO8859-1',
1131 'ger_de.8859': 'de_DE.ISO8859-1',
1132 'german': 'de_DE.ISO8859-1',
1133 'german.iso88591': 'de_CH.ISO8859-1',
1134 'german_germany': 'de_DE.ISO8859-1',
1135 'german_germany.8859': 'de_DE.ISO8859-1',
1136 'gl': 'gl_ES.ISO8859-1',
1137 'gl_es': 'gl_ES.ISO8859-1',
1138 'gl_es.iso88591': 'gl_ES.ISO8859-1',
1139 'gl_es.iso885915': 'gl_ES.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001140 'gl_es.iso885915@euro': 'gl_ES.ISO8859-15',
1141 'gl_es.utf8@euro': 'gl_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001142 'gl_es@euro': 'gl_ES.ISO8859-15',
1143 'greek': 'el_GR.ISO8859-7',
1144 'greek.iso88597': 'el_GR.ISO8859-7',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001145 'gu_in': 'gu_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001146 'gv': 'gv_GB.ISO8859-1',
1147 'gv_gb': 'gv_GB.ISO8859-1',
1148 'gv_gb.iso88591': 'gv_GB.ISO8859-1',
1149 'gv_gb.iso885914': 'gv_GB.ISO8859-14',
1150 'gv_gb.iso885915': 'gv_GB.ISO8859-15',
1151 'gv_gb@euro': 'gv_GB.ISO8859-15',
1152 'he': 'he_IL.ISO8859-8',
1153 'he_il': 'he_IL.ISO8859-8',
1154 'he_il.cp1255': 'he_IL.CP1255',
1155 'he_il.iso88598': 'he_IL.ISO8859-8',
1156 'he_il.microsoftcp1255': 'he_IL.CP1255',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001157 'hebrew': 'iw_IL.ISO8859-8',
1158 'hebrew.iso88598': 'iw_IL.ISO8859-8',
1159 'hi': 'hi_IN.ISCII-DEV',
1160 'hi_in': 'hi_IN.ISCII-DEV',
1161 'hi_in.isciidev': 'hi_IN.ISCII-DEV',
Antoine Pitroufc531532010-04-11 22:32:39 +00001162 'hne': 'hne_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001163 'hr': 'hr_HR.ISO8859-2',
1164 'hr_hr': 'hr_HR.ISO8859-2',
1165 'hr_hr.iso88592': 'hr_HR.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001166 'hrvatski': 'hr_HR.ISO8859-2',
1167 'hu': 'hu_HU.ISO8859-2',
1168 'hu_hu': 'hu_HU.ISO8859-2',
1169 'hu_hu.iso88592': 'hu_HU.ISO8859-2',
1170 'hungarian': 'hu_HU.ISO8859-2',
1171 'icelandic': 'is_IS.ISO8859-1',
1172 'icelandic.iso88591': 'is_IS.ISO8859-1',
1173 'id': 'id_ID.ISO8859-1',
1174 'id_id': 'id_ID.ISO8859-1',
1175 'in': 'id_ID.ISO8859-1',
1176 'in_id': 'id_ID.ISO8859-1',
1177 'is': 'is_IS.ISO8859-1',
1178 'is_is': 'is_IS.ISO8859-1',
1179 'is_is.iso88591': 'is_IS.ISO8859-1',
1180 'is_is.iso885915': 'is_IS.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001181 'is_is@euro': 'is_IS.ISO8859-15',
1182 'iso-8859-1': 'en_US.ISO8859-1',
1183 'iso-8859-15': 'en_US.ISO8859-15',
1184 'iso8859-1': 'en_US.ISO8859-1',
1185 'iso8859-15': 'en_US.ISO8859-15',
1186 'iso_8859_1': 'en_US.ISO8859-1',
1187 'iso_8859_15': 'en_US.ISO8859-15',
1188 'it': 'it_IT.ISO8859-1',
Antoine Pitroufc531532010-04-11 22:32:39 +00001189 'it.iso885915': 'it_IT.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001190 'it_ch': 'it_CH.ISO8859-1',
1191 'it_ch.iso88591': 'it_CH.ISO8859-1',
1192 'it_ch.iso885915': 'it_CH.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001193 'it_ch@euro': 'it_CH.ISO8859-15',
1194 'it_it': 'it_IT.ISO8859-1',
1195 'it_it.88591': 'it_IT.ISO8859-1',
1196 'it_it.iso88591': 'it_IT.ISO8859-1',
1197 'it_it.iso885915': 'it_IT.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001198 'it_it.iso885915@euro': 'it_IT.ISO8859-15',
1199 'it_it.utf8@euro': 'it_IT.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001200 'it_it@euro': 'it_IT.ISO8859-15',
1201 'italian': 'it_IT.ISO8859-1',
1202 'italian.iso88591': 'it_IT.ISO8859-1',
1203 'iu': 'iu_CA.NUNACOM-8',
1204 'iu_ca': 'iu_CA.NUNACOM-8',
1205 'iu_ca.nunacom8': 'iu_CA.NUNACOM-8',
1206 'iw': 'he_IL.ISO8859-8',
1207 'iw_il': 'he_IL.ISO8859-8',
1208 'iw_il.iso88598': 'he_IL.ISO8859-8',
1209 'ja': 'ja_JP.eucJP',
1210 'ja.jis': 'ja_JP.JIS7',
1211 'ja.sjis': 'ja_JP.SJIS',
1212 'ja_jp': 'ja_JP.eucJP',
1213 'ja_jp.ajec': 'ja_JP.eucJP',
1214 'ja_jp.euc': 'ja_JP.eucJP',
1215 'ja_jp.eucjp': 'ja_JP.eucJP',
1216 'ja_jp.iso-2022-jp': 'ja_JP.JIS7',
1217 'ja_jp.iso2022jp': 'ja_JP.JIS7',
1218 'ja_jp.jis': 'ja_JP.JIS7',
1219 'ja_jp.jis7': 'ja_JP.JIS7',
1220 'ja_jp.mscode': 'ja_JP.SJIS',
Antoine Pitroufc531532010-04-11 22:32:39 +00001221 'ja_jp.pck': 'ja_JP.SJIS',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001222 'ja_jp.sjis': 'ja_JP.SJIS',
1223 'ja_jp.ujis': 'ja_JP.eucJP',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001224 'japan': 'ja_JP.eucJP',
1225 'japanese': 'ja_JP.eucJP',
1226 'japanese-euc': 'ja_JP.eucJP',
1227 'japanese.euc': 'ja_JP.eucJP',
1228 'japanese.sjis': 'ja_JP.SJIS',
1229 'jp_jp': 'ja_JP.eucJP',
1230 'ka': 'ka_GE.GEORGIAN-ACADEMY',
1231 'ka_ge': 'ka_GE.GEORGIAN-ACADEMY',
1232 'ka_ge.georgianacademy': 'ka_GE.GEORGIAN-ACADEMY',
1233 'ka_ge.georgianps': 'ka_GE.GEORGIAN-PS',
1234 'ka_ge.georgianrs': 'ka_GE.GEORGIAN-ACADEMY',
1235 'kl': 'kl_GL.ISO8859-1',
1236 'kl_gl': 'kl_GL.ISO8859-1',
1237 'kl_gl.iso88591': 'kl_GL.ISO8859-1',
1238 'kl_gl.iso885915': 'kl_GL.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001239 'kl_gl@euro': 'kl_GL.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001240 'km_kh': 'km_KH.UTF-8',
Antoine Pitroufc531532010-04-11 22:32:39 +00001241 'kn': 'kn_IN.UTF-8',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001242 'kn_in': 'kn_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001243 'ko': 'ko_KR.eucKR',
1244 'ko_kr': 'ko_KR.eucKR',
1245 'ko_kr.euc': 'ko_KR.eucKR',
1246 'ko_kr.euckr': 'ko_KR.eucKR',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001247 'korean': 'ko_KR.eucKR',
1248 'korean.euc': 'ko_KR.eucKR',
Antoine Pitroufc531532010-04-11 22:32:39 +00001249 'ks': 'ks_IN.UTF-8',
1250 'ks_in@devanagari': 'ks_IN@devanagari.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001251 'kw': 'kw_GB.ISO8859-1',
1252 'kw_gb': 'kw_GB.ISO8859-1',
1253 'kw_gb.iso88591': 'kw_GB.ISO8859-1',
1254 'kw_gb.iso885914': 'kw_GB.ISO8859-14',
1255 'kw_gb.iso885915': 'kw_GB.ISO8859-15',
1256 'kw_gb@euro': 'kw_GB.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001257 'ky': 'ky_KG.UTF-8',
1258 'ky_kg': 'ky_KG.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001259 'lithuanian': 'lt_LT.ISO8859-13',
1260 'lo': 'lo_LA.MULELAO-1',
1261 'lo_la': 'lo_LA.MULELAO-1',
1262 'lo_la.cp1133': 'lo_LA.IBM-CP1133',
1263 'lo_la.ibmcp1133': 'lo_LA.IBM-CP1133',
1264 'lo_la.mulelao1': 'lo_LA.MULELAO-1',
1265 'lt': 'lt_LT.ISO8859-13',
1266 'lt_lt': 'lt_LT.ISO8859-13',
1267 'lt_lt.iso885913': 'lt_LT.ISO8859-13',
1268 'lt_lt.iso88594': 'lt_LT.ISO8859-4',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001269 'lv': 'lv_LV.ISO8859-13',
1270 'lv_lv': 'lv_LV.ISO8859-13',
1271 'lv_lv.iso885913': 'lv_LV.ISO8859-13',
1272 'lv_lv.iso88594': 'lv_LV.ISO8859-4',
Antoine Pitroufc531532010-04-11 22:32:39 +00001273 'mai': 'mai_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001274 'mi': 'mi_NZ.ISO8859-1',
1275 'mi_nz': 'mi_NZ.ISO8859-1',
1276 'mi_nz.iso88591': 'mi_NZ.ISO8859-1',
1277 'mk': 'mk_MK.ISO8859-5',
1278 'mk_mk': 'mk_MK.ISO8859-5',
1279 'mk_mk.cp1251': 'mk_MK.CP1251',
1280 'mk_mk.iso88595': 'mk_MK.ISO8859-5',
1281 'mk_mk.microsoftcp1251': 'mk_MK.CP1251',
Antoine Pitroufc531532010-04-11 22:32:39 +00001282 'ml': 'ml_IN.UTF-8',
1283 'mr': 'mr_IN.UTF-8',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001284 'mr_in': 'mr_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001285 'ms': 'ms_MY.ISO8859-1',
1286 'ms_my': 'ms_MY.ISO8859-1',
1287 'ms_my.iso88591': 'ms_MY.ISO8859-1',
1288 'mt': 'mt_MT.ISO8859-3',
1289 'mt_mt': 'mt_MT.ISO8859-3',
1290 'mt_mt.iso88593': 'mt_MT.ISO8859-3',
1291 'nb': 'nb_NO.ISO8859-1',
1292 'nb_no': 'nb_NO.ISO8859-1',
1293 'nb_no.88591': 'nb_NO.ISO8859-1',
1294 'nb_no.iso88591': 'nb_NO.ISO8859-1',
1295 'nb_no.iso885915': 'nb_NO.ISO8859-15',
1296 'nb_no@euro': 'nb_NO.ISO8859-15',
1297 'nl': 'nl_NL.ISO8859-1',
Antoine Pitroufc531532010-04-11 22:32:39 +00001298 'nl.iso885915': 'nl_NL.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001299 'nl_be': 'nl_BE.ISO8859-1',
1300 'nl_be.88591': 'nl_BE.ISO8859-1',
1301 'nl_be.iso88591': 'nl_BE.ISO8859-1',
1302 'nl_be.iso885915': 'nl_BE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001303 'nl_be.iso885915@euro': 'nl_BE.ISO8859-15',
1304 'nl_be.utf8@euro': 'nl_BE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001305 'nl_be@euro': 'nl_BE.ISO8859-15',
1306 'nl_nl': 'nl_NL.ISO8859-1',
1307 'nl_nl.88591': 'nl_NL.ISO8859-1',
1308 'nl_nl.iso88591': 'nl_NL.ISO8859-1',
1309 'nl_nl.iso885915': 'nl_NL.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001310 'nl_nl.iso885915@euro': 'nl_NL.ISO8859-15',
1311 'nl_nl.utf8@euro': 'nl_NL.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001312 'nl_nl@euro': 'nl_NL.ISO8859-15',
1313 'nn': 'nn_NO.ISO8859-1',
1314 'nn_no': 'nn_NO.ISO8859-1',
1315 'nn_no.88591': 'nn_NO.ISO8859-1',
1316 'nn_no.iso88591': 'nn_NO.ISO8859-1',
1317 'nn_no.iso885915': 'nn_NO.ISO8859-15',
1318 'nn_no@euro': 'nn_NO.ISO8859-15',
1319 'no': 'no_NO.ISO8859-1',
1320 'no@nynorsk': 'ny_NO.ISO8859-1',
1321 'no_no': 'no_NO.ISO8859-1',
1322 'no_no.88591': 'no_NO.ISO8859-1',
1323 'no_no.iso88591': 'no_NO.ISO8859-1',
1324 'no_no.iso885915': 'no_NO.ISO8859-15',
Antoine Pitroufc531532010-04-11 22:32:39 +00001325 'no_no.iso88591@bokmal': 'no_NO.ISO8859-1',
1326 'no_no.iso88591@nynorsk': 'no_NO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001327 'no_no@euro': 'no_NO.ISO8859-15',
1328 'norwegian': 'no_NO.ISO8859-1',
1329 'norwegian.iso88591': 'no_NO.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001330 'nr': 'nr_ZA.ISO8859-1',
1331 'nr_za': 'nr_ZA.ISO8859-1',
1332 'nr_za.iso88591': 'nr_ZA.ISO8859-1',
1333 'nso': 'nso_ZA.ISO8859-15',
1334 'nso_za': 'nso_ZA.ISO8859-15',
1335 'nso_za.iso885915': 'nso_ZA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001336 'ny': 'ny_NO.ISO8859-1',
1337 'ny_no': 'ny_NO.ISO8859-1',
1338 'ny_no.88591': 'ny_NO.ISO8859-1',
1339 'ny_no.iso88591': 'ny_NO.ISO8859-1',
1340 'ny_no.iso885915': 'ny_NO.ISO8859-15',
1341 'ny_no@euro': 'ny_NO.ISO8859-15',
1342 'nynorsk': 'nn_NO.ISO8859-1',
1343 'oc': 'oc_FR.ISO8859-1',
1344 'oc_fr': 'oc_FR.ISO8859-1',
1345 'oc_fr.iso88591': 'oc_FR.ISO8859-1',
1346 'oc_fr.iso885915': 'oc_FR.ISO8859-15',
1347 'oc_fr@euro': 'oc_FR.ISO8859-15',
Antoine Pitroufc531532010-04-11 22:32:39 +00001348 'or': 'or_IN.UTF-8',
1349 'pa': 'pa_IN.UTF-8',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001350 'pa_in': 'pa_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001351 'pd': 'pd_US.ISO8859-1',
1352 'pd_de': 'pd_DE.ISO8859-1',
1353 'pd_de.iso88591': 'pd_DE.ISO8859-1',
1354 'pd_de.iso885915': 'pd_DE.ISO8859-15',
1355 'pd_de@euro': 'pd_DE.ISO8859-15',
1356 'pd_us': 'pd_US.ISO8859-1',
1357 'pd_us.iso88591': 'pd_US.ISO8859-1',
1358 'pd_us.iso885915': 'pd_US.ISO8859-15',
1359 'pd_us@euro': 'pd_US.ISO8859-15',
1360 'ph': 'ph_PH.ISO8859-1',
1361 'ph_ph': 'ph_PH.ISO8859-1',
1362 'ph_ph.iso88591': 'ph_PH.ISO8859-1',
1363 'pl': 'pl_PL.ISO8859-2',
1364 'pl_pl': 'pl_PL.ISO8859-2',
1365 'pl_pl.iso88592': 'pl_PL.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001366 'polish': 'pl_PL.ISO8859-2',
1367 'portuguese': 'pt_PT.ISO8859-1',
1368 'portuguese.iso88591': 'pt_PT.ISO8859-1',
1369 'portuguese_brazil': 'pt_BR.ISO8859-1',
1370 'portuguese_brazil.8859': 'pt_BR.ISO8859-1',
1371 'posix': 'C',
1372 'posix-utf2': 'C',
1373 'pp': 'pp_AN.ISO8859-1',
1374 'pp_an': 'pp_AN.ISO8859-1',
1375 'pp_an.iso88591': 'pp_AN.ISO8859-1',
1376 'pt': 'pt_PT.ISO8859-1',
Antoine Pitroufc531532010-04-11 22:32:39 +00001377 'pt.iso885915': 'pt_PT.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001378 'pt_br': 'pt_BR.ISO8859-1',
1379 'pt_br.88591': 'pt_BR.ISO8859-1',
1380 'pt_br.iso88591': 'pt_BR.ISO8859-1',
1381 'pt_br.iso885915': 'pt_BR.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001382 'pt_br@euro': 'pt_BR.ISO8859-15',
1383 'pt_pt': 'pt_PT.ISO8859-1',
1384 'pt_pt.88591': 'pt_PT.ISO8859-1',
1385 'pt_pt.iso88591': 'pt_PT.ISO8859-1',
1386 'pt_pt.iso885915': 'pt_PT.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001387 'pt_pt.iso885915@euro': 'pt_PT.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001388 'pt_pt.utf8@euro': 'pt_PT.UTF-8',
1389 'pt_pt@euro': 'pt_PT.ISO8859-15',
1390 'ro': 'ro_RO.ISO8859-2',
1391 'ro_ro': 'ro_RO.ISO8859-2',
1392 'ro_ro.iso88592': 'ro_RO.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001393 'romanian': 'ro_RO.ISO8859-2',
Antoine Pitroufc531532010-04-11 22:32:39 +00001394 'ru': 'ru_RU.UTF-8',
1395 'ru.koi8r': 'ru_RU.KOI8-R',
1396 'ru_ru': 'ru_RU.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001397 'ru_ru.cp1251': 'ru_RU.CP1251',
1398 'ru_ru.iso88595': 'ru_RU.ISO8859-5',
1399 'ru_ru.koi8r': 'ru_RU.KOI8-R',
1400 'ru_ru.microsoftcp1251': 'ru_RU.CP1251',
1401 'ru_ua': 'ru_UA.KOI8-U',
1402 'ru_ua.cp1251': 'ru_UA.CP1251',
1403 'ru_ua.koi8u': 'ru_UA.KOI8-U',
1404 'ru_ua.microsoftcp1251': 'ru_UA.CP1251',
1405 'rumanian': 'ro_RO.ISO8859-2',
1406 'russian': 'ru_RU.ISO8859-5',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001407 'rw': 'rw_RW.ISO8859-1',
1408 'rw_rw': 'rw_RW.ISO8859-1',
1409 'rw_rw.iso88591': 'rw_RW.ISO8859-1',
Antoine Pitroufc531532010-04-11 22:32:39 +00001410 'sd': 'sd_IN@devanagari.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001411 'se_no': 'se_NO.UTF-8',
Antoine Pitroufc531532010-04-11 22:32:39 +00001412 'serbocroatian': 'sr_RS.UTF-8@latin',
1413 'sh': 'sr_RS.UTF-8@latin',
1414 'sh_ba.iso88592@bosnia': 'sr_CS.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001415 'sh_hr': 'sh_HR.ISO8859-2',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001416 'sh_hr.iso88592': 'hr_HR.ISO8859-2',
1417 'sh_sp': 'sr_CS.ISO8859-2',
Antoine Pitroufc531532010-04-11 22:32:39 +00001418 'sh_yu': 'sr_RS.UTF-8@latin',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001419 'si': 'si_LK.UTF-8',
1420 'si_lk': 'si_LK.UTF-8',
1421 'sinhala': 'si_LK.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001422 'sk': 'sk_SK.ISO8859-2',
1423 'sk_sk': 'sk_SK.ISO8859-2',
1424 'sk_sk.iso88592': 'sk_SK.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001425 'sl': 'sl_SI.ISO8859-2',
1426 'sl_cs': 'sl_CS.ISO8859-2',
1427 'sl_si': 'sl_SI.ISO8859-2',
1428 'sl_si.iso88592': 'sl_SI.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001429 'slovak': 'sk_SK.ISO8859-2',
1430 'slovene': 'sl_SI.ISO8859-2',
1431 'slovenian': 'sl_SI.ISO8859-2',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001432 'sp': 'sr_CS.ISO8859-5',
1433 'sp_yu': 'sr_CS.ISO8859-5',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001434 'spanish': 'es_ES.ISO8859-1',
1435 'spanish.iso88591': 'es_ES.ISO8859-1',
1436 'spanish_spain': 'es_ES.ISO8859-1',
1437 'spanish_spain.8859': 'es_ES.ISO8859-1',
1438 'sq': 'sq_AL.ISO8859-2',
1439 'sq_al': 'sq_AL.ISO8859-2',
1440 'sq_al.iso88592': 'sq_AL.ISO8859-2',
Antoine Pitroufc531532010-04-11 22:32:39 +00001441 'sr': 'sr_RS.UTF-8',
1442 'sr@cyrillic': 'sr_RS.UTF-8',
1443 'sr@latin': 'sr_RS.UTF-8@latin',
1444 'sr@latn': 'sr_RS.UTF-8@latin',
1445 'sr_cs': 'sr_RS.UTF-8',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001446 'sr_cs.iso88592': 'sr_CS.ISO8859-2',
1447 'sr_cs.iso88592@latn': 'sr_CS.ISO8859-2',
1448 'sr_cs.iso88595': 'sr_CS.ISO8859-5',
Antoine Pitroufc531532010-04-11 22:32:39 +00001449 'sr_cs.utf8@latn': 'sr_RS.UTF-8@latin',
1450 'sr_cs@latn': 'sr_RS.UTF-8@latin',
1451 'sr_me': 'sr_ME.UTF-8',
1452 'sr_rs': 'sr_RS.UTF-8',
1453 'sr_rs.utf8@latn': 'sr_RS.UTF-8@latin',
1454 'sr_rs@latin': 'sr_RS.UTF-8@latin',
1455 'sr_rs@latn': 'sr_RS.UTF-8@latin',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001456 'sr_sp': 'sr_CS.ISO8859-2',
Antoine Pitroufc531532010-04-11 22:32:39 +00001457 'sr_yu': 'sr_RS.UTF-8@latin',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001458 'sr_yu.cp1251@cyrillic': 'sr_CS.CP1251',
1459 'sr_yu.iso88592': 'sr_CS.ISO8859-2',
1460 'sr_yu.iso88595': 'sr_CS.ISO8859-5',
1461 'sr_yu.iso88595@cyrillic': 'sr_CS.ISO8859-5',
1462 'sr_yu.microsoftcp1251@cyrillic': 'sr_CS.CP1251',
Antoine Pitroufc531532010-04-11 22:32:39 +00001463 'sr_yu.utf8@cyrillic': 'sr_RS.UTF-8',
1464 'sr_yu@cyrillic': 'sr_RS.UTF-8',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001465 'ss': 'ss_ZA.ISO8859-1',
1466 'ss_za': 'ss_ZA.ISO8859-1',
1467 'ss_za.iso88591': 'ss_ZA.ISO8859-1',
1468 'st': 'st_ZA.ISO8859-1',
1469 'st_za': 'st_ZA.ISO8859-1',
1470 'st_za.iso88591': 'st_ZA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001471 'sv': 'sv_SE.ISO8859-1',
Antoine Pitroufc531532010-04-11 22:32:39 +00001472 'sv.iso885915': 'sv_SE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001473 'sv_fi': 'sv_FI.ISO8859-1',
1474 'sv_fi.iso88591': 'sv_FI.ISO8859-1',
1475 'sv_fi.iso885915': 'sv_FI.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001476 'sv_fi.iso885915@euro': 'sv_FI.ISO8859-15',
1477 'sv_fi.utf8@euro': 'sv_FI.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001478 'sv_fi@euro': 'sv_FI.ISO8859-15',
1479 'sv_se': 'sv_SE.ISO8859-1',
1480 'sv_se.88591': 'sv_SE.ISO8859-1',
1481 'sv_se.iso88591': 'sv_SE.ISO8859-1',
1482 'sv_se.iso885915': 'sv_SE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001483 'sv_se@euro': 'sv_SE.ISO8859-15',
1484 'swedish': 'sv_SE.ISO8859-1',
1485 'swedish.iso88591': 'sv_SE.ISO8859-1',
1486 'ta': 'ta_IN.TSCII-0',
1487 'ta_in': 'ta_IN.TSCII-0',
1488 'ta_in.tscii': 'ta_IN.TSCII-0',
1489 'ta_in.tscii0': 'ta_IN.TSCII-0',
Antoine Pitroufc531532010-04-11 22:32:39 +00001490 'te': 'te_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001491 'tg': 'tg_TJ.KOI8-C',
1492 'tg_tj': 'tg_TJ.KOI8-C',
1493 'tg_tj.koi8c': 'tg_TJ.KOI8-C',
1494 'th': 'th_TH.ISO8859-11',
1495 'th_th': 'th_TH.ISO8859-11',
1496 'th_th.iso885911': 'th_TH.ISO8859-11',
1497 'th_th.tactis': 'th_TH.TIS620',
1498 'th_th.tis620': 'th_TH.TIS620',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001499 'thai': 'th_TH.ISO8859-11',
1500 'tl': 'tl_PH.ISO8859-1',
1501 'tl_ph': 'tl_PH.ISO8859-1',
1502 'tl_ph.iso88591': 'tl_PH.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001503 'tn': 'tn_ZA.ISO8859-15',
1504 'tn_za': 'tn_ZA.ISO8859-15',
1505 'tn_za.iso885915': 'tn_ZA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001506 'tr': 'tr_TR.ISO8859-9',
1507 'tr_tr': 'tr_TR.ISO8859-9',
1508 'tr_tr.iso88599': 'tr_TR.ISO8859-9',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001509 'ts': 'ts_ZA.ISO8859-1',
1510 'ts_za': 'ts_ZA.ISO8859-1',
1511 'ts_za.iso88591': 'ts_ZA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001512 'tt': 'tt_RU.TATAR-CYR',
1513 'tt_ru': 'tt_RU.TATAR-CYR',
1514 'tt_ru.koi8c': 'tt_RU.KOI8-C',
1515 'tt_ru.tatarcyr': 'tt_RU.TATAR-CYR',
1516 'turkish': 'tr_TR.ISO8859-9',
1517 'turkish.iso88599': 'tr_TR.ISO8859-9',
1518 'uk': 'uk_UA.KOI8-U',
1519 'uk_ua': 'uk_UA.KOI8-U',
1520 'uk_ua.cp1251': 'uk_UA.CP1251',
1521 'uk_ua.iso88595': 'uk_UA.ISO8859-5',
1522 'uk_ua.koi8u': 'uk_UA.KOI8-U',
1523 'uk_ua.microsoftcp1251': 'uk_UA.CP1251',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001524 'univ': 'en_US.utf',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001525 'universal': 'en_US.utf',
1526 'universal.utf8@ucs4': 'en_US.UTF-8',
1527 'ur': 'ur_PK.CP1256',
1528 'ur_pk': 'ur_PK.CP1256',
1529 'ur_pk.cp1256': 'ur_PK.CP1256',
1530 'ur_pk.microsoftcp1256': 'ur_PK.CP1256',
1531 'uz': 'uz_UZ.UTF-8',
1532 'uz_uz': 'uz_UZ.UTF-8',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001533 'uz_uz.iso88591': 'uz_UZ.ISO8859-1',
1534 'uz_uz.utf8@cyrillic': 'uz_UZ.UTF-8',
1535 'uz_uz@cyrillic': 'uz_UZ.UTF-8',
1536 've': 've_ZA.UTF-8',
1537 've_za': 've_ZA.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001538 'vi': 'vi_VN.TCVN',
1539 'vi_vn': 'vi_VN.TCVN',
1540 'vi_vn.tcvn': 'vi_VN.TCVN',
1541 'vi_vn.tcvn5712': 'vi_VN.TCVN',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001542 'vi_vn.viscii': 'vi_VN.VISCII',
1543 'vi_vn.viscii111': 'vi_VN.VISCII',
1544 'wa': 'wa_BE.ISO8859-1',
1545 'wa_be': 'wa_BE.ISO8859-1',
1546 'wa_be.iso88591': 'wa_BE.ISO8859-1',
1547 'wa_be.iso885915': 'wa_BE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001548 'wa_be.iso885915@euro': 'wa_BE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001549 'wa_be@euro': 'wa_BE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001550 'xh': 'xh_ZA.ISO8859-1',
1551 'xh_za': 'xh_ZA.ISO8859-1',
1552 'xh_za.iso88591': 'xh_ZA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001553 'yi': 'yi_US.CP1255',
1554 'yi_us': 'yi_US.CP1255',
1555 'yi_us.cp1255': 'yi_US.CP1255',
1556 'yi_us.microsoftcp1255': 'yi_US.CP1255',
1557 'zh': 'zh_CN.eucCN',
1558 'zh_cn': 'zh_CN.gb2312',
1559 'zh_cn.big5': 'zh_TW.big5',
1560 'zh_cn.euc': 'zh_CN.eucCN',
1561 'zh_cn.gb18030': 'zh_CN.gb18030',
1562 'zh_cn.gb2312': 'zh_CN.gb2312',
1563 'zh_cn.gbk': 'zh_CN.gbk',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001564 'zh_hk': 'zh_HK.big5hkscs',
1565 'zh_hk.big5': 'zh_HK.big5',
Antoine Pitroufc531532010-04-11 22:32:39 +00001566 'zh_hk.big5hk': 'zh_HK.big5hkscs',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001567 'zh_hk.big5hkscs': 'zh_HK.big5hkscs',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001568 'zh_tw': 'zh_TW.big5',
1569 'zh_tw.big5': 'zh_TW.big5',
1570 'zh_tw.euc': 'zh_TW.eucTW',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001571 'zh_tw.euctw': 'zh_TW.eucTW',
1572 'zu': 'zu_ZA.ISO8859-1',
1573 'zu_za': 'zu_ZA.ISO8859-1',
1574 'zu_za.iso88591': 'zu_ZA.ISO8859-1',
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001575}
1576
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001577#
Georg Brandlb709c2c2006-01-20 09:07:35 +00001578# This maps Windows language identifiers to locale strings.
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001579#
Tim Peters777f1082006-01-20 20:03:24 +00001580# This list has been updated from
Georg Brandlb709c2c2006-01-20 09:07:35 +00001581# http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nls_238z.asp
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001582# to include every locale up to Windows Vista.
Fredrik Lundh37a09822002-10-19 20:19:10 +00001583#
Georg Brandl5035c1c2006-01-20 13:38:26 +00001584# NOTE: this mapping is incomplete. If your language is missing, please
1585# submit a bug report to Python bug manager, which you can find via:
1586# http://www.python.org/dev/
1587# Make sure you include the missing language identifier and the suggested
1588# locale code.
1589#
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001590
1591windows_locale = {
Georg Brandlb709c2c2006-01-20 09:07:35 +00001592 0x0436: "af_ZA", # Afrikaans
1593 0x041c: "sq_AL", # Albanian
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001594 0x0484: "gsw_FR",# Alsatian - France
1595 0x045e: "am_ET", # Amharic - Ethiopia
Georg Brandlb709c2c2006-01-20 09:07:35 +00001596 0x0401: "ar_SA", # Arabic - Saudi Arabia
1597 0x0801: "ar_IQ", # Arabic - Iraq
1598 0x0c01: "ar_EG", # Arabic - Egypt
1599 0x1001: "ar_LY", # Arabic - Libya
1600 0x1401: "ar_DZ", # Arabic - Algeria
1601 0x1801: "ar_MA", # Arabic - Morocco
1602 0x1c01: "ar_TN", # Arabic - Tunisia
1603 0x2001: "ar_OM", # Arabic - Oman
1604 0x2401: "ar_YE", # Arabic - Yemen
1605 0x2801: "ar_SY", # Arabic - Syria
1606 0x2c01: "ar_JO", # Arabic - Jordan
1607 0x3001: "ar_LB", # Arabic - Lebanon
1608 0x3401: "ar_KW", # Arabic - Kuwait
1609 0x3801: "ar_AE", # Arabic - United Arab Emirates
1610 0x3c01: "ar_BH", # Arabic - Bahrain
1611 0x4001: "ar_QA", # Arabic - Qatar
1612 0x042b: "hy_AM", # Armenian
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001613 0x044d: "as_IN", # Assamese - India
1614 0x042c: "az_AZ", # Azeri - Latin
Georg Brandlb709c2c2006-01-20 09:07:35 +00001615 0x082c: "az_AZ", # Azeri - Cyrillic
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001616 0x046d: "ba_RU", # Bashkir
1617 0x042d: "eu_ES", # Basque - Russia
Georg Brandlb709c2c2006-01-20 09:07:35 +00001618 0x0423: "be_BY", # Belarusian
1619 0x0445: "bn_IN", # Begali
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001620 0x201a: "bs_BA", # Bosnian - Cyrillic
1621 0x141a: "bs_BA", # Bosnian - Latin
Georg Brandlb709c2c2006-01-20 09:07:35 +00001622 0x047e: "br_FR", # Breton - France
1623 0x0402: "bg_BG", # Bulgarian
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001624# 0x0455: "my_MM", # Burmese - Not supported
Georg Brandlb709c2c2006-01-20 09:07:35 +00001625 0x0403: "ca_ES", # Catalan
1626 0x0004: "zh_CHS",# Chinese - Simplified
1627 0x0404: "zh_TW", # Chinese - Taiwan
1628 0x0804: "zh_CN", # Chinese - PRC
1629 0x0c04: "zh_HK", # Chinese - Hong Kong S.A.R.
1630 0x1004: "zh_SG", # Chinese - Singapore
1631 0x1404: "zh_MO", # Chinese - Macao S.A.R.
1632 0x7c04: "zh_CHT",# Chinese - Traditional
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001633 0x0483: "co_FR", # Corsican - France
Georg Brandlb709c2c2006-01-20 09:07:35 +00001634 0x041a: "hr_HR", # Croatian
1635 0x101a: "hr_BA", # Croatian - Bosnia
1636 0x0405: "cs_CZ", # Czech
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001637 0x0406: "da_DK", # Danish
Georg Brandlb709c2c2006-01-20 09:07:35 +00001638 0x048c: "gbz_AF",# Dari - Afghanistan
1639 0x0465: "div_MV",# Divehi - Maldives
1640 0x0413: "nl_NL", # Dutch - The Netherlands
1641 0x0813: "nl_BE", # Dutch - Belgium
1642 0x0409: "en_US", # English - United States
1643 0x0809: "en_GB", # English - United Kingdom
1644 0x0c09: "en_AU", # English - Australia
1645 0x1009: "en_CA", # English - Canada
1646 0x1409: "en_NZ", # English - New Zealand
1647 0x1809: "en_IE", # English - Ireland
1648 0x1c09: "en_ZA", # English - South Africa
1649 0x2009: "en_JA", # English - Jamaica
1650 0x2409: "en_CB", # English - Carribbean
1651 0x2809: "en_BZ", # English - Belize
1652 0x2c09: "en_TT", # English - Trinidad
1653 0x3009: "en_ZW", # English - Zimbabwe
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001654 0x3409: "en_PH", # English - Philippines
1655 0x4009: "en_IN", # English - India
1656 0x4409: "en_MY", # English - Malaysia
1657 0x4809: "en_IN", # English - Singapore
Georg Brandlb709c2c2006-01-20 09:07:35 +00001658 0x0425: "et_EE", # Estonian
1659 0x0438: "fo_FO", # Faroese
1660 0x0464: "fil_PH",# Filipino
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001661 0x040b: "fi_FI", # Finnish
Georg Brandlb709c2c2006-01-20 09:07:35 +00001662 0x040c: "fr_FR", # French - France
1663 0x080c: "fr_BE", # French - Belgium
1664 0x0c0c: "fr_CA", # French - Canada
1665 0x100c: "fr_CH", # French - Switzerland
1666 0x140c: "fr_LU", # French - Luxembourg
1667 0x180c: "fr_MC", # French - Monaco
1668 0x0462: "fy_NL", # Frisian - Netherlands
1669 0x0456: "gl_ES", # Galician
1670 0x0437: "ka_GE", # Georgian
1671 0x0407: "de_DE", # German - Germany
1672 0x0807: "de_CH", # German - Switzerland
1673 0x0c07: "de_AT", # German - Austria
1674 0x1007: "de_LU", # German - Luxembourg
1675 0x1407: "de_LI", # German - Liechtenstein
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001676 0x0408: "el_GR", # Greek
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001677 0x046f: "kl_GL", # Greenlandic - Greenland
Georg Brandlb709c2c2006-01-20 09:07:35 +00001678 0x0447: "gu_IN", # Gujarati
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001679 0x0468: "ha_NG", # Hausa - Latin
Georg Brandlb709c2c2006-01-20 09:07:35 +00001680 0x040d: "he_IL", # Hebrew
1681 0x0439: "hi_IN", # Hindi
1682 0x040e: "hu_HU", # Hungarian
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001683 0x040f: "is_IS", # Icelandic
Georg Brandlb709c2c2006-01-20 09:07:35 +00001684 0x0421: "id_ID", # Indonesian
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001685 0x045d: "iu_CA", # Inuktitut - Syllabics
Georg Brandlb709c2c2006-01-20 09:07:35 +00001686 0x085d: "iu_CA", # Inuktitut - Latin
1687 0x083c: "ga_IE", # Irish - Ireland
Georg Brandlb709c2c2006-01-20 09:07:35 +00001688 0x0410: "it_IT", # Italian - Italy
1689 0x0810: "it_CH", # Italian - Switzerland
1690 0x0411: "ja_JP", # Japanese
1691 0x044b: "kn_IN", # Kannada - India
1692 0x043f: "kk_KZ", # Kazakh
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001693 0x0453: "kh_KH", # Khmer - Cambodia
1694 0x0486: "qut_GT",# K'iche - Guatemala
1695 0x0487: "rw_RW", # Kinyarwanda - Rwanda
Georg Brandlb709c2c2006-01-20 09:07:35 +00001696 0x0457: "kok_IN",# Konkani
1697 0x0412: "ko_KR", # Korean
1698 0x0440: "ky_KG", # Kyrgyz
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001699 0x0454: "lo_LA", # Lao - Lao PDR
Georg Brandlb709c2c2006-01-20 09:07:35 +00001700 0x0426: "lv_LV", # Latvian
1701 0x0427: "lt_LT", # Lithuanian
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001702 0x082e: "dsb_DE",# Lower Sorbian - Germany
Georg Brandlb709c2c2006-01-20 09:07:35 +00001703 0x046e: "lb_LU", # Luxembourgish
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001704 0x042f: "mk_MK", # FYROM Macedonian
Georg Brandlb709c2c2006-01-20 09:07:35 +00001705 0x043e: "ms_MY", # Malay - Malaysia
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001706 0x083e: "ms_BN", # Malay - Brunei Darussalam
Georg Brandlb709c2c2006-01-20 09:07:35 +00001707 0x044c: "ml_IN", # Malayalam - India
1708 0x043a: "mt_MT", # Maltese
1709 0x0481: "mi_NZ", # Maori
1710 0x047a: "arn_CL",# Mapudungun
1711 0x044e: "mr_IN", # Marathi
1712 0x047c: "moh_CA",# Mohawk - Canada
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001713 0x0450: "mn_MN", # Mongolian - Cyrillic
1714 0x0850: "mn_CN", # Mongolian - PRC
Georg Brandlb709c2c2006-01-20 09:07:35 +00001715 0x0461: "ne_NP", # Nepali
1716 0x0414: "nb_NO", # Norwegian - Bokmal
1717 0x0814: "nn_NO", # Norwegian - Nynorsk
1718 0x0482: "oc_FR", # Occitan - France
1719 0x0448: "or_IN", # Oriya - India
1720 0x0463: "ps_AF", # Pashto - Afghanistan
1721 0x0429: "fa_IR", # Persian
1722 0x0415: "pl_PL", # Polish
1723 0x0416: "pt_BR", # Portuguese - Brazil
1724 0x0816: "pt_PT", # Portuguese - Portugal
1725 0x0446: "pa_IN", # Punjabi
1726 0x046b: "quz_BO",# Quechua (Bolivia)
1727 0x086b: "quz_EC",# Quechua (Ecuador)
1728 0x0c6b: "quz_PE",# Quechua (Peru)
1729 0x0418: "ro_RO", # Romanian - Romania
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001730 0x0417: "rm_CH", # Romansh
Georg Brandlb709c2c2006-01-20 09:07:35 +00001731 0x0419: "ru_RU", # Russian
1732 0x243b: "smn_FI",# Sami Finland
1733 0x103b: "smj_NO",# Sami Norway
1734 0x143b: "smj_SE",# Sami Sweden
1735 0x043b: "se_NO", # Sami Northern Norway
1736 0x083b: "se_SE", # Sami Northern Sweden
1737 0x0c3b: "se_FI", # Sami Northern Finland
1738 0x203b: "sms_FI",# Sami Skolt
1739 0x183b: "sma_NO",# Sami Southern Norway
1740 0x1c3b: "sma_SE",# Sami Southern Sweden
1741 0x044f: "sa_IN", # Sanskrit
1742 0x0c1a: "sr_SP", # Serbian - Cyrillic
1743 0x1c1a: "sr_BA", # Serbian - Bosnia Cyrillic
1744 0x081a: "sr_SP", # Serbian - Latin
1745 0x181a: "sr_BA", # Serbian - Bosnia Latin
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001746 0x045b: "si_LK", # Sinhala - Sri Lanka
Georg Brandlb709c2c2006-01-20 09:07:35 +00001747 0x046c: "ns_ZA", # Northern Sotho
1748 0x0432: "tn_ZA", # Setswana - Southern Africa
1749 0x041b: "sk_SK", # Slovak
1750 0x0424: "sl_SI", # Slovenian
1751 0x040a: "es_ES", # Spanish - Spain
1752 0x080a: "es_MX", # Spanish - Mexico
1753 0x0c0a: "es_ES", # Spanish - Spain (Modern)
1754 0x100a: "es_GT", # Spanish - Guatemala
1755 0x140a: "es_CR", # Spanish - Costa Rica
1756 0x180a: "es_PA", # Spanish - Panama
1757 0x1c0a: "es_DO", # Spanish - Dominican Republic
1758 0x200a: "es_VE", # Spanish - Venezuela
1759 0x240a: "es_CO", # Spanish - Colombia
1760 0x280a: "es_PE", # Spanish - Peru
1761 0x2c0a: "es_AR", # Spanish - Argentina
1762 0x300a: "es_EC", # Spanish - Ecuador
1763 0x340a: "es_CL", # Spanish - Chile
1764 0x380a: "es_UR", # Spanish - Uruguay
1765 0x3c0a: "es_PY", # Spanish - Paraguay
1766 0x400a: "es_BO", # Spanish - Bolivia
1767 0x440a: "es_SV", # Spanish - El Salvador
1768 0x480a: "es_HN", # Spanish - Honduras
1769 0x4c0a: "es_NI", # Spanish - Nicaragua
1770 0x500a: "es_PR", # Spanish - Puerto Rico
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001771 0x540a: "es_US", # Spanish - United States
1772# 0x0430: "", # Sutu - Not supported
Georg Brandlb709c2c2006-01-20 09:07:35 +00001773 0x0441: "sw_KE", # Swahili
1774 0x041d: "sv_SE", # Swedish - Sweden
1775 0x081d: "sv_FI", # Swedish - Finland
1776 0x045a: "syr_SY",# Syriac
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001777 0x0428: "tg_TJ", # Tajik - Cyrillic
1778 0x085f: "tmz_DZ",# Tamazight - Latin
Georg Brandlb709c2c2006-01-20 09:07:35 +00001779 0x0449: "ta_IN", # Tamil
1780 0x0444: "tt_RU", # Tatar
1781 0x044a: "te_IN", # Telugu
1782 0x041e: "th_TH", # Thai
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001783 0x0851: "bo_BT", # Tibetan - Bhutan
1784 0x0451: "bo_CN", # Tibetan - PRC
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001785 0x041f: "tr_TR", # Turkish
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001786 0x0442: "tk_TM", # Turkmen - Cyrillic
1787 0x0480: "ug_CN", # Uighur - Arabic
Georg Brandlb709c2c2006-01-20 09:07:35 +00001788 0x0422: "uk_UA", # Ukrainian
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001789 0x042e: "wen_DE",# Upper Sorbian - Germany
Georg Brandlb709c2c2006-01-20 09:07:35 +00001790 0x0420: "ur_PK", # Urdu
1791 0x0820: "ur_IN", # Urdu - India
1792 0x0443: "uz_UZ", # Uzbek - Latin
1793 0x0843: "uz_UZ", # Uzbek - Cyrillic
1794 0x042a: "vi_VN", # Vietnamese
1795 0x0452: "cy_GB", # Welsh
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001796 0x0488: "wo_SN", # Wolof - Senegal
1797 0x0434: "xh_ZA", # Xhosa - South Africa
1798 0x0485: "sah_RU",# Yakut - Cyrillic
1799 0x0478: "ii_CN", # Yi - PRC
1800 0x046a: "yo_NG", # Yoruba - Nigeria
1801 0x0435: "zu_ZA", # Zulu
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001802}
1803
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001804def _print_locale():
1805
1806 """ Test function.
1807 """
1808 categories = {}
1809 def _init_categories(categories=categories):
1810 for k,v in globals().items():
1811 if k[:3] == 'LC_':
1812 categories[k] = v
1813 _init_categories()
1814 del categories['LC_ALL']
1815
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001816 print 'Locale defaults as determined by getdefaultlocale():'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001817 print '-'*72
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001818 lang, enc = getdefaultlocale()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001819 print 'Language: ', lang or '(undefined)'
1820 print 'Encoding: ', enc or '(undefined)'
1821 print
1822
1823 print 'Locale settings on startup:'
1824 print '-'*72
1825 for name,category in categories.items():
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001826 print name, '...'
1827 lang, enc = getlocale(category)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001828 print ' Language: ', lang or '(undefined)'
1829 print ' Encoding: ', enc or '(undefined)'
1830 print
1831
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001832 print
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001833 print 'Locale settings after calling resetlocale():'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001834 print '-'*72
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001835 resetlocale()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001836 for name,category in categories.items():
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001837 print name, '...'
1838 lang, enc = getlocale(category)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001839 print ' Language: ', lang or '(undefined)'
1840 print ' Encoding: ', enc or '(undefined)'
1841 print
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001842
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001843 try:
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001844 setlocale(LC_ALL, "")
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001845 except:
1846 print 'NOTE:'
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001847 print 'setlocale(LC_ALL, "") does not support the default locale'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001848 print 'given in the OS environment variables.'
1849 else:
1850 print
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001851 print 'Locale settings after calling setlocale(LC_ALL, ""):'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001852 print '-'*72
1853 for name,category in categories.items():
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001854 print name, '...'
1855 lang, enc = getlocale(category)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001856 print ' Language: ', lang or '(undefined)'
1857 print ' Encoding: ', enc or '(undefined)'
1858 print
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001859
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001860###
Guido van Rossumeef1d4e1997-11-19 19:01:43 +00001861
Tim Peters1baf8292001-01-24 10:13:46 +00001862try:
1863 LC_MESSAGES
Skip Montanaro0897f0c2002-03-25 21:40:36 +00001864except NameError:
Tim Peters1baf8292001-01-24 10:13:46 +00001865 pass
1866else:
1867 __all__.append("LC_MESSAGES")
1868
Guido van Rossumeef1d4e1997-11-19 19:01:43 +00001869if __name__=='__main__':
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001870 print 'Locale aliasing:'
1871 print
1872 _print_locale()
1873 print
1874 print 'Number formatting:'
1875 print
1876 _test()