blob: 7ddfdb782c0d0945413ddbfebe2fd34975a896ec [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
Martin v. Löwised11a5d2012-05-20 10:42:17 +020021try:
22 _unicode = unicode
23except NameError:
24 # If Python is built without Unicode support, the unicode type
25 # will not exist. Fake one.
26 class _unicode(object):
27 pass
28
Fredrik Lundh6c86b992000-07-09 17:12:58 +000029# Try importing the _locale module.
30#
31# If this fails, fall back on a basic 'C' locale emulation.
Guido van Rossumeef1d4e1997-11-19 19:01:43 +000032
Tim Peters1baf8292001-01-24 10:13:46 +000033# Yuck: LC_MESSAGES is non-standard: can't tell whether it exists before
34# trying the import. So __all__ is also fiddled at the end of the file.
Georg Brandl09728b72007-05-01 06:08:15 +000035__all__ = ["getlocale", "getdefaultlocale", "getpreferredencoding", "Error",
36 "setlocale", "resetlocale", "localeconv", "strcoll", "strxfrm",
37 "str", "atof", "atoi", "format", "format_string", "currency",
38 "normalize", "LC_CTYPE", "LC_COLLATE", "LC_TIME", "LC_MONETARY",
39 "LC_NUMERIC", "LC_ALL", "CHAR_MAX"]
Skip Montanaro17ab1232001-01-24 06:27:27 +000040
Marc-André Lemburg23481142000-06-08 17:49:41 +000041try:
Fredrik Lundh6c86b992000-07-09 17:12:58 +000042
Marc-André Lemburg23481142000-06-08 17:49:41 +000043 from _locale import *
44
45except ImportError:
46
Fredrik Lundh6c86b992000-07-09 17:12:58 +000047 # Locale emulation
48
Marc-André Lemburg23481142000-06-08 17:49:41 +000049 CHAR_MAX = 127
50 LC_ALL = 6
51 LC_COLLATE = 3
52 LC_CTYPE = 0
53 LC_MESSAGES = 5
54 LC_MONETARY = 4
55 LC_NUMERIC = 1
56 LC_TIME = 2
57 Error = ValueError
58
59 def localeconv():
Fredrik Lundh6c86b992000-07-09 17:12:58 +000060 """ localeconv() -> dict.
Marc-André Lemburg23481142000-06-08 17:49:41 +000061 Returns numeric and monetary locale-specific parameters.
62 """
63 # 'C' locale default values
64 return {'grouping': [127],
65 'currency_symbol': '',
66 'n_sign_posn': 127,
Fredrik Lundh6c86b992000-07-09 17:12:58 +000067 'p_cs_precedes': 127,
68 'n_cs_precedes': 127,
69 'mon_grouping': [],
Marc-André Lemburg23481142000-06-08 17:49:41 +000070 'n_sep_by_space': 127,
71 'decimal_point': '.',
72 'negative_sign': '',
73 'positive_sign': '',
Fredrik Lundh6c86b992000-07-09 17:12:58 +000074 'p_sep_by_space': 127,
Marc-André Lemburg23481142000-06-08 17:49:41 +000075 'int_curr_symbol': '',
Fredrik Lundh6c86b992000-07-09 17:12:58 +000076 'p_sign_posn': 127,
Marc-André Lemburg23481142000-06-08 17:49:41 +000077 'thousands_sep': '',
Fredrik Lundh6c86b992000-07-09 17:12:58 +000078 'mon_thousands_sep': '',
79 'frac_digits': 127,
Marc-André Lemburg23481142000-06-08 17:49:41 +000080 'mon_decimal_point': '',
81 'int_frac_digits': 127}
Fredrik Lundh6c86b992000-07-09 17:12:58 +000082
Marc-André Lemburg23481142000-06-08 17:49:41 +000083 def setlocale(category, value=None):
Fredrik Lundh6c86b992000-07-09 17:12:58 +000084 """ setlocale(integer,string=None) -> string.
Marc-André Lemburg23481142000-06-08 17:49:41 +000085 Activates/queries locale processing.
86 """
Martin v. Löwis103d6e72003-03-30 15:42:13 +000087 if value not in (None, '', 'C'):
Fredrik Lundh6c86b992000-07-09 17:12:58 +000088 raise Error, '_locale emulation only supports "C" locale'
Marc-André Lemburg23481142000-06-08 17:49:41 +000089 return 'C'
90
91 def strcoll(a,b):
Fredrik Lundh6c86b992000-07-09 17:12:58 +000092 """ strcoll(string,string) -> int.
Marc-André Lemburg23481142000-06-08 17:49:41 +000093 Compares two strings according to the locale.
94 """
95 return cmp(a,b)
96
97 def strxfrm(s):
Fredrik Lundh6c86b992000-07-09 17:12:58 +000098 """ strxfrm(string) -> string.
Marc-André Lemburg23481142000-06-08 17:49:41 +000099 Returns a string that behaves for cmp locale-aware.
100 """
101 return s
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000102
Antoine Pitrouba54eda2008-07-25 20:40:19 +0000103
104_localeconv = localeconv
105
106# With this dict, you can override some items of localeconv's return value.
107# This is useful for testing purposes.
108_override_localeconv = {}
109
110@functools.wraps(_localeconv)
111def localeconv():
112 d = _localeconv()
113 if _override_localeconv:
114 d.update(_override_localeconv)
115 return d
116
117
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000118### Number formatting APIs
119
120# Author: Martin von Loewis
Georg Brandlb89316f2006-05-17 15:51:16 +0000121# improved by Georg Brandl
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000122
Antoine Pitroufeeafff2009-03-14 00:07:21 +0000123# Iterate over grouping intervals
124def _grouping_intervals(grouping):
Mark Dickinson4b456732009-08-04 21:56:04 +0000125 last_interval = None
Antoine Pitroufeeafff2009-03-14 00:07:21 +0000126 for interval in grouping:
127 # if grouping is -1, we are done
128 if interval == CHAR_MAX:
129 return
130 # 0: re-use last group ad infinitum
131 if interval == 0:
Mark Dickinson4b456732009-08-04 21:56:04 +0000132 if last_interval is None:
133 raise ValueError("invalid grouping")
Antoine Pitroufeeafff2009-03-14 00:07:21 +0000134 while True:
135 yield last_interval
136 yield interval
137 last_interval = interval
138
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000139#perform the grouping from right to left
Georg Brandlb89316f2006-05-17 15:51:16 +0000140def _group(s, monetary=False):
141 conv = localeconv()
142 thousands_sep = conv[monetary and 'mon_thousands_sep' or 'thousands_sep']
143 grouping = conv[monetary and 'mon_grouping' or 'grouping']
144 if not grouping:
145 return (s, 0)
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000146 if s[-1] == ' ':
Antoine Pitroufeeafff2009-03-14 00:07:21 +0000147 stripped = s.rstrip()
148 right_spaces = s[len(stripped):]
149 s = stripped
150 else:
151 right_spaces = ''
152 left_spaces = ''
153 groups = []
154 for interval in _grouping_intervals(grouping):
155 if not s or s[-1] not in "0123456789":
156 # only non-digit characters remain (sign, spaces)
157 left_spaces = s
158 s = ''
Guido van Rossum45e2fbc1998-03-26 21:13:24 +0000159 break
Antoine Pitroufeeafff2009-03-14 00:07:21 +0000160 groups.append(s[-interval:])
161 s = s[:-interval]
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000162 if s:
Antoine Pitroufeeafff2009-03-14 00:07:21 +0000163 groups.append(s)
164 groups.reverse()
165 return (
166 left_spaces + thousands_sep.join(groups) + right_spaces,
Antoine Pitrou7c33bd52009-03-18 17:10:04 +0000167 len(thousands_sep) * (len(groups) - 1)
Antoine Pitroufeeafff2009-03-14 00:07:21 +0000168 )
169
170# Strip a given amount of excess padding from the given string
171def _strip_padding(s, amount):
172 lpos = 0
173 while amount and s[lpos] == ' ':
174 lpos += 1
175 amount -= 1
176 rpos = len(s) - 1
177 while amount and s[rpos] == ' ':
178 rpos -= 1
179 amount -= 1
180 return s[lpos:rpos+1]
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000181
R. David Murraya83da352009-04-01 03:21:43 +0000182_percent_re = re.compile(r'%(?:\((?P<key>.*?)\))?'
183 r'(?P<modifiers>[-#0-9 +*.hlL]*?)[eEfFgGdiouxXcrs%]')
184
Georg Brandlb89316f2006-05-17 15:51:16 +0000185def format(percent, value, grouping=False, monetary=False, *additional):
186 """Returns the locale-aware substitution of a %? specifier
187 (percent).
Tim Petersfd4c4192006-05-18 02:06:40 +0000188
Georg Brandlb89316f2006-05-17 15:51:16 +0000189 additional is for format strings which contain one or more
190 '*' modifiers."""
191 # this is only for one-percent-specifier strings and this should be checked
R. David Murraya83da352009-04-01 03:21:43 +0000192 match = _percent_re.match(percent)
193 if not match or len(match.group())!= len(percent):
194 raise ValueError(("format() must be given exactly one %%char "
195 "format specifier, %s not valid") % repr(percent))
196 return _format(percent, value, grouping, monetary, *additional)
197
198def _format(percent, value, grouping=False, monetary=False, *additional):
Georg Brandlb89316f2006-05-17 15:51:16 +0000199 if additional:
200 formatted = percent % ((value,) + additional)
201 else:
202 formatted = percent % value
203 # floats and decimal ints need special action!
204 if percent[-1] in 'eEfFgG':
205 seps = 0
206 parts = formatted.split('.')
207 if grouping:
208 parts[0], seps = _group(parts[0], monetary=monetary)
209 decimal_point = localeconv()[monetary and 'mon_decimal_point'
210 or 'decimal_point']
211 formatted = decimal_point.join(parts)
Antoine Pitroufeeafff2009-03-14 00:07:21 +0000212 if seps:
213 formatted = _strip_padding(formatted, seps)
Georg Brandlb89316f2006-05-17 15:51:16 +0000214 elif percent[-1] in 'diu':
Antoine Pitroufeeafff2009-03-14 00:07:21 +0000215 seps = 0
Georg Brandlb89316f2006-05-17 15:51:16 +0000216 if grouping:
Antoine Pitroufeeafff2009-03-14 00:07:21 +0000217 formatted, seps = _group(formatted, monetary=monetary)
218 if seps:
219 formatted = _strip_padding(formatted, seps)
Georg Brandlb89316f2006-05-17 15:51:16 +0000220 return formatted
221
Georg Brandlb89316f2006-05-17 15:51:16 +0000222def format_string(f, val, grouping=False):
223 """Formats a string in the same way that the % formatting would use,
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000224 but takes the current locale into account.
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000225 Grouping is applied if the third parameter is true."""
Georg Brandlb89316f2006-05-17 15:51:16 +0000226 percents = list(_percent_re.finditer(f))
227 new_f = _percent_re.sub('%s', f)
228
R. David Murray3939dcd2010-04-26 21:17:14 +0000229 if operator.isMappingType(val):
230 new_val = []
231 for perc in percents:
232 if perc.group()[-1]=='%':
233 new_val.append('%')
234 else:
235 new_val.append(format(perc.group(), val, grouping))
236 else:
237 if not isinstance(val, tuple):
238 val = (val,)
239 new_val = []
Georg Brandlb89316f2006-05-17 15:51:16 +0000240 i = 0
241 for perc in percents:
R. David Murray3939dcd2010-04-26 21:17:14 +0000242 if perc.group()[-1]=='%':
243 new_val.append('%')
244 else:
245 starcount = perc.group('modifiers').count('*')
246 new_val.append(_format(perc.group(),
247 val[i],
248 grouping,
249 False,
250 *val[i+1:i+1+starcount]))
251 i += (1 + starcount)
252 val = tuple(new_val)
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000253
Georg Brandlb89316f2006-05-17 15:51:16 +0000254 return new_f % val
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000255
Georg Brandlb89316f2006-05-17 15:51:16 +0000256def currency(val, symbol=True, grouping=False, international=False):
257 """Formats val according to the currency settings
258 in the current locale."""
259 conv = localeconv()
260
261 # check for illegal values
262 digits = conv[international and 'int_frac_digits' or 'frac_digits']
263 if digits == 127:
264 raise ValueError("Currency formatting is not possible using "
265 "the 'C' locale.")
266
267 s = format('%%.%if' % digits, abs(val), grouping, monetary=True)
268 # '<' and '>' are markers if the sign must be inserted between symbol and value
269 s = '<' + s + '>'
270
271 if symbol:
272 smb = conv[international and 'int_curr_symbol' or 'currency_symbol']
273 precedes = conv[val<0 and 'n_cs_precedes' or 'p_cs_precedes']
274 separated = conv[val<0 and 'n_sep_by_space' or 'p_sep_by_space']
275
276 if precedes:
277 s = smb + (separated and ' ' or '') + s
278 else:
279 s = s + (separated and ' ' or '') + smb
280
281 sign_pos = conv[val<0 and 'n_sign_posn' or 'p_sign_posn']
282 sign = conv[val<0 and 'negative_sign' or 'positive_sign']
283
284 if sign_pos == 0:
285 s = '(' + s + ')'
286 elif sign_pos == 1:
287 s = sign + s
288 elif sign_pos == 2:
289 s = s + sign
290 elif sign_pos == 3:
291 s = s.replace('<', sign)
292 elif sign_pos == 4:
293 s = s.replace('>', sign)
294 else:
295 # the default if nothing specified;
296 # this should be the most fitting sign position
297 s = sign + s
298
299 return s.replace('<', '').replace('>', '')
Martin v. Löwisdb786872001-01-21 18:52:33 +0000300
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000301def str(val):
302 """Convert float to integer, taking the locale into account."""
Georg Brandlb89316f2006-05-17 15:51:16 +0000303 return format("%.12g", val)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000304
Georg Brandlb89316f2006-05-17 15:51:16 +0000305def atof(string, func=float):
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000306 "Parses a string as a float according to the locale settings."
307 #First, get rid of the grouping
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000308 ts = localeconv()['thousands_sep']
309 if ts:
Skip Montanaro249369c2004-04-10 16:39:32 +0000310 string = string.replace(ts, '')
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000311 #next, replace the decimal point with a dot
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000312 dd = localeconv()['decimal_point']
313 if dd:
Skip Montanaro249369c2004-04-10 16:39:32 +0000314 string = string.replace(dd, '.')
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000315 #finally, parse the string
Skip Montanaro249369c2004-04-10 16:39:32 +0000316 return func(string)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000317
318def atoi(str):
319 "Converts a string to an integer according to the locale settings."
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000320 return atof(str, int)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000321
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000322def _test():
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000323 setlocale(LC_ALL, "")
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000324 #do grouping
Georg Brandlb89316f2006-05-17 15:51:16 +0000325 s1 = format("%d", 123456789,1)
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000326 print s1, "is", atoi(s1)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000327 #standard formatting
Georg Brandlb89316f2006-05-17 15:51:16 +0000328 s1 = str(3.14)
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000329 print s1, "is", atof(s1)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000330
331### Locale name aliasing engine
332
333# Author: Marc-Andre Lemburg, mal@lemburg.com
Fredrik Lundh37a09822002-10-19 20:19:10 +0000334# Various tweaks by Fredrik Lundh <fredrik@pythonware.com>
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000335
336# store away the low-level version of setlocale (it's
337# overridden below)
338_setlocale = setlocale
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000339
Antoine Pitrou4cfae022011-07-24 02:51:01 +0200340# Avoid relying on the locale-dependent .lower() method
341# (see issue #1813).
342_ascii_lower_map = ''.join(
343 chr(x + 32 if x >= ord('A') and x <= ord('Z') else x)
344 for x in range(256)
345)
346
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000347def normalize(localename):
348
349 """ Returns a normalized locale code for the given locale
350 name.
351
352 The returned locale code is formatted for use with
353 setlocale().
354
355 If normalization fails, the original name is returned
356 unchanged.
357
358 If the given encoding is not known, the function defaults to
359 the default encoding for the locale code just like setlocale()
360 does.
361
362 """
363 # Normalize the locale name and extract the encoding
Martin v. Löwised11a5d2012-05-20 10:42:17 +0200364 if isinstance(localename, _unicode):
Barry Warsawedfba822011-08-15 19:17:12 -0400365 localename = localename.encode('ascii')
Antoine Pitrou4cfae022011-07-24 02:51:01 +0200366 fullname = localename.translate(_ascii_lower_map)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000367 if ':' in fullname:
368 # ':' is sometimes used as encoding delimiter.
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000369 fullname = fullname.replace(':', '.')
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000370 if '.' in fullname:
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000371 langname, encoding = fullname.split('.')[:2]
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000372 fullname = langname + '.' + encoding
373 else:
374 langname = fullname
375 encoding = ''
376
377 # First lookup: fullname (possibly with encoding)
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000378 norm_encoding = encoding.replace('-', '')
379 norm_encoding = norm_encoding.replace('_', '')
380 lookup_name = langname + '.' + encoding
381 code = locale_alias.get(lookup_name, None)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000382 if code is not None:
383 return code
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000384 #print 'first lookup failed'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000385
386 # Second try: langname (without encoding)
387 code = locale_alias.get(langname, None)
388 if code is not None:
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000389 #print 'langname lookup succeeded'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000390 if '.' in code:
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000391 langname, defenc = code.split('.')
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000392 else:
393 langname = code
394 defenc = ''
395 if encoding:
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000396 # Convert the encoding to a C lib compatible encoding string
397 norm_encoding = encodings.normalize_encoding(encoding)
398 #print 'norm encoding: %r' % norm_encoding
399 norm_encoding = encodings.aliases.aliases.get(norm_encoding,
400 norm_encoding)
401 #print 'aliased encoding: %r' % norm_encoding
402 encoding = locale_encoding_alias.get(norm_encoding,
403 norm_encoding)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000404 else:
405 encoding = defenc
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000406 #print 'found encoding %r' % encoding
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000407 if encoding:
408 return langname + '.' + encoding
409 else:
410 return langname
411
412 else:
413 return localename
414
415def _parse_localename(localename):
416
417 """ Parses the locale code for localename and returns the
418 result as tuple (language code, encoding).
419
420 The localename is normalized and passed through the locale
421 alias engine. A ValueError is raised in case the locale name
422 cannot be parsed.
423
424 The language code corresponds to RFC 1766. code and encoding
425 can be None in case the values cannot be determined or are
Jeremy Hyltona05e2932000-06-28 14:48:01 +0000426 unknown to this implementation.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000427
428 """
429 code = normalize(localename)
Georg Brandlb709c2c2006-01-20 09:07:35 +0000430 if '@' in code:
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000431 # Deal with locale modifiers
432 code, modifier = code.split('@')
433 if modifier == 'euro' and '.' not in code:
434 # Assume Latin-9 for @euro locales. This is bogus,
435 # since some systems may use other encodings for these
436 # locales. Also, we ignore other modifiers.
437 return code, 'iso-8859-15'
Tim Peters230a60c2002-11-09 05:08:07 +0000438
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000439 if '.' in code:
Raymond Hettinger346e67f2005-01-01 06:10:26 +0000440 return tuple(code.split('.')[:2])
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000441 elif code == 'C':
442 return None, None
Andrew M. Kuchling1f877ef2001-08-13 14:50:44 +0000443 raise ValueError, 'unknown locale: %s' % localename
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000444
445def _build_localename(localetuple):
446
447 """ Builds a locale code from the given tuple (language code,
448 encoding).
449
450 No aliasing or normalizing takes place.
451
452 """
453 language, encoding = localetuple
454 if language is None:
455 language = 'C'
456 if encoding is None:
457 return language
458 else:
459 return language + '.' + encoding
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000460
Matthias Klosef3f231f2005-09-20 07:02:49 +0000461def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000462
463 """ Tries to determine the default locale settings and returns
464 them as tuple (language code, encoding).
465
466 According to POSIX, a program which has not called
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000467 setlocale(LC_ALL, "") runs using the portable 'C' locale.
468 Calling setlocale(LC_ALL, "") lets it use the default locale as
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000469 defined by the LANG variable. Since we don't want to interfere
Thomas Wouters7e474022000-07-16 12:04:32 +0000470 with the current locale setting we thus emulate the behavior
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000471 in the way described above.
472
473 To maintain compatibility with other platforms, not only the
474 LANG variable is tested, but a list of variables given as
475 envvars parameter. The first found to be defined will be
476 used. envvars defaults to the search path used in GNU gettext;
477 it must always contain the variable name 'LANG'.
478
479 Except for the code 'C', the language code corresponds to RFC
480 1766. code and encoding can be None in case the values cannot
481 be determined.
482
483 """
Fredrik Lundh04661322000-07-09 23:16:10 +0000484
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000485 try:
486 # check if it's supported by the _locale module
487 import _locale
488 code, encoding = _locale._getdefaultlocale()
Fredrik Lundh04661322000-07-09 23:16:10 +0000489 except (ImportError, AttributeError):
490 pass
491 else:
Fredrik Lundh663809e2000-07-10 19:32:19 +0000492 # make sure the code/encoding values are valid
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000493 if sys.platform == "win32" and code and code[:2] == "0x":
494 # map windows language identifier to language name
495 code = windows_locale.get(int(code, 0))
Fredrik Lundh663809e2000-07-10 19:32:19 +0000496 # ...add other platform-specific processing here, if
497 # necessary...
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000498 return code, encoding
Fredrik Lundh04661322000-07-09 23:16:10 +0000499
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000500 # fall back on POSIX behaviour
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000501 import os
502 lookup = os.environ.get
503 for variable in envvars:
504 localename = lookup(variable,None)
Martin v. Löwisc8ae31d2004-07-26 12:45:18 +0000505 if localename:
Matthias Klosef3f231f2005-09-20 07:02:49 +0000506 if variable == 'LANGUAGE':
507 localename = localename.split(':')[0]
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000508 break
509 else:
510 localename = 'C'
511 return _parse_localename(localename)
512
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000513
514def getlocale(category=LC_CTYPE):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000515
516 """ Returns the current setting for the given locale category as
517 tuple (language code, encoding).
518
519 category may be one of the LC_* value except LC_ALL. It
520 defaults to LC_CTYPE.
521
522 Except for the code 'C', the language code corresponds to RFC
523 1766. code and encoding can be None in case the values cannot
524 be determined.
525
526 """
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000527 localename = _setlocale(category)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000528 if category == LC_ALL and ';' in localename:
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000529 raise TypeError, 'category LC_ALL is not supported'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000530 return _parse_localename(localename)
531
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000532def setlocale(category, locale=None):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000533
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000534 """ Set the locale for the given category. The locale can be
Petri Lehtinen416ecff2011-11-05 10:18:50 +0200535 a string, an iterable of two strings (language code and encoding),
536 or None.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000537
Petri Lehtinen416ecff2011-11-05 10:18:50 +0200538 Iterables are converted to strings using the locale aliasing
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000539 engine. Locale strings are passed directly to the C lib.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000540
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000541 category may be given as one of the LC_* values.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000542
543 """
Victor Stinnerecb863b2011-06-20 22:07:06 +0200544 if locale and type(locale) is not type(""):
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000545 # convert to string
546 locale = normalize(_build_localename(locale))
547 return _setlocale(category, locale)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000548
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000549def resetlocale(category=LC_ALL):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000550
551 """ Sets the locale for category to the default setting.
552
553 The default setting is determined by calling
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000554 getdefaultlocale(). category defaults to LC_ALL.
555
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000556 """
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000557 _setlocale(category, _build_localename(getdefaultlocale()))
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000558
Benjamin Petersone021c9c2009-06-07 16:24:48 +0000559if sys.platform.startswith("win"):
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000560 # On Win32, this will return the ANSI code page
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000561 def getpreferredencoding(do_setlocale = True):
562 """Return the charset that the user is likely using."""
563 import _locale
Tim Petersa326f472002-11-05 03:49:09 +0000564 return _locale._getdefaultlocale()[1]
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000565else:
566 # On Unix, if CODESET is available, use that.
567 try:
568 CODESET
569 except NameError:
570 # Fall back to parsing environment variables :-(
571 def getpreferredencoding(do_setlocale = True):
572 """Return the charset that the user is likely using,
573 by looking at environment variables."""
574 return getdefaultlocale()[1]
575 else:
576 def getpreferredencoding(do_setlocale = True):
577 """Return the charset that the user is likely using,
578 according to the system configuration."""
579 if do_setlocale:
580 oldloc = setlocale(LC_CTYPE)
Jeroen Ruigrok van der Werven041f4652009-05-06 05:25:42 +0000581 try:
582 setlocale(LC_CTYPE, "")
Jeroen Ruigrok van der Wervenc924b3d2009-05-06 13:16:36 +0000583 except Error:
Jeroen Ruigrok van der Werven041f4652009-05-06 05:25:42 +0000584 pass
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000585 result = nl_langinfo(CODESET)
586 setlocale(LC_CTYPE, oldloc)
587 return result
588 else:
589 return nl_langinfo(CODESET)
Tim Peters230a60c2002-11-09 05:08:07 +0000590
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000591
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000592### Database
593#
594# The following data was extracted from the locale.alias file which
595# comes with X11 and then hand edited removing the explicit encoding
596# definitions and adding some more aliases. The file is usually
597# available as /usr/lib/X11/locale/locale.alias.
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000598#
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000599
600#
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000601# The local_encoding_alias table maps lowercase encoding alias names
602# to C locale encoding names (case-sensitive). Note that normalize()
603# first looks up the encoding in the encodings.aliases dictionary and
604# then applies this mapping to find the correct C lib name for the
605# encoding.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000606#
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000607locale_encoding_alias = {
608
609 # Mappings for non-standard encoding names used in locale names
610 '437': 'C',
611 'c': 'C',
612 'en': 'ISO8859-1',
613 'jis': 'JIS7',
614 'jis7': 'JIS7',
615 'ajec': 'eucJP',
616
617 # Mappings from Python codec names to C lib encoding names
618 'ascii': 'ISO8859-1',
619 'latin_1': 'ISO8859-1',
620 'iso8859_1': 'ISO8859-1',
621 'iso8859_10': 'ISO8859-10',
622 'iso8859_11': 'ISO8859-11',
623 'iso8859_13': 'ISO8859-13',
624 'iso8859_14': 'ISO8859-14',
625 'iso8859_15': 'ISO8859-15',
Jeroen Ruigrok van der Werven51133d42009-05-08 13:07:39 +0000626 'iso8859_16': 'ISO8859-16',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000627 'iso8859_2': 'ISO8859-2',
628 'iso8859_3': 'ISO8859-3',
629 'iso8859_4': 'ISO8859-4',
630 'iso8859_5': 'ISO8859-5',
631 'iso8859_6': 'ISO8859-6',
632 'iso8859_7': 'ISO8859-7',
633 'iso8859_8': 'ISO8859-8',
634 'iso8859_9': 'ISO8859-9',
635 'iso2022_jp': 'JIS7',
636 'shift_jis': 'SJIS',
637 'tactis': 'TACTIS',
638 'euc_jp': 'eucJP',
639 'euc_kr': 'eucKR',
Ronald Oussoren372954e2011-05-17 13:22:30 +0200640 'utf_8': 'UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000641 'koi8_r': 'KOI8-R',
642 'koi8_u': 'KOI8-U',
643 # XXX This list is still incomplete. If you know more
644 # mappings, please file a bug report. Thanks.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000645}
646
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000647#
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000648# The locale_alias table maps lowercase alias names to C locale names
649# (case-sensitive). Encodings are always separated from the locale
650# name using a dot ('.'); they should only be given in case the
651# language name is needed to interpret the given encoding alias
652# correctly (CJK codes often have this need).
653#
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000654# Note that the normalize() function which uses this tables
655# removes '_' and '-' characters from the encoding part of the
656# locale name before doing the lookup. This saves a lot of
657# space in the table.
658#
659# MAL 2004-12-10:
660# Updated alias mapping to most recent locale.alias file
661# from X.org distribution using makelocalealias.py.
662#
663# These are the differences compared to the old mapping (Python 2.4
664# and older):
665#
666# updated 'bg' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
667# updated 'bg_bg' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
668# updated 'bulgarian' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
669# updated 'cz' -> 'cz_CZ.ISO8859-2' to 'cs_CZ.ISO8859-2'
670# updated 'cz_cz' -> 'cz_CZ.ISO8859-2' to 'cs_CZ.ISO8859-2'
671# updated 'czech' -> 'cs_CS.ISO8859-2' to 'cs_CZ.ISO8859-2'
672# updated 'dutch' -> 'nl_BE.ISO8859-1' to 'nl_NL.ISO8859-1'
673# updated 'et' -> 'et_EE.ISO8859-4' to 'et_EE.ISO8859-15'
674# updated 'et_ee' -> 'et_EE.ISO8859-4' to 'et_EE.ISO8859-15'
675# updated 'fi' -> 'fi_FI.ISO8859-1' to 'fi_FI.ISO8859-15'
676# updated 'fi_fi' -> 'fi_FI.ISO8859-1' to 'fi_FI.ISO8859-15'
677# updated 'iw' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
678# updated 'iw_il' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
679# updated 'japanese' -> 'ja_JP.SJIS' to 'ja_JP.eucJP'
680# updated 'lt' -> 'lt_LT.ISO8859-4' to 'lt_LT.ISO8859-13'
681# updated 'lv' -> 'lv_LV.ISO8859-4' to 'lv_LV.ISO8859-13'
682# updated 'sl' -> 'sl_CS.ISO8859-2' to 'sl_SI.ISO8859-2'
683# updated 'slovene' -> 'sl_CS.ISO8859-2' to 'sl_SI.ISO8859-2'
684# updated 'th_th' -> 'th_TH.TACTIS' to 'th_TH.ISO8859-11'
685# updated 'zh_cn' -> 'zh_CN.eucCN' to 'zh_CN.gb2312'
686# updated 'zh_cn.big5' -> 'zh_TW.eucTW' to 'zh_TW.big5'
687# updated 'zh_tw' -> 'zh_TW.eucTW' to 'zh_TW.big5'
688#
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000689# MAL 2008-05-30:
690# Updated alias mapping to most recent locale.alias file
691# from X.org distribution using makelocalealias.py.
692#
693# These are the differences compared to the old mapping (Python 2.5
694# and older):
695#
696# updated 'cs_cs.iso88592' -> 'cs_CZ.ISO8859-2' to 'cs_CS.ISO8859-2'
697# updated 'serbocroatian' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
698# updated 'sh' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
699# updated 'sh_hr.iso88592' -> 'sh_HR.ISO8859-2' to 'hr_HR.ISO8859-2'
700# updated 'sh_sp' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
701# updated 'sh_yu' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
702# updated 'sp' -> 'sp_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
703# updated 'sp_yu' -> 'sp_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
704# updated 'sr' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
705# updated 'sr@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
706# updated 'sr_sp' -> 'sr_SP.ISO8859-2' to 'sr_CS.ISO8859-2'
707# updated 'sr_yu' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
708# updated 'sr_yu.cp1251@cyrillic' -> 'sr_YU.CP1251' to 'sr_CS.CP1251'
709# updated 'sr_yu.iso88592' -> 'sr_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
710# updated 'sr_yu.iso88595' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
711# updated 'sr_yu.iso88595@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
712# updated 'sr_yu.microsoftcp1251@cyrillic' -> 'sr_YU.CP1251' to 'sr_CS.CP1251'
713# updated 'sr_yu.utf8@cyrillic' -> 'sr_YU.UTF-8' to 'sr_CS.UTF-8'
714# updated 'sr_yu@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
Antoine Pitroufc531532010-04-11 22:32:39 +0000715#
716# AP 2010-04-12:
717# Updated alias mapping to most recent locale.alias file
718# from X.org distribution using makelocalealias.py.
719#
720# These are the differences compared to the old mapping (Python 2.6.5
721# and older):
722#
723# updated 'ru' -> 'ru_RU.ISO8859-5' to 'ru_RU.UTF-8'
724# updated 'ru_ru' -> 'ru_RU.ISO8859-5' to 'ru_RU.UTF-8'
725# updated 'serbocroatian' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
726# updated 'sh' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
727# updated 'sh_yu' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
728# updated 'sr' -> 'sr_CS.ISO8859-5' to 'sr_RS.UTF-8'
729# updated 'sr@cyrillic' -> 'sr_CS.ISO8859-5' to 'sr_RS.UTF-8'
730# updated 'sr@latn' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
731# updated 'sr_cs.utf8@latn' -> 'sr_CS.UTF-8' to 'sr_RS.UTF-8@latin'
732# updated 'sr_cs@latn' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
733# updated 'sr_yu' -> 'sr_CS.ISO8859-5' to 'sr_RS.UTF-8@latin'
734# updated 'sr_yu.utf8@cyrillic' -> 'sr_CS.UTF-8' to 'sr_RS.UTF-8'
735# updated 'sr_yu@cyrillic' -> 'sr_CS.ISO8859-5' to 'sr_RS.UTF-8'
736#
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000737
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000738locale_alias = {
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000739 'a3': 'a3_AZ.KOI8-C',
740 'a3_az': 'a3_AZ.KOI8-C',
741 'a3_az.koi8c': 'a3_AZ.KOI8-C',
742 'af': 'af_ZA.ISO8859-1',
743 'af_za': 'af_ZA.ISO8859-1',
744 'af_za.iso88591': 'af_ZA.ISO8859-1',
745 'am': 'am_ET.UTF-8',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000746 'am_et': 'am_ET.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000747 'american': 'en_US.ISO8859-1',
748 'american.iso88591': 'en_US.ISO8859-1',
749 'ar': 'ar_AA.ISO8859-6',
750 'ar_aa': 'ar_AA.ISO8859-6',
751 'ar_aa.iso88596': 'ar_AA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000752 'ar_ae': 'ar_AE.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000753 'ar_ae.iso88596': 'ar_AE.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000754 'ar_bh': 'ar_BH.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000755 'ar_bh.iso88596': 'ar_BH.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000756 'ar_dz': 'ar_DZ.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000757 'ar_dz.iso88596': 'ar_DZ.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000758 'ar_eg': 'ar_EG.ISO8859-6',
759 'ar_eg.iso88596': 'ar_EG.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000760 'ar_iq': 'ar_IQ.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000761 'ar_iq.iso88596': 'ar_IQ.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000762 'ar_jo': 'ar_JO.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000763 'ar_jo.iso88596': 'ar_JO.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000764 'ar_kw': 'ar_KW.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000765 'ar_kw.iso88596': 'ar_KW.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000766 'ar_lb': 'ar_LB.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000767 'ar_lb.iso88596': 'ar_LB.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000768 'ar_ly': 'ar_LY.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000769 'ar_ly.iso88596': 'ar_LY.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000770 'ar_ma': 'ar_MA.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000771 'ar_ma.iso88596': 'ar_MA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000772 'ar_om': 'ar_OM.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000773 'ar_om.iso88596': 'ar_OM.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000774 'ar_qa': 'ar_QA.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000775 'ar_qa.iso88596': 'ar_QA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000776 'ar_sa': 'ar_SA.ISO8859-6',
777 'ar_sa.iso88596': 'ar_SA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000778 'ar_sd': 'ar_SD.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000779 'ar_sd.iso88596': 'ar_SD.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000780 'ar_sy': 'ar_SY.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000781 'ar_sy.iso88596': 'ar_SY.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000782 'ar_tn': 'ar_TN.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000783 'ar_tn.iso88596': 'ar_TN.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000784 'ar_ye': 'ar_YE.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000785 'ar_ye.iso88596': 'ar_YE.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000786 'arabic': 'ar_AA.ISO8859-6',
787 'arabic.iso88596': 'ar_AA.ISO8859-6',
Antoine Pitroufc531532010-04-11 22:32:39 +0000788 'as': 'as_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000789 'az': 'az_AZ.ISO8859-9E',
790 'az_az': 'az_AZ.ISO8859-9E',
791 'az_az.iso88599e': 'az_AZ.ISO8859-9E',
792 'be': 'be_BY.CP1251',
Antoine Pitroufc531532010-04-11 22:32:39 +0000793 'be@latin': 'be_BY.UTF-8@latin',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000794 'be_by': 'be_BY.CP1251',
795 'be_by.cp1251': 'be_BY.CP1251',
796 'be_by.microsoftcp1251': 'be_BY.CP1251',
Antoine Pitroufc531532010-04-11 22:32:39 +0000797 'be_by.utf8@latin': 'be_BY.UTF-8@latin',
798 'be_by@latin': 'be_BY.UTF-8@latin',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000799 'bg': 'bg_BG.CP1251',
800 'bg_bg': 'bg_BG.CP1251',
801 'bg_bg.cp1251': 'bg_BG.CP1251',
802 'bg_bg.iso88595': 'bg_BG.ISO8859-5',
803 'bg_bg.koi8r': 'bg_BG.KOI8-R',
804 'bg_bg.microsoftcp1251': 'bg_BG.CP1251',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000805 'bn_in': 'bn_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000806 'bokmal': 'nb_NO.ISO8859-1',
807 'bokm\xe5l': 'nb_NO.ISO8859-1',
808 'br': 'br_FR.ISO8859-1',
809 'br_fr': 'br_FR.ISO8859-1',
810 'br_fr.iso88591': 'br_FR.ISO8859-1',
811 'br_fr.iso885914': 'br_FR.ISO8859-14',
812 'br_fr.iso885915': 'br_FR.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000813 'br_fr.iso885915@euro': 'br_FR.ISO8859-15',
814 'br_fr.utf8@euro': 'br_FR.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000815 'br_fr@euro': 'br_FR.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000816 'bs': 'bs_BA.ISO8859-2',
817 'bs_ba': 'bs_BA.ISO8859-2',
818 'bs_ba.iso88592': 'bs_BA.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000819 'bulgarian': 'bg_BG.CP1251',
820 'c': 'C',
821 'c-french': 'fr_CA.ISO8859-1',
822 'c-french.iso88591': 'fr_CA.ISO8859-1',
823 'c.en': 'C',
824 'c.iso88591': 'en_US.ISO8859-1',
825 'c_c': 'C',
826 'c_c.c': 'C',
827 'ca': 'ca_ES.ISO8859-1',
Antoine Pitroufc531532010-04-11 22:32:39 +0000828 'ca_ad': 'ca_AD.ISO8859-1',
829 'ca_ad.iso88591': 'ca_AD.ISO8859-1',
830 'ca_ad.iso885915': 'ca_AD.ISO8859-15',
831 'ca_ad.iso885915@euro': 'ca_AD.ISO8859-15',
832 'ca_ad.utf8@euro': 'ca_AD.UTF-8',
833 'ca_ad@euro': 'ca_AD.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000834 'ca_es': 'ca_ES.ISO8859-1',
835 'ca_es.iso88591': 'ca_ES.ISO8859-1',
836 'ca_es.iso885915': 'ca_ES.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000837 'ca_es.iso885915@euro': 'ca_ES.ISO8859-15',
838 'ca_es.utf8@euro': 'ca_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000839 'ca_es@euro': 'ca_ES.ISO8859-15',
Antoine Pitroufc531532010-04-11 22:32:39 +0000840 'ca_fr': 'ca_FR.ISO8859-1',
841 'ca_fr.iso88591': 'ca_FR.ISO8859-1',
842 'ca_fr.iso885915': 'ca_FR.ISO8859-15',
843 'ca_fr.iso885915@euro': 'ca_FR.ISO8859-15',
844 'ca_fr.utf8@euro': 'ca_FR.UTF-8',
845 'ca_fr@euro': 'ca_FR.ISO8859-15',
846 'ca_it': 'ca_IT.ISO8859-1',
847 'ca_it.iso88591': 'ca_IT.ISO8859-1',
848 'ca_it.iso885915': 'ca_IT.ISO8859-15',
849 'ca_it.iso885915@euro': 'ca_IT.ISO8859-15',
850 'ca_it.utf8@euro': 'ca_IT.UTF-8',
851 'ca_it@euro': 'ca_IT.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000852 'catalan': 'ca_ES.ISO8859-1',
853 'cextend': 'en_US.ISO8859-1',
854 'cextend.en': 'en_US.ISO8859-1',
855 'chinese-s': 'zh_CN.eucCN',
856 'chinese-t': 'zh_TW.eucTW',
857 'croatian': 'hr_HR.ISO8859-2',
858 'cs': 'cs_CZ.ISO8859-2',
859 'cs_cs': 'cs_CZ.ISO8859-2',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000860 'cs_cs.iso88592': 'cs_CS.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000861 'cs_cz': 'cs_CZ.ISO8859-2',
862 'cs_cz.iso88592': 'cs_CZ.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000863 'cy': 'cy_GB.ISO8859-1',
864 'cy_gb': 'cy_GB.ISO8859-1',
865 'cy_gb.iso88591': 'cy_GB.ISO8859-1',
866 'cy_gb.iso885914': 'cy_GB.ISO8859-14',
867 'cy_gb.iso885915': 'cy_GB.ISO8859-15',
868 'cy_gb@euro': 'cy_GB.ISO8859-15',
869 'cz': 'cs_CZ.ISO8859-2',
870 'cz_cz': 'cs_CZ.ISO8859-2',
871 'czech': 'cs_CZ.ISO8859-2',
872 'da': 'da_DK.ISO8859-1',
Antoine Pitroufc531532010-04-11 22:32:39 +0000873 'da.iso885915': 'da_DK.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000874 'da_dk': 'da_DK.ISO8859-1',
875 'da_dk.88591': 'da_DK.ISO8859-1',
876 'da_dk.885915': 'da_DK.ISO8859-15',
877 'da_dk.iso88591': 'da_DK.ISO8859-1',
878 'da_dk.iso885915': 'da_DK.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000879 'da_dk@euro': 'da_DK.ISO8859-15',
880 'danish': 'da_DK.ISO8859-1',
881 'danish.iso88591': 'da_DK.ISO8859-1',
882 'dansk': 'da_DK.ISO8859-1',
883 'de': 'de_DE.ISO8859-1',
Antoine Pitroufc531532010-04-11 22:32:39 +0000884 'de.iso885915': 'de_DE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000885 'de_at': 'de_AT.ISO8859-1',
886 'de_at.iso88591': 'de_AT.ISO8859-1',
887 'de_at.iso885915': 'de_AT.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000888 'de_at.iso885915@euro': 'de_AT.ISO8859-15',
889 'de_at.utf8@euro': 'de_AT.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000890 'de_at@euro': 'de_AT.ISO8859-15',
891 'de_be': 'de_BE.ISO8859-1',
892 'de_be.iso88591': 'de_BE.ISO8859-1',
893 'de_be.iso885915': 'de_BE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000894 'de_be.iso885915@euro': 'de_BE.ISO8859-15',
895 'de_be.utf8@euro': 'de_BE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000896 'de_be@euro': 'de_BE.ISO8859-15',
897 'de_ch': 'de_CH.ISO8859-1',
898 'de_ch.iso88591': 'de_CH.ISO8859-1',
899 'de_ch.iso885915': 'de_CH.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000900 'de_ch@euro': 'de_CH.ISO8859-15',
901 'de_de': 'de_DE.ISO8859-1',
902 'de_de.88591': 'de_DE.ISO8859-1',
903 'de_de.885915': 'de_DE.ISO8859-15',
904 'de_de.885915@euro': 'de_DE.ISO8859-15',
905 'de_de.iso88591': 'de_DE.ISO8859-1',
906 'de_de.iso885915': 'de_DE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000907 'de_de.iso885915@euro': 'de_DE.ISO8859-15',
908 'de_de.utf8@euro': 'de_DE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000909 'de_de@euro': 'de_DE.ISO8859-15',
910 'de_lu': 'de_LU.ISO8859-1',
911 'de_lu.iso88591': 'de_LU.ISO8859-1',
912 'de_lu.iso885915': 'de_LU.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000913 'de_lu.iso885915@euro': 'de_LU.ISO8859-15',
914 'de_lu.utf8@euro': 'de_LU.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000915 'de_lu@euro': 'de_LU.ISO8859-15',
916 'deutsch': 'de_DE.ISO8859-1',
917 'dutch': 'nl_NL.ISO8859-1',
918 'dutch.iso88591': 'nl_BE.ISO8859-1',
919 'ee': 'ee_EE.ISO8859-4',
920 'ee_ee': 'ee_EE.ISO8859-4',
921 'ee_ee.iso88594': 'ee_EE.ISO8859-4',
922 'eesti': 'et_EE.ISO8859-1',
923 'el': 'el_GR.ISO8859-7',
924 'el_gr': 'el_GR.ISO8859-7',
925 'el_gr.iso88597': 'el_GR.ISO8859-7',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000926 'el_gr@euro': 'el_GR.ISO8859-15',
927 'en': 'en_US.ISO8859-1',
928 'en.iso88591': 'en_US.ISO8859-1',
929 'en_au': 'en_AU.ISO8859-1',
930 'en_au.iso88591': 'en_AU.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000931 'en_be': 'en_BE.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000932 'en_be@euro': 'en_BE.ISO8859-15',
933 'en_bw': 'en_BW.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000934 'en_bw.iso88591': 'en_BW.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000935 'en_ca': 'en_CA.ISO8859-1',
936 'en_ca.iso88591': 'en_CA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000937 'en_gb': 'en_GB.ISO8859-1',
938 'en_gb.88591': 'en_GB.ISO8859-1',
939 'en_gb.iso88591': 'en_GB.ISO8859-1',
940 'en_gb.iso885915': 'en_GB.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000941 'en_gb@euro': 'en_GB.ISO8859-15',
942 'en_hk': 'en_HK.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000943 'en_hk.iso88591': 'en_HK.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000944 'en_ie': 'en_IE.ISO8859-1',
945 'en_ie.iso88591': 'en_IE.ISO8859-1',
946 'en_ie.iso885915': 'en_IE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000947 'en_ie.iso885915@euro': 'en_IE.ISO8859-15',
948 'en_ie.utf8@euro': 'en_IE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000949 'en_ie@euro': 'en_IE.ISO8859-15',
950 'en_in': 'en_IN.ISO8859-1',
951 'en_nz': 'en_NZ.ISO8859-1',
952 'en_nz.iso88591': 'en_NZ.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000953 'en_ph': 'en_PH.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000954 'en_ph.iso88591': 'en_PH.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000955 'en_sg': 'en_SG.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000956 'en_sg.iso88591': 'en_SG.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000957 'en_uk': 'en_GB.ISO8859-1',
958 'en_us': 'en_US.ISO8859-1',
959 'en_us.88591': 'en_US.ISO8859-1',
960 'en_us.885915': 'en_US.ISO8859-15',
961 'en_us.iso88591': 'en_US.ISO8859-1',
962 'en_us.iso885915': 'en_US.ISO8859-15',
963 'en_us.iso885915@euro': 'en_US.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000964 'en_us@euro': 'en_US.ISO8859-15',
965 'en_us@euro@euro': 'en_US.ISO8859-15',
966 'en_za': 'en_ZA.ISO8859-1',
967 'en_za.88591': 'en_ZA.ISO8859-1',
968 'en_za.iso88591': 'en_ZA.ISO8859-1',
969 'en_za.iso885915': 'en_ZA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000970 'en_za@euro': 'en_ZA.ISO8859-15',
971 'en_zw': 'en_ZW.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000972 'en_zw.iso88591': 'en_ZW.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000973 'eng_gb': 'en_GB.ISO8859-1',
974 'eng_gb.8859': 'en_GB.ISO8859-1',
975 'english': 'en_EN.ISO8859-1',
976 'english.iso88591': 'en_EN.ISO8859-1',
977 'english_uk': 'en_GB.ISO8859-1',
978 'english_uk.8859': 'en_GB.ISO8859-1',
979 'english_united-states': 'en_US.ISO8859-1',
980 'english_united-states.437': 'C',
981 'english_us': 'en_US.ISO8859-1',
982 'english_us.8859': 'en_US.ISO8859-1',
983 'english_us.ascii': 'en_US.ISO8859-1',
984 'eo': 'eo_XX.ISO8859-3',
985 'eo_eo': 'eo_EO.ISO8859-3',
986 'eo_eo.iso88593': 'eo_EO.ISO8859-3',
987 'eo_xx': 'eo_XX.ISO8859-3',
988 'eo_xx.iso88593': 'eo_XX.ISO8859-3',
989 'es': 'es_ES.ISO8859-1',
990 'es_ar': 'es_AR.ISO8859-1',
991 'es_ar.iso88591': 'es_AR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000992 'es_bo': 'es_BO.ISO8859-1',
993 'es_bo.iso88591': 'es_BO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000994 'es_cl': 'es_CL.ISO8859-1',
995 'es_cl.iso88591': 'es_CL.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000996 'es_co': 'es_CO.ISO8859-1',
997 'es_co.iso88591': 'es_CO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000998 'es_cr': 'es_CR.ISO8859-1',
999 'es_cr.iso88591': 'es_CR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001000 'es_do': 'es_DO.ISO8859-1',
1001 'es_do.iso88591': 'es_DO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001002 'es_ec': 'es_EC.ISO8859-1',
1003 'es_ec.iso88591': 'es_EC.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001004 'es_es': 'es_ES.ISO8859-1',
1005 'es_es.88591': 'es_ES.ISO8859-1',
1006 'es_es.iso88591': 'es_ES.ISO8859-1',
1007 'es_es.iso885915': 'es_ES.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001008 'es_es.iso885915@euro': 'es_ES.ISO8859-15',
1009 'es_es.utf8@euro': 'es_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001010 'es_es@euro': 'es_ES.ISO8859-15',
1011 'es_gt': 'es_GT.ISO8859-1',
1012 'es_gt.iso88591': 'es_GT.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001013 'es_hn': 'es_HN.ISO8859-1',
1014 'es_hn.iso88591': 'es_HN.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001015 'es_mx': 'es_MX.ISO8859-1',
1016 'es_mx.iso88591': 'es_MX.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001017 'es_ni': 'es_NI.ISO8859-1',
1018 'es_ni.iso88591': 'es_NI.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001019 'es_pa': 'es_PA.ISO8859-1',
1020 'es_pa.iso88591': 'es_PA.ISO8859-1',
1021 'es_pa.iso885915': 'es_PA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001022 'es_pa@euro': 'es_PA.ISO8859-15',
1023 'es_pe': 'es_PE.ISO8859-1',
1024 'es_pe.iso88591': 'es_PE.ISO8859-1',
1025 'es_pe.iso885915': 'es_PE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001026 'es_pe@euro': 'es_PE.ISO8859-15',
1027 'es_pr': 'es_PR.ISO8859-1',
1028 'es_pr.iso88591': 'es_PR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001029 'es_py': 'es_PY.ISO8859-1',
1030 'es_py.iso88591': 'es_PY.ISO8859-1',
1031 'es_py.iso885915': 'es_PY.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001032 'es_py@euro': 'es_PY.ISO8859-15',
1033 'es_sv': 'es_SV.ISO8859-1',
1034 'es_sv.iso88591': 'es_SV.ISO8859-1',
1035 'es_sv.iso885915': 'es_SV.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001036 'es_sv@euro': 'es_SV.ISO8859-15',
1037 'es_us': 'es_US.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001038 'es_us.iso88591': 'es_US.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001039 'es_uy': 'es_UY.ISO8859-1',
1040 'es_uy.iso88591': 'es_UY.ISO8859-1',
1041 'es_uy.iso885915': 'es_UY.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001042 'es_uy@euro': 'es_UY.ISO8859-15',
1043 'es_ve': 'es_VE.ISO8859-1',
1044 'es_ve.iso88591': 'es_VE.ISO8859-1',
1045 'es_ve.iso885915': 'es_VE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001046 'es_ve@euro': 'es_VE.ISO8859-15',
1047 'estonian': 'et_EE.ISO8859-1',
1048 'et': 'et_EE.ISO8859-15',
1049 'et_ee': 'et_EE.ISO8859-15',
1050 'et_ee.iso88591': 'et_EE.ISO8859-1',
1051 'et_ee.iso885913': 'et_EE.ISO8859-13',
1052 'et_ee.iso885915': 'et_EE.ISO8859-15',
1053 'et_ee.iso88594': 'et_EE.ISO8859-4',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001054 'et_ee@euro': 'et_EE.ISO8859-15',
1055 'eu': 'eu_ES.ISO8859-1',
1056 'eu_es': 'eu_ES.ISO8859-1',
1057 'eu_es.iso88591': 'eu_ES.ISO8859-1',
1058 'eu_es.iso885915': 'eu_ES.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001059 'eu_es.iso885915@euro': 'eu_ES.ISO8859-15',
1060 'eu_es.utf8@euro': 'eu_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001061 'eu_es@euro': 'eu_ES.ISO8859-15',
1062 'fa': 'fa_IR.UTF-8',
1063 'fa_ir': 'fa_IR.UTF-8',
1064 'fa_ir.isiri3342': 'fa_IR.ISIRI-3342',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001065 'fi': 'fi_FI.ISO8859-15',
Antoine Pitroufc531532010-04-11 22:32:39 +00001066 'fi.iso885915': 'fi_FI.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001067 'fi_fi': 'fi_FI.ISO8859-15',
1068 'fi_fi.88591': 'fi_FI.ISO8859-1',
1069 'fi_fi.iso88591': 'fi_FI.ISO8859-1',
1070 'fi_fi.iso885915': 'fi_FI.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001071 'fi_fi.iso885915@euro': 'fi_FI.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001072 'fi_fi.utf8@euro': 'fi_FI.UTF-8',
1073 'fi_fi@euro': 'fi_FI.ISO8859-15',
1074 'finnish': 'fi_FI.ISO8859-1',
1075 'finnish.iso88591': 'fi_FI.ISO8859-1',
1076 'fo': 'fo_FO.ISO8859-1',
1077 'fo_fo': 'fo_FO.ISO8859-1',
1078 'fo_fo.iso88591': 'fo_FO.ISO8859-1',
1079 'fo_fo.iso885915': 'fo_FO.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001080 'fo_fo@euro': 'fo_FO.ISO8859-15',
1081 'fr': 'fr_FR.ISO8859-1',
Antoine Pitroufc531532010-04-11 22:32:39 +00001082 'fr.iso885915': 'fr_FR.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001083 'fr_be': 'fr_BE.ISO8859-1',
1084 'fr_be.88591': 'fr_BE.ISO8859-1',
1085 'fr_be.iso88591': 'fr_BE.ISO8859-1',
1086 'fr_be.iso885915': 'fr_BE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001087 'fr_be.iso885915@euro': 'fr_BE.ISO8859-15',
1088 'fr_be.utf8@euro': 'fr_BE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001089 'fr_be@euro': 'fr_BE.ISO8859-15',
1090 'fr_ca': 'fr_CA.ISO8859-1',
1091 'fr_ca.88591': 'fr_CA.ISO8859-1',
1092 'fr_ca.iso88591': 'fr_CA.ISO8859-1',
1093 'fr_ca.iso885915': 'fr_CA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001094 'fr_ca@euro': 'fr_CA.ISO8859-15',
1095 'fr_ch': 'fr_CH.ISO8859-1',
1096 'fr_ch.88591': 'fr_CH.ISO8859-1',
1097 'fr_ch.iso88591': 'fr_CH.ISO8859-1',
1098 'fr_ch.iso885915': 'fr_CH.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001099 'fr_ch@euro': 'fr_CH.ISO8859-15',
1100 'fr_fr': 'fr_FR.ISO8859-1',
1101 'fr_fr.88591': 'fr_FR.ISO8859-1',
1102 'fr_fr.iso88591': 'fr_FR.ISO8859-1',
1103 'fr_fr.iso885915': 'fr_FR.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001104 'fr_fr.iso885915@euro': 'fr_FR.ISO8859-15',
1105 'fr_fr.utf8@euro': 'fr_FR.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001106 'fr_fr@euro': 'fr_FR.ISO8859-15',
1107 'fr_lu': 'fr_LU.ISO8859-1',
1108 'fr_lu.88591': 'fr_LU.ISO8859-1',
1109 'fr_lu.iso88591': 'fr_LU.ISO8859-1',
1110 'fr_lu.iso885915': 'fr_LU.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001111 'fr_lu.iso885915@euro': 'fr_LU.ISO8859-15',
1112 'fr_lu.utf8@euro': 'fr_LU.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001113 'fr_lu@euro': 'fr_LU.ISO8859-15',
1114 'fran\xe7ais': 'fr_FR.ISO8859-1',
1115 'fre_fr': 'fr_FR.ISO8859-1',
1116 'fre_fr.8859': 'fr_FR.ISO8859-1',
1117 'french': 'fr_FR.ISO8859-1',
1118 'french.iso88591': 'fr_CH.ISO8859-1',
1119 'french_france': 'fr_FR.ISO8859-1',
1120 'french_france.8859': 'fr_FR.ISO8859-1',
1121 'ga': 'ga_IE.ISO8859-1',
1122 'ga_ie': 'ga_IE.ISO8859-1',
1123 'ga_ie.iso88591': 'ga_IE.ISO8859-1',
1124 'ga_ie.iso885914': 'ga_IE.ISO8859-14',
1125 'ga_ie.iso885915': 'ga_IE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001126 'ga_ie.iso885915@euro': 'ga_IE.ISO8859-15',
1127 'ga_ie.utf8@euro': 'ga_IE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001128 'ga_ie@euro': 'ga_IE.ISO8859-15',
1129 'galego': 'gl_ES.ISO8859-1',
1130 'galician': 'gl_ES.ISO8859-1',
1131 'gd': 'gd_GB.ISO8859-1',
1132 'gd_gb': 'gd_GB.ISO8859-1',
1133 'gd_gb.iso88591': 'gd_GB.ISO8859-1',
1134 'gd_gb.iso885914': 'gd_GB.ISO8859-14',
1135 'gd_gb.iso885915': 'gd_GB.ISO8859-15',
1136 'gd_gb@euro': 'gd_GB.ISO8859-15',
1137 'ger_de': 'de_DE.ISO8859-1',
1138 'ger_de.8859': 'de_DE.ISO8859-1',
1139 'german': 'de_DE.ISO8859-1',
1140 'german.iso88591': 'de_CH.ISO8859-1',
1141 'german_germany': 'de_DE.ISO8859-1',
1142 'german_germany.8859': 'de_DE.ISO8859-1',
1143 'gl': 'gl_ES.ISO8859-1',
1144 'gl_es': 'gl_ES.ISO8859-1',
1145 'gl_es.iso88591': 'gl_ES.ISO8859-1',
1146 'gl_es.iso885915': 'gl_ES.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001147 'gl_es.iso885915@euro': 'gl_ES.ISO8859-15',
1148 'gl_es.utf8@euro': 'gl_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001149 'gl_es@euro': 'gl_ES.ISO8859-15',
1150 'greek': 'el_GR.ISO8859-7',
1151 'greek.iso88597': 'el_GR.ISO8859-7',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001152 'gu_in': 'gu_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001153 'gv': 'gv_GB.ISO8859-1',
1154 'gv_gb': 'gv_GB.ISO8859-1',
1155 'gv_gb.iso88591': 'gv_GB.ISO8859-1',
1156 'gv_gb.iso885914': 'gv_GB.ISO8859-14',
1157 'gv_gb.iso885915': 'gv_GB.ISO8859-15',
1158 'gv_gb@euro': 'gv_GB.ISO8859-15',
1159 'he': 'he_IL.ISO8859-8',
1160 'he_il': 'he_IL.ISO8859-8',
1161 'he_il.cp1255': 'he_IL.CP1255',
1162 'he_il.iso88598': 'he_IL.ISO8859-8',
1163 'he_il.microsoftcp1255': 'he_IL.CP1255',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001164 'hebrew': 'iw_IL.ISO8859-8',
1165 'hebrew.iso88598': 'iw_IL.ISO8859-8',
1166 'hi': 'hi_IN.ISCII-DEV',
1167 'hi_in': 'hi_IN.ISCII-DEV',
1168 'hi_in.isciidev': 'hi_IN.ISCII-DEV',
Antoine Pitroufc531532010-04-11 22:32:39 +00001169 'hne': 'hne_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001170 'hr': 'hr_HR.ISO8859-2',
1171 'hr_hr': 'hr_HR.ISO8859-2',
1172 'hr_hr.iso88592': 'hr_HR.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001173 'hrvatski': 'hr_HR.ISO8859-2',
1174 'hu': 'hu_HU.ISO8859-2',
1175 'hu_hu': 'hu_HU.ISO8859-2',
1176 'hu_hu.iso88592': 'hu_HU.ISO8859-2',
1177 'hungarian': 'hu_HU.ISO8859-2',
1178 'icelandic': 'is_IS.ISO8859-1',
1179 'icelandic.iso88591': 'is_IS.ISO8859-1',
1180 'id': 'id_ID.ISO8859-1',
1181 'id_id': 'id_ID.ISO8859-1',
1182 'in': 'id_ID.ISO8859-1',
1183 'in_id': 'id_ID.ISO8859-1',
1184 'is': 'is_IS.ISO8859-1',
1185 'is_is': 'is_IS.ISO8859-1',
1186 'is_is.iso88591': 'is_IS.ISO8859-1',
1187 'is_is.iso885915': 'is_IS.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001188 'is_is@euro': 'is_IS.ISO8859-15',
1189 'iso-8859-1': 'en_US.ISO8859-1',
1190 'iso-8859-15': 'en_US.ISO8859-15',
1191 'iso8859-1': 'en_US.ISO8859-1',
1192 'iso8859-15': 'en_US.ISO8859-15',
1193 'iso_8859_1': 'en_US.ISO8859-1',
1194 'iso_8859_15': 'en_US.ISO8859-15',
1195 'it': 'it_IT.ISO8859-1',
Antoine Pitroufc531532010-04-11 22:32:39 +00001196 'it.iso885915': 'it_IT.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001197 'it_ch': 'it_CH.ISO8859-1',
1198 'it_ch.iso88591': 'it_CH.ISO8859-1',
1199 'it_ch.iso885915': 'it_CH.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001200 'it_ch@euro': 'it_CH.ISO8859-15',
1201 'it_it': 'it_IT.ISO8859-1',
1202 'it_it.88591': 'it_IT.ISO8859-1',
1203 'it_it.iso88591': 'it_IT.ISO8859-1',
1204 'it_it.iso885915': 'it_IT.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001205 'it_it.iso885915@euro': 'it_IT.ISO8859-15',
1206 'it_it.utf8@euro': 'it_IT.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001207 'it_it@euro': 'it_IT.ISO8859-15',
1208 'italian': 'it_IT.ISO8859-1',
1209 'italian.iso88591': 'it_IT.ISO8859-1',
1210 'iu': 'iu_CA.NUNACOM-8',
1211 'iu_ca': 'iu_CA.NUNACOM-8',
1212 'iu_ca.nunacom8': 'iu_CA.NUNACOM-8',
1213 'iw': 'he_IL.ISO8859-8',
1214 'iw_il': 'he_IL.ISO8859-8',
1215 'iw_il.iso88598': 'he_IL.ISO8859-8',
1216 'ja': 'ja_JP.eucJP',
1217 'ja.jis': 'ja_JP.JIS7',
1218 'ja.sjis': 'ja_JP.SJIS',
1219 'ja_jp': 'ja_JP.eucJP',
1220 'ja_jp.ajec': 'ja_JP.eucJP',
1221 'ja_jp.euc': 'ja_JP.eucJP',
1222 'ja_jp.eucjp': 'ja_JP.eucJP',
1223 'ja_jp.iso-2022-jp': 'ja_JP.JIS7',
1224 'ja_jp.iso2022jp': 'ja_JP.JIS7',
1225 'ja_jp.jis': 'ja_JP.JIS7',
1226 'ja_jp.jis7': 'ja_JP.JIS7',
1227 'ja_jp.mscode': 'ja_JP.SJIS',
Antoine Pitroufc531532010-04-11 22:32:39 +00001228 'ja_jp.pck': 'ja_JP.SJIS',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001229 'ja_jp.sjis': 'ja_JP.SJIS',
1230 'ja_jp.ujis': 'ja_JP.eucJP',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001231 'japan': 'ja_JP.eucJP',
1232 'japanese': 'ja_JP.eucJP',
1233 'japanese-euc': 'ja_JP.eucJP',
1234 'japanese.euc': 'ja_JP.eucJP',
1235 'japanese.sjis': 'ja_JP.SJIS',
1236 'jp_jp': 'ja_JP.eucJP',
1237 'ka': 'ka_GE.GEORGIAN-ACADEMY',
1238 'ka_ge': 'ka_GE.GEORGIAN-ACADEMY',
1239 'ka_ge.georgianacademy': 'ka_GE.GEORGIAN-ACADEMY',
1240 'ka_ge.georgianps': 'ka_GE.GEORGIAN-PS',
1241 'ka_ge.georgianrs': 'ka_GE.GEORGIAN-ACADEMY',
1242 'kl': 'kl_GL.ISO8859-1',
1243 'kl_gl': 'kl_GL.ISO8859-1',
1244 'kl_gl.iso88591': 'kl_GL.ISO8859-1',
1245 'kl_gl.iso885915': 'kl_GL.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001246 'kl_gl@euro': 'kl_GL.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001247 'km_kh': 'km_KH.UTF-8',
Antoine Pitroufc531532010-04-11 22:32:39 +00001248 'kn': 'kn_IN.UTF-8',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001249 'kn_in': 'kn_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001250 'ko': 'ko_KR.eucKR',
1251 'ko_kr': 'ko_KR.eucKR',
1252 'ko_kr.euc': 'ko_KR.eucKR',
1253 'ko_kr.euckr': 'ko_KR.eucKR',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001254 'korean': 'ko_KR.eucKR',
1255 'korean.euc': 'ko_KR.eucKR',
Antoine Pitroufc531532010-04-11 22:32:39 +00001256 'ks': 'ks_IN.UTF-8',
1257 'ks_in@devanagari': 'ks_IN@devanagari.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001258 'kw': 'kw_GB.ISO8859-1',
1259 'kw_gb': 'kw_GB.ISO8859-1',
1260 'kw_gb.iso88591': 'kw_GB.ISO8859-1',
1261 'kw_gb.iso885914': 'kw_GB.ISO8859-14',
1262 'kw_gb.iso885915': 'kw_GB.ISO8859-15',
1263 'kw_gb@euro': 'kw_GB.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001264 'ky': 'ky_KG.UTF-8',
1265 'ky_kg': 'ky_KG.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001266 'lithuanian': 'lt_LT.ISO8859-13',
1267 'lo': 'lo_LA.MULELAO-1',
1268 'lo_la': 'lo_LA.MULELAO-1',
1269 'lo_la.cp1133': 'lo_LA.IBM-CP1133',
1270 'lo_la.ibmcp1133': 'lo_LA.IBM-CP1133',
1271 'lo_la.mulelao1': 'lo_LA.MULELAO-1',
1272 'lt': 'lt_LT.ISO8859-13',
1273 'lt_lt': 'lt_LT.ISO8859-13',
1274 'lt_lt.iso885913': 'lt_LT.ISO8859-13',
1275 'lt_lt.iso88594': 'lt_LT.ISO8859-4',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001276 'lv': 'lv_LV.ISO8859-13',
1277 'lv_lv': 'lv_LV.ISO8859-13',
1278 'lv_lv.iso885913': 'lv_LV.ISO8859-13',
1279 'lv_lv.iso88594': 'lv_LV.ISO8859-4',
Antoine Pitroufc531532010-04-11 22:32:39 +00001280 'mai': 'mai_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001281 'mi': 'mi_NZ.ISO8859-1',
1282 'mi_nz': 'mi_NZ.ISO8859-1',
1283 'mi_nz.iso88591': 'mi_NZ.ISO8859-1',
1284 'mk': 'mk_MK.ISO8859-5',
1285 'mk_mk': 'mk_MK.ISO8859-5',
1286 'mk_mk.cp1251': 'mk_MK.CP1251',
1287 'mk_mk.iso88595': 'mk_MK.ISO8859-5',
1288 'mk_mk.microsoftcp1251': 'mk_MK.CP1251',
Antoine Pitroufc531532010-04-11 22:32:39 +00001289 'ml': 'ml_IN.UTF-8',
1290 'mr': 'mr_IN.UTF-8',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001291 'mr_in': 'mr_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001292 'ms': 'ms_MY.ISO8859-1',
1293 'ms_my': 'ms_MY.ISO8859-1',
1294 'ms_my.iso88591': 'ms_MY.ISO8859-1',
1295 'mt': 'mt_MT.ISO8859-3',
1296 'mt_mt': 'mt_MT.ISO8859-3',
1297 'mt_mt.iso88593': 'mt_MT.ISO8859-3',
1298 'nb': 'nb_NO.ISO8859-1',
1299 'nb_no': 'nb_NO.ISO8859-1',
1300 'nb_no.88591': 'nb_NO.ISO8859-1',
1301 'nb_no.iso88591': 'nb_NO.ISO8859-1',
1302 'nb_no.iso885915': 'nb_NO.ISO8859-15',
1303 'nb_no@euro': 'nb_NO.ISO8859-15',
1304 'nl': 'nl_NL.ISO8859-1',
Antoine Pitroufc531532010-04-11 22:32:39 +00001305 'nl.iso885915': 'nl_NL.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001306 'nl_be': 'nl_BE.ISO8859-1',
1307 'nl_be.88591': 'nl_BE.ISO8859-1',
1308 'nl_be.iso88591': 'nl_BE.ISO8859-1',
1309 'nl_be.iso885915': 'nl_BE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001310 'nl_be.iso885915@euro': 'nl_BE.ISO8859-15',
1311 'nl_be.utf8@euro': 'nl_BE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001312 'nl_be@euro': 'nl_BE.ISO8859-15',
1313 'nl_nl': 'nl_NL.ISO8859-1',
1314 'nl_nl.88591': 'nl_NL.ISO8859-1',
1315 'nl_nl.iso88591': 'nl_NL.ISO8859-1',
1316 'nl_nl.iso885915': 'nl_NL.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001317 'nl_nl.iso885915@euro': 'nl_NL.ISO8859-15',
1318 'nl_nl.utf8@euro': 'nl_NL.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001319 'nl_nl@euro': 'nl_NL.ISO8859-15',
1320 'nn': 'nn_NO.ISO8859-1',
1321 'nn_no': 'nn_NO.ISO8859-1',
1322 'nn_no.88591': 'nn_NO.ISO8859-1',
1323 'nn_no.iso88591': 'nn_NO.ISO8859-1',
1324 'nn_no.iso885915': 'nn_NO.ISO8859-15',
1325 'nn_no@euro': 'nn_NO.ISO8859-15',
1326 'no': 'no_NO.ISO8859-1',
1327 'no@nynorsk': 'ny_NO.ISO8859-1',
1328 'no_no': 'no_NO.ISO8859-1',
1329 'no_no.88591': 'no_NO.ISO8859-1',
1330 'no_no.iso88591': 'no_NO.ISO8859-1',
1331 'no_no.iso885915': 'no_NO.ISO8859-15',
Antoine Pitroufc531532010-04-11 22:32:39 +00001332 'no_no.iso88591@bokmal': 'no_NO.ISO8859-1',
1333 'no_no.iso88591@nynorsk': 'no_NO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001334 'no_no@euro': 'no_NO.ISO8859-15',
1335 'norwegian': 'no_NO.ISO8859-1',
1336 'norwegian.iso88591': 'no_NO.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001337 'nr': 'nr_ZA.ISO8859-1',
1338 'nr_za': 'nr_ZA.ISO8859-1',
1339 'nr_za.iso88591': 'nr_ZA.ISO8859-1',
1340 'nso': 'nso_ZA.ISO8859-15',
1341 'nso_za': 'nso_ZA.ISO8859-15',
1342 'nso_za.iso885915': 'nso_ZA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001343 'ny': 'ny_NO.ISO8859-1',
1344 'ny_no': 'ny_NO.ISO8859-1',
1345 'ny_no.88591': 'ny_NO.ISO8859-1',
1346 'ny_no.iso88591': 'ny_NO.ISO8859-1',
1347 'ny_no.iso885915': 'ny_NO.ISO8859-15',
1348 'ny_no@euro': 'ny_NO.ISO8859-15',
1349 'nynorsk': 'nn_NO.ISO8859-1',
1350 'oc': 'oc_FR.ISO8859-1',
1351 'oc_fr': 'oc_FR.ISO8859-1',
1352 'oc_fr.iso88591': 'oc_FR.ISO8859-1',
1353 'oc_fr.iso885915': 'oc_FR.ISO8859-15',
1354 'oc_fr@euro': 'oc_FR.ISO8859-15',
Antoine Pitroufc531532010-04-11 22:32:39 +00001355 'or': 'or_IN.UTF-8',
1356 'pa': 'pa_IN.UTF-8',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001357 'pa_in': 'pa_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001358 'pd': 'pd_US.ISO8859-1',
1359 'pd_de': 'pd_DE.ISO8859-1',
1360 'pd_de.iso88591': 'pd_DE.ISO8859-1',
1361 'pd_de.iso885915': 'pd_DE.ISO8859-15',
1362 'pd_de@euro': 'pd_DE.ISO8859-15',
1363 'pd_us': 'pd_US.ISO8859-1',
1364 'pd_us.iso88591': 'pd_US.ISO8859-1',
1365 'pd_us.iso885915': 'pd_US.ISO8859-15',
1366 'pd_us@euro': 'pd_US.ISO8859-15',
1367 'ph': 'ph_PH.ISO8859-1',
1368 'ph_ph': 'ph_PH.ISO8859-1',
1369 'ph_ph.iso88591': 'ph_PH.ISO8859-1',
1370 'pl': 'pl_PL.ISO8859-2',
1371 'pl_pl': 'pl_PL.ISO8859-2',
1372 'pl_pl.iso88592': 'pl_PL.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001373 'polish': 'pl_PL.ISO8859-2',
1374 'portuguese': 'pt_PT.ISO8859-1',
1375 'portuguese.iso88591': 'pt_PT.ISO8859-1',
1376 'portuguese_brazil': 'pt_BR.ISO8859-1',
1377 'portuguese_brazil.8859': 'pt_BR.ISO8859-1',
1378 'posix': 'C',
1379 'posix-utf2': 'C',
1380 'pp': 'pp_AN.ISO8859-1',
1381 'pp_an': 'pp_AN.ISO8859-1',
1382 'pp_an.iso88591': 'pp_AN.ISO8859-1',
1383 'pt': 'pt_PT.ISO8859-1',
Antoine Pitroufc531532010-04-11 22:32:39 +00001384 'pt.iso885915': 'pt_PT.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001385 'pt_br': 'pt_BR.ISO8859-1',
1386 'pt_br.88591': 'pt_BR.ISO8859-1',
1387 'pt_br.iso88591': 'pt_BR.ISO8859-1',
1388 'pt_br.iso885915': 'pt_BR.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001389 'pt_br@euro': 'pt_BR.ISO8859-15',
1390 'pt_pt': 'pt_PT.ISO8859-1',
1391 'pt_pt.88591': 'pt_PT.ISO8859-1',
1392 'pt_pt.iso88591': 'pt_PT.ISO8859-1',
1393 'pt_pt.iso885915': 'pt_PT.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001394 'pt_pt.iso885915@euro': 'pt_PT.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001395 'pt_pt.utf8@euro': 'pt_PT.UTF-8',
1396 'pt_pt@euro': 'pt_PT.ISO8859-15',
1397 'ro': 'ro_RO.ISO8859-2',
1398 'ro_ro': 'ro_RO.ISO8859-2',
1399 'ro_ro.iso88592': 'ro_RO.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001400 'romanian': 'ro_RO.ISO8859-2',
Antoine Pitroufc531532010-04-11 22:32:39 +00001401 'ru': 'ru_RU.UTF-8',
1402 'ru.koi8r': 'ru_RU.KOI8-R',
1403 'ru_ru': 'ru_RU.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001404 'ru_ru.cp1251': 'ru_RU.CP1251',
1405 'ru_ru.iso88595': 'ru_RU.ISO8859-5',
1406 'ru_ru.koi8r': 'ru_RU.KOI8-R',
1407 'ru_ru.microsoftcp1251': 'ru_RU.CP1251',
1408 'ru_ua': 'ru_UA.KOI8-U',
1409 'ru_ua.cp1251': 'ru_UA.CP1251',
1410 'ru_ua.koi8u': 'ru_UA.KOI8-U',
1411 'ru_ua.microsoftcp1251': 'ru_UA.CP1251',
1412 'rumanian': 'ro_RO.ISO8859-2',
1413 'russian': 'ru_RU.ISO8859-5',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001414 'rw': 'rw_RW.ISO8859-1',
1415 'rw_rw': 'rw_RW.ISO8859-1',
1416 'rw_rw.iso88591': 'rw_RW.ISO8859-1',
Antoine Pitroufc531532010-04-11 22:32:39 +00001417 'sd': 'sd_IN@devanagari.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001418 'se_no': 'se_NO.UTF-8',
Antoine Pitroufc531532010-04-11 22:32:39 +00001419 'serbocroatian': 'sr_RS.UTF-8@latin',
1420 'sh': 'sr_RS.UTF-8@latin',
1421 'sh_ba.iso88592@bosnia': 'sr_CS.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001422 'sh_hr': 'sh_HR.ISO8859-2',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001423 'sh_hr.iso88592': 'hr_HR.ISO8859-2',
1424 'sh_sp': 'sr_CS.ISO8859-2',
Antoine Pitroufc531532010-04-11 22:32:39 +00001425 'sh_yu': 'sr_RS.UTF-8@latin',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001426 'si': 'si_LK.UTF-8',
1427 'si_lk': 'si_LK.UTF-8',
1428 'sinhala': 'si_LK.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001429 'sk': 'sk_SK.ISO8859-2',
1430 'sk_sk': 'sk_SK.ISO8859-2',
1431 'sk_sk.iso88592': 'sk_SK.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001432 'sl': 'sl_SI.ISO8859-2',
1433 'sl_cs': 'sl_CS.ISO8859-2',
1434 'sl_si': 'sl_SI.ISO8859-2',
1435 'sl_si.iso88592': 'sl_SI.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001436 'slovak': 'sk_SK.ISO8859-2',
1437 'slovene': 'sl_SI.ISO8859-2',
1438 'slovenian': 'sl_SI.ISO8859-2',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001439 'sp': 'sr_CS.ISO8859-5',
1440 'sp_yu': 'sr_CS.ISO8859-5',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001441 'spanish': 'es_ES.ISO8859-1',
1442 'spanish.iso88591': 'es_ES.ISO8859-1',
1443 'spanish_spain': 'es_ES.ISO8859-1',
1444 'spanish_spain.8859': 'es_ES.ISO8859-1',
1445 'sq': 'sq_AL.ISO8859-2',
1446 'sq_al': 'sq_AL.ISO8859-2',
1447 'sq_al.iso88592': 'sq_AL.ISO8859-2',
Antoine Pitroufc531532010-04-11 22:32:39 +00001448 'sr': 'sr_RS.UTF-8',
1449 'sr@cyrillic': 'sr_RS.UTF-8',
1450 'sr@latin': 'sr_RS.UTF-8@latin',
1451 'sr@latn': 'sr_RS.UTF-8@latin',
1452 'sr_cs': 'sr_RS.UTF-8',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001453 'sr_cs.iso88592': 'sr_CS.ISO8859-2',
1454 'sr_cs.iso88592@latn': 'sr_CS.ISO8859-2',
1455 'sr_cs.iso88595': 'sr_CS.ISO8859-5',
Antoine Pitroufc531532010-04-11 22:32:39 +00001456 'sr_cs.utf8@latn': 'sr_RS.UTF-8@latin',
1457 'sr_cs@latn': 'sr_RS.UTF-8@latin',
1458 'sr_me': 'sr_ME.UTF-8',
1459 'sr_rs': 'sr_RS.UTF-8',
1460 'sr_rs.utf8@latn': 'sr_RS.UTF-8@latin',
1461 'sr_rs@latin': 'sr_RS.UTF-8@latin',
1462 'sr_rs@latn': 'sr_RS.UTF-8@latin',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001463 'sr_sp': 'sr_CS.ISO8859-2',
Antoine Pitroufc531532010-04-11 22:32:39 +00001464 'sr_yu': 'sr_RS.UTF-8@latin',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001465 'sr_yu.cp1251@cyrillic': 'sr_CS.CP1251',
1466 'sr_yu.iso88592': 'sr_CS.ISO8859-2',
1467 'sr_yu.iso88595': 'sr_CS.ISO8859-5',
1468 'sr_yu.iso88595@cyrillic': 'sr_CS.ISO8859-5',
1469 'sr_yu.microsoftcp1251@cyrillic': 'sr_CS.CP1251',
Antoine Pitroufc531532010-04-11 22:32:39 +00001470 'sr_yu.utf8@cyrillic': 'sr_RS.UTF-8',
1471 'sr_yu@cyrillic': 'sr_RS.UTF-8',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001472 'ss': 'ss_ZA.ISO8859-1',
1473 'ss_za': 'ss_ZA.ISO8859-1',
1474 'ss_za.iso88591': 'ss_ZA.ISO8859-1',
1475 'st': 'st_ZA.ISO8859-1',
1476 'st_za': 'st_ZA.ISO8859-1',
1477 'st_za.iso88591': 'st_ZA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001478 'sv': 'sv_SE.ISO8859-1',
Antoine Pitroufc531532010-04-11 22:32:39 +00001479 'sv.iso885915': 'sv_SE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001480 'sv_fi': 'sv_FI.ISO8859-1',
1481 'sv_fi.iso88591': 'sv_FI.ISO8859-1',
1482 'sv_fi.iso885915': 'sv_FI.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001483 'sv_fi.iso885915@euro': 'sv_FI.ISO8859-15',
1484 'sv_fi.utf8@euro': 'sv_FI.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001485 'sv_fi@euro': 'sv_FI.ISO8859-15',
1486 'sv_se': 'sv_SE.ISO8859-1',
1487 'sv_se.88591': 'sv_SE.ISO8859-1',
1488 'sv_se.iso88591': 'sv_SE.ISO8859-1',
1489 'sv_se.iso885915': 'sv_SE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001490 'sv_se@euro': 'sv_SE.ISO8859-15',
1491 'swedish': 'sv_SE.ISO8859-1',
1492 'swedish.iso88591': 'sv_SE.ISO8859-1',
1493 'ta': 'ta_IN.TSCII-0',
1494 'ta_in': 'ta_IN.TSCII-0',
1495 'ta_in.tscii': 'ta_IN.TSCII-0',
1496 'ta_in.tscii0': 'ta_IN.TSCII-0',
Antoine Pitroufc531532010-04-11 22:32:39 +00001497 'te': 'te_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001498 'tg': 'tg_TJ.KOI8-C',
1499 'tg_tj': 'tg_TJ.KOI8-C',
1500 'tg_tj.koi8c': 'tg_TJ.KOI8-C',
1501 'th': 'th_TH.ISO8859-11',
1502 'th_th': 'th_TH.ISO8859-11',
1503 'th_th.iso885911': 'th_TH.ISO8859-11',
1504 'th_th.tactis': 'th_TH.TIS620',
1505 'th_th.tis620': 'th_TH.TIS620',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001506 'thai': 'th_TH.ISO8859-11',
1507 'tl': 'tl_PH.ISO8859-1',
1508 'tl_ph': 'tl_PH.ISO8859-1',
1509 'tl_ph.iso88591': 'tl_PH.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001510 'tn': 'tn_ZA.ISO8859-15',
1511 'tn_za': 'tn_ZA.ISO8859-15',
1512 'tn_za.iso885915': 'tn_ZA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001513 'tr': 'tr_TR.ISO8859-9',
1514 'tr_tr': 'tr_TR.ISO8859-9',
1515 'tr_tr.iso88599': 'tr_TR.ISO8859-9',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001516 'ts': 'ts_ZA.ISO8859-1',
1517 'ts_za': 'ts_ZA.ISO8859-1',
1518 'ts_za.iso88591': 'ts_ZA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001519 'tt': 'tt_RU.TATAR-CYR',
1520 'tt_ru': 'tt_RU.TATAR-CYR',
1521 'tt_ru.koi8c': 'tt_RU.KOI8-C',
1522 'tt_ru.tatarcyr': 'tt_RU.TATAR-CYR',
1523 'turkish': 'tr_TR.ISO8859-9',
1524 'turkish.iso88599': 'tr_TR.ISO8859-9',
1525 'uk': 'uk_UA.KOI8-U',
1526 'uk_ua': 'uk_UA.KOI8-U',
1527 'uk_ua.cp1251': 'uk_UA.CP1251',
1528 'uk_ua.iso88595': 'uk_UA.ISO8859-5',
1529 'uk_ua.koi8u': 'uk_UA.KOI8-U',
1530 'uk_ua.microsoftcp1251': 'uk_UA.CP1251',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001531 'univ': 'en_US.utf',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001532 'universal': 'en_US.utf',
1533 'universal.utf8@ucs4': 'en_US.UTF-8',
1534 'ur': 'ur_PK.CP1256',
1535 'ur_pk': 'ur_PK.CP1256',
1536 'ur_pk.cp1256': 'ur_PK.CP1256',
1537 'ur_pk.microsoftcp1256': 'ur_PK.CP1256',
1538 'uz': 'uz_UZ.UTF-8',
1539 'uz_uz': 'uz_UZ.UTF-8',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001540 'uz_uz.iso88591': 'uz_UZ.ISO8859-1',
1541 'uz_uz.utf8@cyrillic': 'uz_UZ.UTF-8',
1542 'uz_uz@cyrillic': 'uz_UZ.UTF-8',
1543 've': 've_ZA.UTF-8',
1544 've_za': 've_ZA.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001545 'vi': 'vi_VN.TCVN',
1546 'vi_vn': 'vi_VN.TCVN',
1547 'vi_vn.tcvn': 'vi_VN.TCVN',
1548 'vi_vn.tcvn5712': 'vi_VN.TCVN',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001549 'vi_vn.viscii': 'vi_VN.VISCII',
1550 'vi_vn.viscii111': 'vi_VN.VISCII',
1551 'wa': 'wa_BE.ISO8859-1',
1552 'wa_be': 'wa_BE.ISO8859-1',
1553 'wa_be.iso88591': 'wa_BE.ISO8859-1',
1554 'wa_be.iso885915': 'wa_BE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001555 'wa_be.iso885915@euro': 'wa_BE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001556 'wa_be@euro': 'wa_BE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001557 'xh': 'xh_ZA.ISO8859-1',
1558 'xh_za': 'xh_ZA.ISO8859-1',
1559 'xh_za.iso88591': 'xh_ZA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001560 'yi': 'yi_US.CP1255',
1561 'yi_us': 'yi_US.CP1255',
1562 'yi_us.cp1255': 'yi_US.CP1255',
1563 'yi_us.microsoftcp1255': 'yi_US.CP1255',
1564 'zh': 'zh_CN.eucCN',
1565 'zh_cn': 'zh_CN.gb2312',
1566 'zh_cn.big5': 'zh_TW.big5',
1567 'zh_cn.euc': 'zh_CN.eucCN',
1568 'zh_cn.gb18030': 'zh_CN.gb18030',
1569 'zh_cn.gb2312': 'zh_CN.gb2312',
1570 'zh_cn.gbk': 'zh_CN.gbk',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001571 'zh_hk': 'zh_HK.big5hkscs',
1572 'zh_hk.big5': 'zh_HK.big5',
Antoine Pitroufc531532010-04-11 22:32:39 +00001573 'zh_hk.big5hk': 'zh_HK.big5hkscs',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001574 'zh_hk.big5hkscs': 'zh_HK.big5hkscs',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001575 'zh_tw': 'zh_TW.big5',
1576 'zh_tw.big5': 'zh_TW.big5',
1577 'zh_tw.euc': 'zh_TW.eucTW',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001578 'zh_tw.euctw': 'zh_TW.eucTW',
1579 'zu': 'zu_ZA.ISO8859-1',
1580 'zu_za': 'zu_ZA.ISO8859-1',
1581 'zu_za.iso88591': 'zu_ZA.ISO8859-1',
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001582}
1583
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001584#
Georg Brandlb709c2c2006-01-20 09:07:35 +00001585# This maps Windows language identifiers to locale strings.
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001586#
Tim Peters777f1082006-01-20 20:03:24 +00001587# This list has been updated from
Georg Brandlb709c2c2006-01-20 09:07:35 +00001588# 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 +00001589# to include every locale up to Windows Vista.
Fredrik Lundh37a09822002-10-19 20:19:10 +00001590#
Georg Brandl5035c1c2006-01-20 13:38:26 +00001591# NOTE: this mapping is incomplete. If your language is missing, please
Éric Araujo8d4d74e2012-02-26 01:28:34 +01001592# submit a bug report to the Python bug tracker at http://bugs.python.org/
Georg Brandl5035c1c2006-01-20 13:38:26 +00001593# Make sure you include the missing language identifier and the suggested
1594# locale code.
1595#
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001596
1597windows_locale = {
Georg Brandlb709c2c2006-01-20 09:07:35 +00001598 0x0436: "af_ZA", # Afrikaans
1599 0x041c: "sq_AL", # Albanian
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001600 0x0484: "gsw_FR",# Alsatian - France
1601 0x045e: "am_ET", # Amharic - Ethiopia
Georg Brandlb709c2c2006-01-20 09:07:35 +00001602 0x0401: "ar_SA", # Arabic - Saudi Arabia
1603 0x0801: "ar_IQ", # Arabic - Iraq
1604 0x0c01: "ar_EG", # Arabic - Egypt
1605 0x1001: "ar_LY", # Arabic - Libya
1606 0x1401: "ar_DZ", # Arabic - Algeria
1607 0x1801: "ar_MA", # Arabic - Morocco
1608 0x1c01: "ar_TN", # Arabic - Tunisia
1609 0x2001: "ar_OM", # Arabic - Oman
1610 0x2401: "ar_YE", # Arabic - Yemen
1611 0x2801: "ar_SY", # Arabic - Syria
1612 0x2c01: "ar_JO", # Arabic - Jordan
1613 0x3001: "ar_LB", # Arabic - Lebanon
1614 0x3401: "ar_KW", # Arabic - Kuwait
1615 0x3801: "ar_AE", # Arabic - United Arab Emirates
1616 0x3c01: "ar_BH", # Arabic - Bahrain
1617 0x4001: "ar_QA", # Arabic - Qatar
1618 0x042b: "hy_AM", # Armenian
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001619 0x044d: "as_IN", # Assamese - India
1620 0x042c: "az_AZ", # Azeri - Latin
Georg Brandlb709c2c2006-01-20 09:07:35 +00001621 0x082c: "az_AZ", # Azeri - Cyrillic
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001622 0x046d: "ba_RU", # Bashkir
1623 0x042d: "eu_ES", # Basque - Russia
Georg Brandlb709c2c2006-01-20 09:07:35 +00001624 0x0423: "be_BY", # Belarusian
1625 0x0445: "bn_IN", # Begali
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001626 0x201a: "bs_BA", # Bosnian - Cyrillic
1627 0x141a: "bs_BA", # Bosnian - Latin
Georg Brandlb709c2c2006-01-20 09:07:35 +00001628 0x047e: "br_FR", # Breton - France
1629 0x0402: "bg_BG", # Bulgarian
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001630# 0x0455: "my_MM", # Burmese - Not supported
Georg Brandlb709c2c2006-01-20 09:07:35 +00001631 0x0403: "ca_ES", # Catalan
1632 0x0004: "zh_CHS",# Chinese - Simplified
1633 0x0404: "zh_TW", # Chinese - Taiwan
1634 0x0804: "zh_CN", # Chinese - PRC
1635 0x0c04: "zh_HK", # Chinese - Hong Kong S.A.R.
1636 0x1004: "zh_SG", # Chinese - Singapore
1637 0x1404: "zh_MO", # Chinese - Macao S.A.R.
1638 0x7c04: "zh_CHT",# Chinese - Traditional
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001639 0x0483: "co_FR", # Corsican - France
Georg Brandlb709c2c2006-01-20 09:07:35 +00001640 0x041a: "hr_HR", # Croatian
1641 0x101a: "hr_BA", # Croatian - Bosnia
1642 0x0405: "cs_CZ", # Czech
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001643 0x0406: "da_DK", # Danish
Georg Brandlb709c2c2006-01-20 09:07:35 +00001644 0x048c: "gbz_AF",# Dari - Afghanistan
1645 0x0465: "div_MV",# Divehi - Maldives
1646 0x0413: "nl_NL", # Dutch - The Netherlands
1647 0x0813: "nl_BE", # Dutch - Belgium
1648 0x0409: "en_US", # English - United States
1649 0x0809: "en_GB", # English - United Kingdom
1650 0x0c09: "en_AU", # English - Australia
1651 0x1009: "en_CA", # English - Canada
1652 0x1409: "en_NZ", # English - New Zealand
1653 0x1809: "en_IE", # English - Ireland
1654 0x1c09: "en_ZA", # English - South Africa
1655 0x2009: "en_JA", # English - Jamaica
1656 0x2409: "en_CB", # English - Carribbean
1657 0x2809: "en_BZ", # English - Belize
1658 0x2c09: "en_TT", # English - Trinidad
1659 0x3009: "en_ZW", # English - Zimbabwe
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001660 0x3409: "en_PH", # English - Philippines
1661 0x4009: "en_IN", # English - India
1662 0x4409: "en_MY", # English - Malaysia
1663 0x4809: "en_IN", # English - Singapore
Georg Brandlb709c2c2006-01-20 09:07:35 +00001664 0x0425: "et_EE", # Estonian
1665 0x0438: "fo_FO", # Faroese
1666 0x0464: "fil_PH",# Filipino
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001667 0x040b: "fi_FI", # Finnish
Georg Brandlb709c2c2006-01-20 09:07:35 +00001668 0x040c: "fr_FR", # French - France
1669 0x080c: "fr_BE", # French - Belgium
1670 0x0c0c: "fr_CA", # French - Canada
1671 0x100c: "fr_CH", # French - Switzerland
1672 0x140c: "fr_LU", # French - Luxembourg
1673 0x180c: "fr_MC", # French - Monaco
1674 0x0462: "fy_NL", # Frisian - Netherlands
1675 0x0456: "gl_ES", # Galician
1676 0x0437: "ka_GE", # Georgian
1677 0x0407: "de_DE", # German - Germany
1678 0x0807: "de_CH", # German - Switzerland
1679 0x0c07: "de_AT", # German - Austria
1680 0x1007: "de_LU", # German - Luxembourg
1681 0x1407: "de_LI", # German - Liechtenstein
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001682 0x0408: "el_GR", # Greek
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001683 0x046f: "kl_GL", # Greenlandic - Greenland
Georg Brandlb709c2c2006-01-20 09:07:35 +00001684 0x0447: "gu_IN", # Gujarati
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001685 0x0468: "ha_NG", # Hausa - Latin
Georg Brandlb709c2c2006-01-20 09:07:35 +00001686 0x040d: "he_IL", # Hebrew
1687 0x0439: "hi_IN", # Hindi
1688 0x040e: "hu_HU", # Hungarian
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001689 0x040f: "is_IS", # Icelandic
Georg Brandlb709c2c2006-01-20 09:07:35 +00001690 0x0421: "id_ID", # Indonesian
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001691 0x045d: "iu_CA", # Inuktitut - Syllabics
Georg Brandlb709c2c2006-01-20 09:07:35 +00001692 0x085d: "iu_CA", # Inuktitut - Latin
1693 0x083c: "ga_IE", # Irish - Ireland
Georg Brandlb709c2c2006-01-20 09:07:35 +00001694 0x0410: "it_IT", # Italian - Italy
1695 0x0810: "it_CH", # Italian - Switzerland
1696 0x0411: "ja_JP", # Japanese
1697 0x044b: "kn_IN", # Kannada - India
1698 0x043f: "kk_KZ", # Kazakh
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001699 0x0453: "kh_KH", # Khmer - Cambodia
1700 0x0486: "qut_GT",# K'iche - Guatemala
1701 0x0487: "rw_RW", # Kinyarwanda - Rwanda
Georg Brandlb709c2c2006-01-20 09:07:35 +00001702 0x0457: "kok_IN",# Konkani
1703 0x0412: "ko_KR", # Korean
1704 0x0440: "ky_KG", # Kyrgyz
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001705 0x0454: "lo_LA", # Lao - Lao PDR
Georg Brandlb709c2c2006-01-20 09:07:35 +00001706 0x0426: "lv_LV", # Latvian
1707 0x0427: "lt_LT", # Lithuanian
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001708 0x082e: "dsb_DE",# Lower Sorbian - Germany
Georg Brandlb709c2c2006-01-20 09:07:35 +00001709 0x046e: "lb_LU", # Luxembourgish
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001710 0x042f: "mk_MK", # FYROM Macedonian
Georg Brandlb709c2c2006-01-20 09:07:35 +00001711 0x043e: "ms_MY", # Malay - Malaysia
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001712 0x083e: "ms_BN", # Malay - Brunei Darussalam
Georg Brandlb709c2c2006-01-20 09:07:35 +00001713 0x044c: "ml_IN", # Malayalam - India
1714 0x043a: "mt_MT", # Maltese
1715 0x0481: "mi_NZ", # Maori
1716 0x047a: "arn_CL",# Mapudungun
1717 0x044e: "mr_IN", # Marathi
1718 0x047c: "moh_CA",# Mohawk - Canada
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001719 0x0450: "mn_MN", # Mongolian - Cyrillic
1720 0x0850: "mn_CN", # Mongolian - PRC
Georg Brandlb709c2c2006-01-20 09:07:35 +00001721 0x0461: "ne_NP", # Nepali
1722 0x0414: "nb_NO", # Norwegian - Bokmal
1723 0x0814: "nn_NO", # Norwegian - Nynorsk
1724 0x0482: "oc_FR", # Occitan - France
1725 0x0448: "or_IN", # Oriya - India
1726 0x0463: "ps_AF", # Pashto - Afghanistan
1727 0x0429: "fa_IR", # Persian
1728 0x0415: "pl_PL", # Polish
1729 0x0416: "pt_BR", # Portuguese - Brazil
1730 0x0816: "pt_PT", # Portuguese - Portugal
1731 0x0446: "pa_IN", # Punjabi
1732 0x046b: "quz_BO",# Quechua (Bolivia)
1733 0x086b: "quz_EC",# Quechua (Ecuador)
1734 0x0c6b: "quz_PE",# Quechua (Peru)
1735 0x0418: "ro_RO", # Romanian - Romania
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001736 0x0417: "rm_CH", # Romansh
Georg Brandlb709c2c2006-01-20 09:07:35 +00001737 0x0419: "ru_RU", # Russian
1738 0x243b: "smn_FI",# Sami Finland
1739 0x103b: "smj_NO",# Sami Norway
1740 0x143b: "smj_SE",# Sami Sweden
1741 0x043b: "se_NO", # Sami Northern Norway
1742 0x083b: "se_SE", # Sami Northern Sweden
1743 0x0c3b: "se_FI", # Sami Northern Finland
1744 0x203b: "sms_FI",# Sami Skolt
1745 0x183b: "sma_NO",# Sami Southern Norway
1746 0x1c3b: "sma_SE",# Sami Southern Sweden
1747 0x044f: "sa_IN", # Sanskrit
1748 0x0c1a: "sr_SP", # Serbian - Cyrillic
1749 0x1c1a: "sr_BA", # Serbian - Bosnia Cyrillic
1750 0x081a: "sr_SP", # Serbian - Latin
1751 0x181a: "sr_BA", # Serbian - Bosnia Latin
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001752 0x045b: "si_LK", # Sinhala - Sri Lanka
Georg Brandlb709c2c2006-01-20 09:07:35 +00001753 0x046c: "ns_ZA", # Northern Sotho
1754 0x0432: "tn_ZA", # Setswana - Southern Africa
1755 0x041b: "sk_SK", # Slovak
1756 0x0424: "sl_SI", # Slovenian
1757 0x040a: "es_ES", # Spanish - Spain
1758 0x080a: "es_MX", # Spanish - Mexico
1759 0x0c0a: "es_ES", # Spanish - Spain (Modern)
1760 0x100a: "es_GT", # Spanish - Guatemala
1761 0x140a: "es_CR", # Spanish - Costa Rica
1762 0x180a: "es_PA", # Spanish - Panama
1763 0x1c0a: "es_DO", # Spanish - Dominican Republic
1764 0x200a: "es_VE", # Spanish - Venezuela
1765 0x240a: "es_CO", # Spanish - Colombia
1766 0x280a: "es_PE", # Spanish - Peru
1767 0x2c0a: "es_AR", # Spanish - Argentina
1768 0x300a: "es_EC", # Spanish - Ecuador
1769 0x340a: "es_CL", # Spanish - Chile
1770 0x380a: "es_UR", # Spanish - Uruguay
1771 0x3c0a: "es_PY", # Spanish - Paraguay
1772 0x400a: "es_BO", # Spanish - Bolivia
1773 0x440a: "es_SV", # Spanish - El Salvador
1774 0x480a: "es_HN", # Spanish - Honduras
1775 0x4c0a: "es_NI", # Spanish - Nicaragua
1776 0x500a: "es_PR", # Spanish - Puerto Rico
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001777 0x540a: "es_US", # Spanish - United States
1778# 0x0430: "", # Sutu - Not supported
Georg Brandlb709c2c2006-01-20 09:07:35 +00001779 0x0441: "sw_KE", # Swahili
1780 0x041d: "sv_SE", # Swedish - Sweden
1781 0x081d: "sv_FI", # Swedish - Finland
1782 0x045a: "syr_SY",# Syriac
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001783 0x0428: "tg_TJ", # Tajik - Cyrillic
1784 0x085f: "tmz_DZ",# Tamazight - Latin
Georg Brandlb709c2c2006-01-20 09:07:35 +00001785 0x0449: "ta_IN", # Tamil
1786 0x0444: "tt_RU", # Tatar
1787 0x044a: "te_IN", # Telugu
1788 0x041e: "th_TH", # Thai
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001789 0x0851: "bo_BT", # Tibetan - Bhutan
1790 0x0451: "bo_CN", # Tibetan - PRC
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001791 0x041f: "tr_TR", # Turkish
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001792 0x0442: "tk_TM", # Turkmen - Cyrillic
1793 0x0480: "ug_CN", # Uighur - Arabic
Georg Brandlb709c2c2006-01-20 09:07:35 +00001794 0x0422: "uk_UA", # Ukrainian
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001795 0x042e: "wen_DE",# Upper Sorbian - Germany
Georg Brandlb709c2c2006-01-20 09:07:35 +00001796 0x0420: "ur_PK", # Urdu
1797 0x0820: "ur_IN", # Urdu - India
1798 0x0443: "uz_UZ", # Uzbek - Latin
1799 0x0843: "uz_UZ", # Uzbek - Cyrillic
1800 0x042a: "vi_VN", # Vietnamese
1801 0x0452: "cy_GB", # Welsh
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001802 0x0488: "wo_SN", # Wolof - Senegal
1803 0x0434: "xh_ZA", # Xhosa - South Africa
1804 0x0485: "sah_RU",# Yakut - Cyrillic
1805 0x0478: "ii_CN", # Yi - PRC
1806 0x046a: "yo_NG", # Yoruba - Nigeria
1807 0x0435: "zu_ZA", # Zulu
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001808}
1809
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001810def _print_locale():
1811
1812 """ Test function.
1813 """
1814 categories = {}
1815 def _init_categories(categories=categories):
1816 for k,v in globals().items():
1817 if k[:3] == 'LC_':
1818 categories[k] = v
1819 _init_categories()
1820 del categories['LC_ALL']
1821
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001822 print 'Locale defaults as determined by getdefaultlocale():'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001823 print '-'*72
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001824 lang, enc = getdefaultlocale()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001825 print 'Language: ', lang or '(undefined)'
1826 print 'Encoding: ', enc or '(undefined)'
1827 print
1828
1829 print 'Locale settings on startup:'
1830 print '-'*72
1831 for name,category in categories.items():
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001832 print name, '...'
1833 lang, enc = getlocale(category)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001834 print ' Language: ', lang or '(undefined)'
1835 print ' Encoding: ', enc or '(undefined)'
1836 print
1837
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001838 print
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001839 print 'Locale settings after calling resetlocale():'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001840 print '-'*72
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001841 resetlocale()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001842 for name,category in categories.items():
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001843 print name, '...'
1844 lang, enc = getlocale(category)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001845 print ' Language: ', lang or '(undefined)'
1846 print ' Encoding: ', enc or '(undefined)'
1847 print
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001848
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001849 try:
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001850 setlocale(LC_ALL, "")
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001851 except:
1852 print 'NOTE:'
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001853 print 'setlocale(LC_ALL, "") does not support the default locale'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001854 print 'given in the OS environment variables.'
1855 else:
1856 print
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001857 print 'Locale settings after calling setlocale(LC_ALL, ""):'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001858 print '-'*72
1859 for name,category in categories.items():
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001860 print name, '...'
1861 lang, enc = getlocale(category)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001862 print ' Language: ', lang or '(undefined)'
1863 print ' Encoding: ', enc or '(undefined)'
1864 print
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001865
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001866###
Guido van Rossumeef1d4e1997-11-19 19:01:43 +00001867
Tim Peters1baf8292001-01-24 10:13:46 +00001868try:
1869 LC_MESSAGES
Skip Montanaro0897f0c2002-03-25 21:40:36 +00001870except NameError:
Tim Peters1baf8292001-01-24 10:13:46 +00001871 pass
1872else:
1873 __all__.append("LC_MESSAGES")
1874
Guido van Rossumeef1d4e1997-11-19 19:01:43 +00001875if __name__=='__main__':
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001876 print 'Locale aliasing:'
1877 print
1878 _print_locale()
1879 print
1880 print 'Number formatting:'
1881 print
1882 _test()