blob: 3dc4cafcb152030f83c6d089f18128d36de1fb1c [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 Murraye59482e2009-04-01 03:42:00 +000014import sys
15import encodings
16import encodings.aliases
17import re
18import collections
Georg Brandl1a3284e2007-12-02 09:40:06 +000019from builtins import str as _builtin_str
Antoine Pitrou83d6a872008-07-25 21:45:08 +000020import functools
Marc-André Lemburg5431bc32000-06-07 09:11:40 +000021
Fredrik Lundh6c86b992000-07-09 17:12:58 +000022# Try importing the _locale module.
23#
24# If this fails, fall back on a basic 'C' locale emulation.
Guido van Rossumeef1d4e1997-11-19 19:01:43 +000025
Tim Peters1baf8292001-01-24 10:13:46 +000026# Yuck: LC_MESSAGES is non-standard: can't tell whether it exists before
27# trying the import. So __all__ is also fiddled at the end of the file.
Guido van Rossum360e4b82007-05-14 22:51:27 +000028__all__ = ["getlocale", "getdefaultlocale", "getpreferredencoding", "Error",
29 "setlocale", "resetlocale", "localeconv", "strcoll", "strxfrm",
30 "str", "atof", "atoi", "format", "format_string", "currency",
31 "normalize", "LC_CTYPE", "LC_COLLATE", "LC_TIME", "LC_MONETARY",
32 "LC_NUMERIC", "LC_ALL", "CHAR_MAX"]
Skip Montanaro17ab1232001-01-24 06:27:27 +000033
Neal Norwitz48b98de2008-03-10 04:49:25 +000034def _strcoll(a,b):
35 """ strcoll(string,string) -> int.
36 Compares two strings according to the locale.
37 """
Mark Dickinsona56c4672009-01-27 18:17:45 +000038 return (a > b) - (a < b)
Neal Norwitz48b98de2008-03-10 04:49:25 +000039
40def _strxfrm(s):
41 """ strxfrm(string) -> string.
42 Returns a string that behaves for cmp locale-aware.
43 """
44 return s
45
Marc-André Lemburg23481142000-06-08 17:49:41 +000046try:
Fredrik Lundh6c86b992000-07-09 17:12:58 +000047
Marc-André Lemburg23481142000-06-08 17:49:41 +000048 from _locale import *
49
50except ImportError:
51
Fredrik Lundh6c86b992000-07-09 17:12:58 +000052 # Locale emulation
53
Marc-André Lemburg23481142000-06-08 17:49:41 +000054 CHAR_MAX = 127
55 LC_ALL = 6
56 LC_COLLATE = 3
57 LC_CTYPE = 0
58 LC_MESSAGES = 5
59 LC_MONETARY = 4
60 LC_NUMERIC = 1
61 LC_TIME = 2
62 Error = ValueError
63
64 def localeconv():
Fredrik Lundh6c86b992000-07-09 17:12:58 +000065 """ localeconv() -> dict.
Marc-André Lemburg23481142000-06-08 17:49:41 +000066 Returns numeric and monetary locale-specific parameters.
67 """
68 # 'C' locale default values
69 return {'grouping': [127],
70 'currency_symbol': '',
71 'n_sign_posn': 127,
Fredrik Lundh6c86b992000-07-09 17:12:58 +000072 'p_cs_precedes': 127,
73 'n_cs_precedes': 127,
74 'mon_grouping': [],
Marc-André Lemburg23481142000-06-08 17:49:41 +000075 'n_sep_by_space': 127,
76 'decimal_point': '.',
77 'negative_sign': '',
78 'positive_sign': '',
Fredrik Lundh6c86b992000-07-09 17:12:58 +000079 'p_sep_by_space': 127,
Marc-André Lemburg23481142000-06-08 17:49:41 +000080 'int_curr_symbol': '',
Fredrik Lundh6c86b992000-07-09 17:12:58 +000081 'p_sign_posn': 127,
Marc-André Lemburg23481142000-06-08 17:49:41 +000082 'thousands_sep': '',
Fredrik Lundh6c86b992000-07-09 17:12:58 +000083 'mon_thousands_sep': '',
84 'frac_digits': 127,
Marc-André Lemburg23481142000-06-08 17:49:41 +000085 'mon_decimal_point': '',
86 'int_frac_digits': 127}
Fredrik Lundh6c86b992000-07-09 17:12:58 +000087
Marc-André Lemburg23481142000-06-08 17:49:41 +000088 def setlocale(category, value=None):
Fredrik Lundh6c86b992000-07-09 17:12:58 +000089 """ setlocale(integer,string=None) -> string.
Marc-André Lemburg23481142000-06-08 17:49:41 +000090 Activates/queries locale processing.
91 """
Martin v. Löwis103d6e72003-03-30 15:42:13 +000092 if value not in (None, '', 'C'):
Collin Winterce36ad82007-08-30 01:19:48 +000093 raise Error('_locale emulation only supports "C" locale')
Marc-André Lemburg23481142000-06-08 17:49:41 +000094 return 'C'
95
Neal Norwitz48b98de2008-03-10 04:49:25 +000096# These may or may not exist in _locale, so be sure to set them.
97if 'strxfrm' not in globals():
98 strxfrm = _strxfrm
99if 'strcoll' not in globals():
100 strcoll = _strcoll
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000101
Antoine Pitrou83d6a872008-07-25 21:45:08 +0000102
103_localeconv = localeconv
104
105# With this dict, you can override some items of localeconv's return value.
106# This is useful for testing purposes.
107_override_localeconv = {}
108
109@functools.wraps(_localeconv)
110def localeconv():
111 d = _localeconv()
112 if _override_localeconv:
113 d.update(_override_localeconv)
114 return d
115
116
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000117### Number formatting APIs
118
119# Author: Martin von Loewis
Thomas Wouters477c8d52006-05-27 19:21:47 +0000120# improved by Georg Brandl
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000121
Antoine Pitrou350370c2009-03-14 00:13:13 +0000122# Iterate over grouping intervals
123def _grouping_intervals(grouping):
Mark Dickinsonbbffb252009-08-04 21:57:18 +0000124 last_interval = None
Antoine Pitrou350370c2009-03-14 00:13:13 +0000125 for interval in grouping:
126 # if grouping is -1, we are done
127 if interval == CHAR_MAX:
128 return
129 # 0: re-use last group ad infinitum
130 if interval == 0:
Mark Dickinsonbbffb252009-08-04 21:57:18 +0000131 if last_interval is None:
132 raise ValueError("invalid grouping")
Antoine Pitrou350370c2009-03-14 00:13:13 +0000133 while True:
134 yield last_interval
135 yield interval
136 last_interval = interval
137
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000138#perform the grouping from right to left
Thomas Wouters477c8d52006-05-27 19:21:47 +0000139def _group(s, monetary=False):
140 conv = localeconv()
141 thousands_sep = conv[monetary and 'mon_thousands_sep' or 'thousands_sep']
142 grouping = conv[monetary and 'mon_grouping' or 'grouping']
143 if not grouping:
144 return (s, 0)
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000145 if s[-1] == ' ':
Antoine Pitrou350370c2009-03-14 00:13:13 +0000146 stripped = s.rstrip()
147 right_spaces = s[len(stripped):]
148 s = stripped
149 else:
150 right_spaces = ''
151 left_spaces = ''
152 groups = []
153 for interval in _grouping_intervals(grouping):
154 if not s or s[-1] not in "0123456789":
155 # only non-digit characters remain (sign, spaces)
156 left_spaces = s
157 s = ''
Guido van Rossum45e2fbc1998-03-26 21:13:24 +0000158 break
Antoine Pitrou350370c2009-03-14 00:13:13 +0000159 groups.append(s[-interval:])
160 s = s[:-interval]
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000161 if s:
Antoine Pitrou350370c2009-03-14 00:13:13 +0000162 groups.append(s)
163 groups.reverse()
164 return (
165 left_spaces + thousands_sep.join(groups) + right_spaces,
Antoine Pitrou6cf17aa2009-03-18 20:26:42 +0000166 len(thousands_sep) * (len(groups) - 1)
Antoine Pitrou350370c2009-03-14 00:13:13 +0000167 )
168
169# Strip a given amount of excess padding from the given string
170def _strip_padding(s, amount):
171 lpos = 0
172 while amount and s[lpos] == ' ':
173 lpos += 1
174 amount -= 1
175 rpos = len(s) - 1
176 while amount and s[rpos] == ' ':
177 rpos -= 1
178 amount -= 1
179 return s[lpos:rpos+1]
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000180
R. David Murraye59482e2009-04-01 03:42:00 +0000181_percent_re = re.compile(r'%(?:\((?P<key>.*?)\))?'
182 r'(?P<modifiers>[-#0-9 +*.hlL]*?)[eEfFgGdiouxXcrs%]')
183
Thomas Wouters477c8d52006-05-27 19:21:47 +0000184def format(percent, value, grouping=False, monetary=False, *additional):
185 """Returns the locale-aware substitution of a %? specifier
186 (percent).
187
188 additional is for format strings which contain one or more
189 '*' modifiers."""
190 # this is only for one-percent-specifier strings and this should be checked
R. David Murraye59482e2009-04-01 03:42:00 +0000191 match = _percent_re.match(percent)
192 if not match or len(match.group())!= len(percent):
193 raise ValueError(("format() must be given exactly one %%char "
194 "format specifier, %s not valid") % repr(percent))
195 return _format(percent, value, grouping, monetary, *additional)
196
197def _format(percent, value, grouping=False, monetary=False, *additional):
Thomas Wouters477c8d52006-05-27 19:21:47 +0000198 if additional:
199 formatted = percent % ((value,) + additional)
200 else:
201 formatted = percent % value
202 # floats and decimal ints need special action!
203 if percent[-1] in 'eEfFgG':
204 seps = 0
205 parts = formatted.split('.')
206 if grouping:
207 parts[0], seps = _group(parts[0], monetary=monetary)
208 decimal_point = localeconv()[monetary and 'mon_decimal_point'
209 or 'decimal_point']
210 formatted = decimal_point.join(parts)
Antoine Pitrou350370c2009-03-14 00:13:13 +0000211 if seps:
212 formatted = _strip_padding(formatted, seps)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000213 elif percent[-1] in 'diu':
Antoine Pitrou350370c2009-03-14 00:13:13 +0000214 seps = 0
Thomas Wouters477c8d52006-05-27 19:21:47 +0000215 if grouping:
Antoine Pitrou350370c2009-03-14 00:13:13 +0000216 formatted, seps = _group(formatted, monetary=monetary)
217 if seps:
218 formatted = _strip_padding(formatted, seps)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000219 return formatted
220
Thomas Wouters477c8d52006-05-27 19:21:47 +0000221def format_string(f, val, grouping=False):
222 """Formats a string in the same way that the % formatting would use,
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000223 but takes the current locale into account.
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000224 Grouping is applied if the third parameter is true."""
Thomas Wouters477c8d52006-05-27 19:21:47 +0000225 percents = list(_percent_re.finditer(f))
226 new_f = _percent_re.sub('%s', f)
227
R. David Murrayad78d152010-04-27 02:45:53 +0000228 if isinstance(val, collections.Mapping):
229 new_val = []
230 for perc in percents:
231 if perc.group()[-1]=='%':
232 new_val.append('%')
233 else:
234 new_val.append(format(perc.group(), val, grouping))
235 else:
236 if not isinstance(val, tuple):
237 val = (val,)
238 new_val = []
Thomas Wouters477c8d52006-05-27 19:21:47 +0000239 i = 0
240 for perc in percents:
R. David Murrayad78d152010-04-27 02:45:53 +0000241 if perc.group()[-1]=='%':
242 new_val.append('%')
243 else:
244 starcount = perc.group('modifiers').count('*')
245 new_val.append(_format(perc.group(),
246 val[i],
247 grouping,
248 False,
249 *val[i+1:i+1+starcount]))
250 i += (1 + starcount)
251 val = tuple(new_val)
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000252
Thomas Wouters477c8d52006-05-27 19:21:47 +0000253 return new_f % val
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000254
Thomas Wouters477c8d52006-05-27 19:21:47 +0000255def currency(val, symbol=True, grouping=False, international=False):
256 """Formats val according to the currency settings
257 in the current locale."""
258 conv = localeconv()
259
260 # check for illegal values
261 digits = conv[international and 'int_frac_digits' or 'frac_digits']
262 if digits == 127:
263 raise ValueError("Currency formatting is not possible using "
264 "the 'C' locale.")
265
266 s = format('%%.%if' % digits, abs(val), grouping, monetary=True)
267 # '<' and '>' are markers if the sign must be inserted between symbol and value
268 s = '<' + s + '>'
269
270 if symbol:
271 smb = conv[international and 'int_curr_symbol' or 'currency_symbol']
272 precedes = conv[val<0 and 'n_cs_precedes' or 'p_cs_precedes']
273 separated = conv[val<0 and 'n_sep_by_space' or 'p_sep_by_space']
274
275 if precedes:
276 s = smb + (separated and ' ' or '') + s
277 else:
278 s = s + (separated and ' ' or '') + smb
279
280 sign_pos = conv[val<0 and 'n_sign_posn' or 'p_sign_posn']
281 sign = conv[val<0 and 'negative_sign' or 'positive_sign']
282
283 if sign_pos == 0:
284 s = '(' + s + ')'
285 elif sign_pos == 1:
286 s = sign + s
287 elif sign_pos == 2:
288 s = s + sign
289 elif sign_pos == 3:
290 s = s.replace('<', sign)
291 elif sign_pos == 4:
292 s = s.replace('>', sign)
293 else:
294 # the default if nothing specified;
295 # this should be the most fitting sign position
296 s = sign + s
297
298 return s.replace('<', '').replace('>', '')
Martin v. Löwisdb786872001-01-21 18:52:33 +0000299
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000300def str(val):
301 """Convert float to integer, taking the locale into account."""
Thomas Wouters477c8d52006-05-27 19:21:47 +0000302 return format("%.12g", val)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000303
Thomas Wouters477c8d52006-05-27 19:21:47 +0000304def atof(string, func=float):
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000305 "Parses a string as a float according to the locale settings."
306 #First, get rid of the grouping
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000307 ts = localeconv()['thousands_sep']
308 if ts:
Skip Montanaro249369c2004-04-10 16:39:32 +0000309 string = string.replace(ts, '')
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000310 #next, replace the decimal point with a dot
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000311 dd = localeconv()['decimal_point']
312 if dd:
Skip Montanaro249369c2004-04-10 16:39:32 +0000313 string = string.replace(dd, '.')
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000314 #finally, parse the string
Skip Montanaro249369c2004-04-10 16:39:32 +0000315 return func(string)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000316
317def atoi(str):
318 "Converts a string to an integer according to the locale settings."
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000319 return atof(str, int)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000320
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000321def _test():
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000322 setlocale(LC_ALL, "")
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000323 #do grouping
Thomas Wouters477c8d52006-05-27 19:21:47 +0000324 s1 = format("%d", 123456789,1)
Guido van Rossumbe19ed72007-02-09 05:37:30 +0000325 print(s1, "is", atoi(s1))
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000326 #standard formatting
Thomas Wouters477c8d52006-05-27 19:21:47 +0000327 s1 = str(3.14)
Guido van Rossumbe19ed72007-02-09 05:37:30 +0000328 print(s1, "is", atof(s1))
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000329
330### Locale name aliasing engine
331
332# Author: Marc-Andre Lemburg, mal@lemburg.com
Fredrik Lundh37a09822002-10-19 20:19:10 +0000333# Various tweaks by Fredrik Lundh <fredrik@pythonware.com>
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000334
335# store away the low-level version of setlocale (it's
336# overridden below)
337_setlocale = setlocale
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000338
339def normalize(localename):
340
341 """ Returns a normalized locale code for the given locale
342 name.
343
344 The returned locale code is formatted for use with
345 setlocale().
346
347 If normalization fails, the original name is returned
348 unchanged.
349
350 If the given encoding is not known, the function defaults to
351 the default encoding for the locale code just like setlocale()
352 does.
353
354 """
355 # Normalize the locale name and extract the encoding
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000356 fullname = localename.lower()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000357 if ':' in fullname:
358 # ':' is sometimes used as encoding delimiter.
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000359 fullname = fullname.replace(':', '.')
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000360 if '.' in fullname:
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000361 langname, encoding = fullname.split('.')[:2]
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000362 fullname = langname + '.' + encoding
363 else:
364 langname = fullname
365 encoding = ''
366
367 # First lookup: fullname (possibly with encoding)
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000368 norm_encoding = encoding.replace('-', '')
369 norm_encoding = norm_encoding.replace('_', '')
370 lookup_name = langname + '.' + encoding
371 code = locale_alias.get(lookup_name, None)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000372 if code is not None:
373 return code
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000374 #print 'first lookup failed'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000375
376 # Second try: langname (without encoding)
377 code = locale_alias.get(langname, None)
378 if code is not None:
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000379 #print 'langname lookup succeeded'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000380 if '.' in code:
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000381 langname, defenc = code.split('.')
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000382 else:
383 langname = code
384 defenc = ''
385 if encoding:
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000386 # Convert the encoding to a C lib compatible encoding string
387 norm_encoding = encodings.normalize_encoding(encoding)
388 #print 'norm encoding: %r' % norm_encoding
389 norm_encoding = encodings.aliases.aliases.get(norm_encoding,
390 norm_encoding)
391 #print 'aliased encoding: %r' % norm_encoding
392 encoding = locale_encoding_alias.get(norm_encoding,
393 norm_encoding)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000394 else:
395 encoding = defenc
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000396 #print 'found encoding %r' % encoding
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000397 if encoding:
398 return langname + '.' + encoding
399 else:
400 return langname
401
402 else:
403 return localename
404
405def _parse_localename(localename):
406
407 """ Parses the locale code for localename and returns the
408 result as tuple (language code, encoding).
409
410 The localename is normalized and passed through the locale
411 alias engine. A ValueError is raised in case the locale name
412 cannot be parsed.
413
414 The language code corresponds to RFC 1766. code and encoding
415 can be None in case the values cannot be determined or are
Jeremy Hyltona05e2932000-06-28 14:48:01 +0000416 unknown to this implementation.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000417
418 """
419 code = normalize(localename)
Georg Brandlb709c2c2006-01-20 09:07:35 +0000420 if '@' in code:
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000421 # Deal with locale modifiers
422 code, modifier = code.split('@')
423 if modifier == 'euro' and '.' not in code:
424 # Assume Latin-9 for @euro locales. This is bogus,
425 # since some systems may use other encodings for these
426 # locales. Also, we ignore other modifiers.
427 return code, 'iso-8859-15'
Tim Peters230a60c2002-11-09 05:08:07 +0000428
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000429 if '.' in code:
Raymond Hettinger346e67f2005-01-01 06:10:26 +0000430 return tuple(code.split('.')[:2])
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000431 elif code == 'C':
432 return None, None
Collin Winterce36ad82007-08-30 01:19:48 +0000433 raise ValueError('unknown locale: %s' % localename)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000434
435def _build_localename(localetuple):
436
437 """ Builds a locale code from the given tuple (language code,
438 encoding).
439
440 No aliasing or normalizing takes place.
441
442 """
443 language, encoding = localetuple
444 if language is None:
445 language = 'C'
446 if encoding is None:
447 return language
448 else:
449 return language + '.' + encoding
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000450
Matthias Klosef3f231f2005-09-20 07:02:49 +0000451def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000452
453 """ Tries to determine the default locale settings and returns
454 them as tuple (language code, encoding).
455
456 According to POSIX, a program which has not called
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000457 setlocale(LC_ALL, "") runs using the portable 'C' locale.
458 Calling setlocale(LC_ALL, "") lets it use the default locale as
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000459 defined by the LANG variable. Since we don't want to interfere
Thomas Wouters7e474022000-07-16 12:04:32 +0000460 with the current locale setting we thus emulate the behavior
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000461 in the way described above.
462
463 To maintain compatibility with other platforms, not only the
464 LANG variable is tested, but a list of variables given as
465 envvars parameter. The first found to be defined will be
466 used. envvars defaults to the search path used in GNU gettext;
467 it must always contain the variable name 'LANG'.
468
469 Except for the code 'C', the language code corresponds to RFC
470 1766. code and encoding can be None in case the values cannot
471 be determined.
472
473 """
Fredrik Lundh04661322000-07-09 23:16:10 +0000474
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000475 try:
476 # check if it's supported by the _locale module
477 import _locale
478 code, encoding = _locale._getdefaultlocale()
Fredrik Lundh04661322000-07-09 23:16:10 +0000479 except (ImportError, AttributeError):
480 pass
481 else:
Fredrik Lundh663809e2000-07-10 19:32:19 +0000482 # make sure the code/encoding values are valid
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000483 if sys.platform == "win32" and code and code[:2] == "0x":
484 # map windows language identifier to language name
485 code = windows_locale.get(int(code, 0))
Fredrik Lundh663809e2000-07-10 19:32:19 +0000486 # ...add other platform-specific processing here, if
487 # necessary...
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000488 return code, encoding
Fredrik Lundh04661322000-07-09 23:16:10 +0000489
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000490 # fall back on POSIX behaviour
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000491 import os
492 lookup = os.environ.get
493 for variable in envvars:
494 localename = lookup(variable,None)
Martin v. Löwisc8ae31d2004-07-26 12:45:18 +0000495 if localename:
Matthias Klosef3f231f2005-09-20 07:02:49 +0000496 if variable == 'LANGUAGE':
497 localename = localename.split(':')[0]
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000498 break
499 else:
500 localename = 'C'
501 return _parse_localename(localename)
502
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000503
504def getlocale(category=LC_CTYPE):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000505
506 """ Returns the current setting for the given locale category as
507 tuple (language code, encoding).
508
509 category may be one of the LC_* value except LC_ALL. It
510 defaults to LC_CTYPE.
511
512 Except for the code 'C', the language code corresponds to RFC
513 1766. code and encoding can be None in case the values cannot
514 be determined.
515
516 """
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000517 localename = _setlocale(category)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000518 if category == LC_ALL and ';' in localename:
Collin Winterce36ad82007-08-30 01:19:48 +0000519 raise TypeError('category LC_ALL is not supported')
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000520 return _parse_localename(localename)
521
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000522def setlocale(category, locale=None):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000523
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000524 """ Set the locale for the given category. The locale can be
525 a string, a locale tuple (language code, encoding), or None.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000526
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000527 Locale tuples are converted to strings the locale aliasing
528 engine. Locale strings are passed directly to the C lib.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000529
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000530 category may be given as one of the LC_* values.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000531
532 """
Guido van Rossum3172c5d2007-10-16 18:12:55 +0000533 if locale and not isinstance(locale, _builtin_str):
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000534 # convert to string
535 locale = normalize(_build_localename(locale))
536 return _setlocale(category, locale)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000537
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000538def resetlocale(category=LC_ALL):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000539
540 """ Sets the locale for category to the default setting.
541
542 The default setting is determined by calling
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000543 getdefaultlocale(). category defaults to LC_ALL.
544
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000545 """
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000546 _setlocale(category, _build_localename(getdefaultlocale()))
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000547
Ronald Oussorenfe8a3d62009-06-07 15:29:46 +0000548if sys.platform.startswith("win"):
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000549 # On Win32, this will return the ANSI code page
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000550 def getpreferredencoding(do_setlocale = True):
551 """Return the charset that the user is likely using."""
552 import _locale
Tim Petersa326f472002-11-05 03:49:09 +0000553 return _locale._getdefaultlocale()[1]
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000554else:
555 # On Unix, if CODESET is available, use that.
556 try:
557 CODESET
558 except NameError:
559 # Fall back to parsing environment variables :-(
560 def getpreferredencoding(do_setlocale = True):
561 """Return the charset that the user is likely using,
562 by looking at environment variables."""
Martin v. Löwis071ef772008-03-08 11:24:24 +0000563 res = getdefaultlocale()[1]
564 if res is None:
565 # LANG not set, default conservatively to ASCII
566 res = 'ascii'
567 return res
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000568 else:
569 def getpreferredencoding(do_setlocale = True):
570 """Return the charset that the user is likely using,
571 according to the system configuration."""
572 if do_setlocale:
573 oldloc = setlocale(LC_CTYPE)
Jeroen Ruigrok van der Wervenbcf85062009-05-06 05:33:24 +0000574 try:
575 setlocale(LC_CTYPE, "")
Jeroen Ruigrok van der Werven6ca2e0a2009-05-06 13:18:35 +0000576 except Error:
Jeroen Ruigrok van der Wervenbcf85062009-05-06 05:33:24 +0000577 pass
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000578 result = nl_langinfo(CODESET)
Ronald Oussoren6d77e072009-09-06 13:59:02 +0000579 if not result and sys.platform == 'darwin':
580 # nl_langinfo can return an empty string
581 # when the setting has an invalid value.
582 # Default to UTF-8 in that case because
583 # UTF-8 is the default charset on OSX and
584 # returning nothing will crash the
585 # interpreter.
586 result = 'UTF-8'
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000587 setlocale(LC_CTYPE, oldloc)
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000588 else:
Ronald Oussoren6d77e072009-09-06 13:59:02 +0000589 result = nl_langinfo(CODESET)
590 if not result and sys.platform == 'darwin':
591 # See above for explanation
592 result = 'UTF-8'
Antoine Pitrou6a448d42009-10-19 19:43:09 +0000593 return result
Tim Peters230a60c2002-11-09 05:08:07 +0000594
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000595
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000596### Database
597#
598# The following data was extracted from the locale.alias file which
599# comes with X11 and then hand edited removing the explicit encoding
600# definitions and adding some more aliases. The file is usually
601# available as /usr/lib/X11/locale/locale.alias.
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000602#
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000603
604#
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000605# The local_encoding_alias table maps lowercase encoding alias names
606# to C locale encoding names (case-sensitive). Note that normalize()
607# first looks up the encoding in the encodings.aliases dictionary and
608# then applies this mapping to find the correct C lib name for the
609# encoding.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000610#
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000611locale_encoding_alias = {
612
613 # Mappings for non-standard encoding names used in locale names
614 '437': 'C',
615 'c': 'C',
616 'en': 'ISO8859-1',
617 'jis': 'JIS7',
618 'jis7': 'JIS7',
619 'ajec': 'eucJP',
620
621 # Mappings from Python codec names to C lib encoding names
622 'ascii': 'ISO8859-1',
623 'latin_1': 'ISO8859-1',
624 'iso8859_1': 'ISO8859-1',
625 'iso8859_10': 'ISO8859-10',
626 'iso8859_11': 'ISO8859-11',
627 'iso8859_13': 'ISO8859-13',
628 'iso8859_14': 'ISO8859-14',
629 'iso8859_15': 'ISO8859-15',
Jeroen Ruigrok van der Werven4072ff32009-05-08 14:17:00 +0000630 'iso8859_16': 'ISO8859-16',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000631 'iso8859_2': 'ISO8859-2',
632 'iso8859_3': 'ISO8859-3',
633 'iso8859_4': 'ISO8859-4',
634 'iso8859_5': 'ISO8859-5',
635 'iso8859_6': 'ISO8859-6',
636 'iso8859_7': 'ISO8859-7',
637 'iso8859_8': 'ISO8859-8',
638 'iso8859_9': 'ISO8859-9',
639 'iso2022_jp': 'JIS7',
640 'shift_jis': 'SJIS',
641 'tactis': 'TACTIS',
642 'euc_jp': 'eucJP',
643 'euc_kr': 'eucKR',
Ronald Oussoren02a67ac2011-05-17 12:44:54 +0200644 'utf_8': 'UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000645 'koi8_r': 'KOI8-R',
646 'koi8_u': 'KOI8-U',
647 # XXX This list is still incomplete. If you know more
648 # mappings, please file a bug report. Thanks.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000649}
650
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000651#
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000652# The locale_alias table maps lowercase alias names to C locale names
653# (case-sensitive). Encodings are always separated from the locale
654# name using a dot ('.'); they should only be given in case the
655# language name is needed to interpret the given encoding alias
656# correctly (CJK codes often have this need).
657#
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000658# Note that the normalize() function which uses this tables
659# removes '_' and '-' characters from the encoding part of the
660# locale name before doing the lookup. This saves a lot of
661# space in the table.
662#
663# MAL 2004-12-10:
664# Updated alias mapping to most recent locale.alias file
665# from X.org distribution using makelocalealias.py.
666#
667# These are the differences compared to the old mapping (Python 2.4
668# and older):
669#
670# updated 'bg' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
671# updated 'bg_bg' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
672# updated 'bulgarian' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
673# updated 'cz' -> 'cz_CZ.ISO8859-2' to 'cs_CZ.ISO8859-2'
674# updated 'cz_cz' -> 'cz_CZ.ISO8859-2' to 'cs_CZ.ISO8859-2'
675# updated 'czech' -> 'cs_CS.ISO8859-2' to 'cs_CZ.ISO8859-2'
676# updated 'dutch' -> 'nl_BE.ISO8859-1' to 'nl_NL.ISO8859-1'
677# updated 'et' -> 'et_EE.ISO8859-4' to 'et_EE.ISO8859-15'
678# updated 'et_ee' -> 'et_EE.ISO8859-4' to 'et_EE.ISO8859-15'
679# updated 'fi' -> 'fi_FI.ISO8859-1' to 'fi_FI.ISO8859-15'
680# updated 'fi_fi' -> 'fi_FI.ISO8859-1' to 'fi_FI.ISO8859-15'
681# updated 'iw' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
682# updated 'iw_il' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
683# updated 'japanese' -> 'ja_JP.SJIS' to 'ja_JP.eucJP'
684# updated 'lt' -> 'lt_LT.ISO8859-4' to 'lt_LT.ISO8859-13'
685# updated 'lv' -> 'lv_LV.ISO8859-4' to 'lv_LV.ISO8859-13'
686# updated 'sl' -> 'sl_CS.ISO8859-2' to 'sl_SI.ISO8859-2'
687# updated 'slovene' -> 'sl_CS.ISO8859-2' to 'sl_SI.ISO8859-2'
688# updated 'th_th' -> 'th_TH.TACTIS' to 'th_TH.ISO8859-11'
689# updated 'zh_cn' -> 'zh_CN.eucCN' to 'zh_CN.gb2312'
690# updated 'zh_cn.big5' -> 'zh_TW.eucTW' to 'zh_TW.big5'
691# updated 'zh_tw' -> 'zh_TW.eucTW' to 'zh_TW.big5'
692#
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000693# MAL 2008-05-30:
694# Updated alias mapping to most recent locale.alias file
695# from X.org distribution using makelocalealias.py.
696#
697# These are the differences compared to the old mapping (Python 2.5
698# and older):
699#
700# updated 'cs_cs.iso88592' -> 'cs_CZ.ISO8859-2' to 'cs_CS.ISO8859-2'
701# updated 'serbocroatian' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
702# updated 'sh' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
703# updated 'sh_hr.iso88592' -> 'sh_HR.ISO8859-2' to 'hr_HR.ISO8859-2'
704# updated 'sh_sp' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
705# updated 'sh_yu' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
706# updated 'sp' -> 'sp_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
707# updated 'sp_yu' -> 'sp_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
708# updated 'sr' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
709# updated 'sr@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
710# updated 'sr_sp' -> 'sr_SP.ISO8859-2' to 'sr_CS.ISO8859-2'
711# updated 'sr_yu' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
712# updated 'sr_yu.cp1251@cyrillic' -> 'sr_YU.CP1251' to 'sr_CS.CP1251'
713# updated 'sr_yu.iso88592' -> 'sr_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
714# updated 'sr_yu.iso88595' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
715# updated 'sr_yu.iso88595@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
716# updated 'sr_yu.microsoftcp1251@cyrillic' -> 'sr_YU.CP1251' to 'sr_CS.CP1251'
717# updated 'sr_yu.utf8@cyrillic' -> 'sr_YU.UTF-8' to 'sr_CS.UTF-8'
718# updated 'sr_yu@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +0000719#
720# AP 2010-04-12:
721# Updated alias mapping to most recent locale.alias file
722# from X.org distribution using makelocalealias.py.
723#
724# These are the differences compared to the old mapping (Python 2.6.5
725# and older):
726#
727# updated 'ru' -> 'ru_RU.ISO8859-5' to 'ru_RU.UTF-8'
728# updated 'ru_ru' -> 'ru_RU.ISO8859-5' to 'ru_RU.UTF-8'
729# updated 'serbocroatian' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
730# updated 'sh' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
731# updated 'sh_yu' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
732# updated 'sr' -> 'sr_CS.ISO8859-5' to 'sr_RS.UTF-8'
733# updated 'sr@cyrillic' -> 'sr_CS.ISO8859-5' to 'sr_RS.UTF-8'
734# updated 'sr@latn' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
735# updated 'sr_cs.utf8@latn' -> 'sr_CS.UTF-8' to 'sr_RS.UTF-8@latin'
736# updated 'sr_cs@latn' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
737# updated 'sr_yu' -> 'sr_CS.ISO8859-5' to 'sr_RS.UTF-8@latin'
738# updated 'sr_yu.utf8@cyrillic' -> 'sr_CS.UTF-8' to 'sr_RS.UTF-8'
739# updated 'sr_yu@cyrillic' -> 'sr_CS.ISO8859-5' to 'sr_RS.UTF-8'
740#
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000741
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000742locale_alias = {
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000743 'a3': 'a3_AZ.KOI8-C',
744 'a3_az': 'a3_AZ.KOI8-C',
745 'a3_az.koi8c': 'a3_AZ.KOI8-C',
746 'af': 'af_ZA.ISO8859-1',
747 'af_za': 'af_ZA.ISO8859-1',
748 'af_za.iso88591': 'af_ZA.ISO8859-1',
749 'am': 'am_ET.UTF-8',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000750 'am_et': 'am_ET.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000751 'american': 'en_US.ISO8859-1',
752 'american.iso88591': 'en_US.ISO8859-1',
753 'ar': 'ar_AA.ISO8859-6',
754 'ar_aa': 'ar_AA.ISO8859-6',
755 'ar_aa.iso88596': 'ar_AA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000756 'ar_ae': 'ar_AE.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000757 'ar_ae.iso88596': 'ar_AE.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000758 'ar_bh': 'ar_BH.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000759 'ar_bh.iso88596': 'ar_BH.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000760 'ar_dz': 'ar_DZ.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000761 'ar_dz.iso88596': 'ar_DZ.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000762 'ar_eg': 'ar_EG.ISO8859-6',
763 'ar_eg.iso88596': 'ar_EG.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000764 'ar_iq': 'ar_IQ.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000765 'ar_iq.iso88596': 'ar_IQ.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000766 'ar_jo': 'ar_JO.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000767 'ar_jo.iso88596': 'ar_JO.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000768 'ar_kw': 'ar_KW.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000769 'ar_kw.iso88596': 'ar_KW.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000770 'ar_lb': 'ar_LB.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000771 'ar_lb.iso88596': 'ar_LB.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000772 'ar_ly': 'ar_LY.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000773 'ar_ly.iso88596': 'ar_LY.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000774 'ar_ma': 'ar_MA.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000775 'ar_ma.iso88596': 'ar_MA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000776 'ar_om': 'ar_OM.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000777 'ar_om.iso88596': 'ar_OM.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000778 'ar_qa': 'ar_QA.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000779 'ar_qa.iso88596': 'ar_QA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000780 'ar_sa': 'ar_SA.ISO8859-6',
781 'ar_sa.iso88596': 'ar_SA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000782 'ar_sd': 'ar_SD.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000783 'ar_sd.iso88596': 'ar_SD.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000784 'ar_sy': 'ar_SY.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000785 'ar_sy.iso88596': 'ar_SY.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000786 'ar_tn': 'ar_TN.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000787 'ar_tn.iso88596': 'ar_TN.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000788 'ar_ye': 'ar_YE.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000789 'ar_ye.iso88596': 'ar_YE.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000790 'arabic': 'ar_AA.ISO8859-6',
791 'arabic.iso88596': 'ar_AA.ISO8859-6',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +0000792 'as': 'as_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000793 'az': 'az_AZ.ISO8859-9E',
794 'az_az': 'az_AZ.ISO8859-9E',
795 'az_az.iso88599e': 'az_AZ.ISO8859-9E',
796 'be': 'be_BY.CP1251',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +0000797 'be@latin': 'be_BY.UTF-8@latin',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000798 'be_by': 'be_BY.CP1251',
799 'be_by.cp1251': 'be_BY.CP1251',
800 'be_by.microsoftcp1251': 'be_BY.CP1251',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +0000801 'be_by.utf8@latin': 'be_BY.UTF-8@latin',
802 'be_by@latin': 'be_BY.UTF-8@latin',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000803 'bg': 'bg_BG.CP1251',
804 'bg_bg': 'bg_BG.CP1251',
805 'bg_bg.cp1251': 'bg_BG.CP1251',
806 'bg_bg.iso88595': 'bg_BG.ISO8859-5',
807 'bg_bg.koi8r': 'bg_BG.KOI8-R',
808 'bg_bg.microsoftcp1251': 'bg_BG.CP1251',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000809 'bn_in': 'bn_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000810 'bokmal': 'nb_NO.ISO8859-1',
811 'bokm\xe5l': 'nb_NO.ISO8859-1',
812 'br': 'br_FR.ISO8859-1',
813 'br_fr': 'br_FR.ISO8859-1',
814 'br_fr.iso88591': 'br_FR.ISO8859-1',
815 'br_fr.iso885914': 'br_FR.ISO8859-14',
816 'br_fr.iso885915': 'br_FR.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000817 'br_fr.iso885915@euro': 'br_FR.ISO8859-15',
818 'br_fr.utf8@euro': 'br_FR.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000819 'br_fr@euro': 'br_FR.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000820 'bs': 'bs_BA.ISO8859-2',
821 'bs_ba': 'bs_BA.ISO8859-2',
822 'bs_ba.iso88592': 'bs_BA.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000823 'bulgarian': 'bg_BG.CP1251',
824 'c': 'C',
825 'c-french': 'fr_CA.ISO8859-1',
826 'c-french.iso88591': 'fr_CA.ISO8859-1',
827 'c.en': 'C',
828 'c.iso88591': 'en_US.ISO8859-1',
829 'c_c': 'C',
830 'c_c.c': 'C',
831 'ca': 'ca_ES.ISO8859-1',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +0000832 'ca_ad': 'ca_AD.ISO8859-1',
833 'ca_ad.iso88591': 'ca_AD.ISO8859-1',
834 'ca_ad.iso885915': 'ca_AD.ISO8859-15',
835 'ca_ad.iso885915@euro': 'ca_AD.ISO8859-15',
836 'ca_ad.utf8@euro': 'ca_AD.UTF-8',
837 'ca_ad@euro': 'ca_AD.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000838 'ca_es': 'ca_ES.ISO8859-1',
839 'ca_es.iso88591': 'ca_ES.ISO8859-1',
840 'ca_es.iso885915': 'ca_ES.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000841 'ca_es.iso885915@euro': 'ca_ES.ISO8859-15',
842 'ca_es.utf8@euro': 'ca_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000843 'ca_es@euro': 'ca_ES.ISO8859-15',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +0000844 'ca_fr': 'ca_FR.ISO8859-1',
845 'ca_fr.iso88591': 'ca_FR.ISO8859-1',
846 'ca_fr.iso885915': 'ca_FR.ISO8859-15',
847 'ca_fr.iso885915@euro': 'ca_FR.ISO8859-15',
848 'ca_fr.utf8@euro': 'ca_FR.UTF-8',
849 'ca_fr@euro': 'ca_FR.ISO8859-15',
850 'ca_it': 'ca_IT.ISO8859-1',
851 'ca_it.iso88591': 'ca_IT.ISO8859-1',
852 'ca_it.iso885915': 'ca_IT.ISO8859-15',
853 'ca_it.iso885915@euro': 'ca_IT.ISO8859-15',
854 'ca_it.utf8@euro': 'ca_IT.UTF-8',
855 'ca_it@euro': 'ca_IT.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000856 'catalan': 'ca_ES.ISO8859-1',
857 'cextend': 'en_US.ISO8859-1',
858 'cextend.en': 'en_US.ISO8859-1',
859 'chinese-s': 'zh_CN.eucCN',
860 'chinese-t': 'zh_TW.eucTW',
861 'croatian': 'hr_HR.ISO8859-2',
862 'cs': 'cs_CZ.ISO8859-2',
863 'cs_cs': 'cs_CZ.ISO8859-2',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000864 'cs_cs.iso88592': 'cs_CS.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000865 'cs_cz': 'cs_CZ.ISO8859-2',
866 'cs_cz.iso88592': 'cs_CZ.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000867 'cy': 'cy_GB.ISO8859-1',
868 'cy_gb': 'cy_GB.ISO8859-1',
869 'cy_gb.iso88591': 'cy_GB.ISO8859-1',
870 'cy_gb.iso885914': 'cy_GB.ISO8859-14',
871 'cy_gb.iso885915': 'cy_GB.ISO8859-15',
872 'cy_gb@euro': 'cy_GB.ISO8859-15',
873 'cz': 'cs_CZ.ISO8859-2',
874 'cz_cz': 'cs_CZ.ISO8859-2',
875 'czech': 'cs_CZ.ISO8859-2',
876 'da': 'da_DK.ISO8859-1',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +0000877 'da.iso885915': 'da_DK.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000878 'da_dk': 'da_DK.ISO8859-1',
879 'da_dk.88591': 'da_DK.ISO8859-1',
880 'da_dk.885915': 'da_DK.ISO8859-15',
881 'da_dk.iso88591': 'da_DK.ISO8859-1',
882 'da_dk.iso885915': 'da_DK.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000883 'da_dk@euro': 'da_DK.ISO8859-15',
884 'danish': 'da_DK.ISO8859-1',
885 'danish.iso88591': 'da_DK.ISO8859-1',
886 'dansk': 'da_DK.ISO8859-1',
887 'de': 'de_DE.ISO8859-1',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +0000888 'de.iso885915': 'de_DE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000889 'de_at': 'de_AT.ISO8859-1',
890 'de_at.iso88591': 'de_AT.ISO8859-1',
891 'de_at.iso885915': 'de_AT.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000892 'de_at.iso885915@euro': 'de_AT.ISO8859-15',
893 'de_at.utf8@euro': 'de_AT.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000894 'de_at@euro': 'de_AT.ISO8859-15',
895 'de_be': 'de_BE.ISO8859-1',
896 'de_be.iso88591': 'de_BE.ISO8859-1',
897 'de_be.iso885915': 'de_BE.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000898 'de_be.iso885915@euro': 'de_BE.ISO8859-15',
899 'de_be.utf8@euro': 'de_BE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000900 'de_be@euro': 'de_BE.ISO8859-15',
901 'de_ch': 'de_CH.ISO8859-1',
902 'de_ch.iso88591': 'de_CH.ISO8859-1',
903 'de_ch.iso885915': 'de_CH.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000904 'de_ch@euro': 'de_CH.ISO8859-15',
905 'de_de': 'de_DE.ISO8859-1',
906 'de_de.88591': 'de_DE.ISO8859-1',
907 'de_de.885915': 'de_DE.ISO8859-15',
908 'de_de.885915@euro': 'de_DE.ISO8859-15',
909 'de_de.iso88591': 'de_DE.ISO8859-1',
910 'de_de.iso885915': 'de_DE.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000911 'de_de.iso885915@euro': 'de_DE.ISO8859-15',
912 'de_de.utf8@euro': 'de_DE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000913 'de_de@euro': 'de_DE.ISO8859-15',
914 'de_lu': 'de_LU.ISO8859-1',
915 'de_lu.iso88591': 'de_LU.ISO8859-1',
916 'de_lu.iso885915': 'de_LU.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000917 'de_lu.iso885915@euro': 'de_LU.ISO8859-15',
918 'de_lu.utf8@euro': 'de_LU.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000919 'de_lu@euro': 'de_LU.ISO8859-15',
920 'deutsch': 'de_DE.ISO8859-1',
921 'dutch': 'nl_NL.ISO8859-1',
922 'dutch.iso88591': 'nl_BE.ISO8859-1',
923 'ee': 'ee_EE.ISO8859-4',
924 'ee_ee': 'ee_EE.ISO8859-4',
925 'ee_ee.iso88594': 'ee_EE.ISO8859-4',
926 'eesti': 'et_EE.ISO8859-1',
927 'el': 'el_GR.ISO8859-7',
928 'el_gr': 'el_GR.ISO8859-7',
929 'el_gr.iso88597': 'el_GR.ISO8859-7',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000930 'el_gr@euro': 'el_GR.ISO8859-15',
931 'en': 'en_US.ISO8859-1',
932 'en.iso88591': 'en_US.ISO8859-1',
933 'en_au': 'en_AU.ISO8859-1',
934 'en_au.iso88591': 'en_AU.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000935 'en_be': 'en_BE.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000936 'en_be@euro': 'en_BE.ISO8859-15',
937 'en_bw': 'en_BW.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000938 'en_bw.iso88591': 'en_BW.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000939 'en_ca': 'en_CA.ISO8859-1',
940 'en_ca.iso88591': 'en_CA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000941 'en_gb': 'en_GB.ISO8859-1',
942 'en_gb.88591': 'en_GB.ISO8859-1',
943 'en_gb.iso88591': 'en_GB.ISO8859-1',
944 'en_gb.iso885915': 'en_GB.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000945 'en_gb@euro': 'en_GB.ISO8859-15',
946 'en_hk': 'en_HK.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000947 'en_hk.iso88591': 'en_HK.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000948 'en_ie': 'en_IE.ISO8859-1',
949 'en_ie.iso88591': 'en_IE.ISO8859-1',
950 'en_ie.iso885915': 'en_IE.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000951 'en_ie.iso885915@euro': 'en_IE.ISO8859-15',
952 'en_ie.utf8@euro': 'en_IE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000953 'en_ie@euro': 'en_IE.ISO8859-15',
954 'en_in': 'en_IN.ISO8859-1',
955 'en_nz': 'en_NZ.ISO8859-1',
956 'en_nz.iso88591': 'en_NZ.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000957 'en_ph': 'en_PH.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000958 'en_ph.iso88591': 'en_PH.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000959 'en_sg': 'en_SG.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000960 'en_sg.iso88591': 'en_SG.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000961 'en_uk': 'en_GB.ISO8859-1',
962 'en_us': 'en_US.ISO8859-1',
963 'en_us.88591': 'en_US.ISO8859-1',
964 'en_us.885915': 'en_US.ISO8859-15',
965 'en_us.iso88591': 'en_US.ISO8859-1',
966 'en_us.iso885915': 'en_US.ISO8859-15',
967 'en_us.iso885915@euro': 'en_US.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000968 'en_us@euro': 'en_US.ISO8859-15',
969 'en_us@euro@euro': 'en_US.ISO8859-15',
970 'en_za': 'en_ZA.ISO8859-1',
971 'en_za.88591': 'en_ZA.ISO8859-1',
972 'en_za.iso88591': 'en_ZA.ISO8859-1',
973 'en_za.iso885915': 'en_ZA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000974 'en_za@euro': 'en_ZA.ISO8859-15',
975 'en_zw': 'en_ZW.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000976 'en_zw.iso88591': 'en_ZW.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000977 'eng_gb': 'en_GB.ISO8859-1',
978 'eng_gb.8859': 'en_GB.ISO8859-1',
979 'english': 'en_EN.ISO8859-1',
980 'english.iso88591': 'en_EN.ISO8859-1',
981 'english_uk': 'en_GB.ISO8859-1',
982 'english_uk.8859': 'en_GB.ISO8859-1',
983 'english_united-states': 'en_US.ISO8859-1',
984 'english_united-states.437': 'C',
985 'english_us': 'en_US.ISO8859-1',
986 'english_us.8859': 'en_US.ISO8859-1',
987 'english_us.ascii': 'en_US.ISO8859-1',
988 'eo': 'eo_XX.ISO8859-3',
989 'eo_eo': 'eo_EO.ISO8859-3',
990 'eo_eo.iso88593': 'eo_EO.ISO8859-3',
991 'eo_xx': 'eo_XX.ISO8859-3',
992 'eo_xx.iso88593': 'eo_XX.ISO8859-3',
993 'es': 'es_ES.ISO8859-1',
994 'es_ar': 'es_AR.ISO8859-1',
995 'es_ar.iso88591': 'es_AR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000996 'es_bo': 'es_BO.ISO8859-1',
997 'es_bo.iso88591': 'es_BO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000998 'es_cl': 'es_CL.ISO8859-1',
999 'es_cl.iso88591': 'es_CL.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001000 'es_co': 'es_CO.ISO8859-1',
1001 'es_co.iso88591': 'es_CO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001002 'es_cr': 'es_CR.ISO8859-1',
1003 'es_cr.iso88591': 'es_CR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001004 'es_do': 'es_DO.ISO8859-1',
1005 'es_do.iso88591': 'es_DO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001006 'es_ec': 'es_EC.ISO8859-1',
1007 'es_ec.iso88591': 'es_EC.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001008 'es_es': 'es_ES.ISO8859-1',
1009 'es_es.88591': 'es_ES.ISO8859-1',
1010 'es_es.iso88591': 'es_ES.ISO8859-1',
1011 'es_es.iso885915': 'es_ES.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001012 'es_es.iso885915@euro': 'es_ES.ISO8859-15',
1013 'es_es.utf8@euro': 'es_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001014 'es_es@euro': 'es_ES.ISO8859-15',
1015 'es_gt': 'es_GT.ISO8859-1',
1016 'es_gt.iso88591': 'es_GT.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001017 'es_hn': 'es_HN.ISO8859-1',
1018 'es_hn.iso88591': 'es_HN.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001019 'es_mx': 'es_MX.ISO8859-1',
1020 'es_mx.iso88591': 'es_MX.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001021 'es_ni': 'es_NI.ISO8859-1',
1022 'es_ni.iso88591': 'es_NI.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001023 'es_pa': 'es_PA.ISO8859-1',
1024 'es_pa.iso88591': 'es_PA.ISO8859-1',
1025 'es_pa.iso885915': 'es_PA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001026 'es_pa@euro': 'es_PA.ISO8859-15',
1027 'es_pe': 'es_PE.ISO8859-1',
1028 'es_pe.iso88591': 'es_PE.ISO8859-1',
1029 'es_pe.iso885915': 'es_PE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001030 'es_pe@euro': 'es_PE.ISO8859-15',
1031 'es_pr': 'es_PR.ISO8859-1',
1032 'es_pr.iso88591': 'es_PR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001033 'es_py': 'es_PY.ISO8859-1',
1034 'es_py.iso88591': 'es_PY.ISO8859-1',
1035 'es_py.iso885915': 'es_PY.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001036 'es_py@euro': 'es_PY.ISO8859-15',
1037 'es_sv': 'es_SV.ISO8859-1',
1038 'es_sv.iso88591': 'es_SV.ISO8859-1',
1039 'es_sv.iso885915': 'es_SV.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001040 'es_sv@euro': 'es_SV.ISO8859-15',
1041 'es_us': 'es_US.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001042 'es_us.iso88591': 'es_US.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001043 'es_uy': 'es_UY.ISO8859-1',
1044 'es_uy.iso88591': 'es_UY.ISO8859-1',
1045 'es_uy.iso885915': 'es_UY.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001046 'es_uy@euro': 'es_UY.ISO8859-15',
1047 'es_ve': 'es_VE.ISO8859-1',
1048 'es_ve.iso88591': 'es_VE.ISO8859-1',
1049 'es_ve.iso885915': 'es_VE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001050 'es_ve@euro': 'es_VE.ISO8859-15',
1051 'estonian': 'et_EE.ISO8859-1',
1052 'et': 'et_EE.ISO8859-15',
1053 'et_ee': 'et_EE.ISO8859-15',
1054 'et_ee.iso88591': 'et_EE.ISO8859-1',
1055 'et_ee.iso885913': 'et_EE.ISO8859-13',
1056 'et_ee.iso885915': 'et_EE.ISO8859-15',
1057 'et_ee.iso88594': 'et_EE.ISO8859-4',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001058 'et_ee@euro': 'et_EE.ISO8859-15',
1059 'eu': 'eu_ES.ISO8859-1',
1060 'eu_es': 'eu_ES.ISO8859-1',
1061 'eu_es.iso88591': 'eu_ES.ISO8859-1',
1062 'eu_es.iso885915': 'eu_ES.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001063 'eu_es.iso885915@euro': 'eu_ES.ISO8859-15',
1064 'eu_es.utf8@euro': 'eu_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001065 'eu_es@euro': 'eu_ES.ISO8859-15',
1066 'fa': 'fa_IR.UTF-8',
1067 'fa_ir': 'fa_IR.UTF-8',
1068 'fa_ir.isiri3342': 'fa_IR.ISIRI-3342',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001069 'fi': 'fi_FI.ISO8859-15',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001070 'fi.iso885915': 'fi_FI.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001071 'fi_fi': 'fi_FI.ISO8859-15',
1072 'fi_fi.88591': 'fi_FI.ISO8859-1',
1073 'fi_fi.iso88591': 'fi_FI.ISO8859-1',
1074 'fi_fi.iso885915': 'fi_FI.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001075 'fi_fi.iso885915@euro': 'fi_FI.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001076 'fi_fi.utf8@euro': 'fi_FI.UTF-8',
1077 'fi_fi@euro': 'fi_FI.ISO8859-15',
1078 'finnish': 'fi_FI.ISO8859-1',
1079 'finnish.iso88591': 'fi_FI.ISO8859-1',
1080 'fo': 'fo_FO.ISO8859-1',
1081 'fo_fo': 'fo_FO.ISO8859-1',
1082 'fo_fo.iso88591': 'fo_FO.ISO8859-1',
1083 'fo_fo.iso885915': 'fo_FO.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001084 'fo_fo@euro': 'fo_FO.ISO8859-15',
1085 'fr': 'fr_FR.ISO8859-1',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001086 'fr.iso885915': 'fr_FR.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001087 'fr_be': 'fr_BE.ISO8859-1',
1088 'fr_be.88591': 'fr_BE.ISO8859-1',
1089 'fr_be.iso88591': 'fr_BE.ISO8859-1',
1090 'fr_be.iso885915': 'fr_BE.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001091 'fr_be.iso885915@euro': 'fr_BE.ISO8859-15',
1092 'fr_be.utf8@euro': 'fr_BE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001093 'fr_be@euro': 'fr_BE.ISO8859-15',
1094 'fr_ca': 'fr_CA.ISO8859-1',
1095 'fr_ca.88591': 'fr_CA.ISO8859-1',
1096 'fr_ca.iso88591': 'fr_CA.ISO8859-1',
1097 'fr_ca.iso885915': 'fr_CA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001098 'fr_ca@euro': 'fr_CA.ISO8859-15',
1099 'fr_ch': 'fr_CH.ISO8859-1',
1100 'fr_ch.88591': 'fr_CH.ISO8859-1',
1101 'fr_ch.iso88591': 'fr_CH.ISO8859-1',
1102 'fr_ch.iso885915': 'fr_CH.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001103 'fr_ch@euro': 'fr_CH.ISO8859-15',
1104 'fr_fr': 'fr_FR.ISO8859-1',
1105 'fr_fr.88591': 'fr_FR.ISO8859-1',
1106 'fr_fr.iso88591': 'fr_FR.ISO8859-1',
1107 'fr_fr.iso885915': 'fr_FR.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001108 'fr_fr.iso885915@euro': 'fr_FR.ISO8859-15',
1109 'fr_fr.utf8@euro': 'fr_FR.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001110 'fr_fr@euro': 'fr_FR.ISO8859-15',
1111 'fr_lu': 'fr_LU.ISO8859-1',
1112 'fr_lu.88591': 'fr_LU.ISO8859-1',
1113 'fr_lu.iso88591': 'fr_LU.ISO8859-1',
1114 'fr_lu.iso885915': 'fr_LU.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001115 'fr_lu.iso885915@euro': 'fr_LU.ISO8859-15',
1116 'fr_lu.utf8@euro': 'fr_LU.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001117 'fr_lu@euro': 'fr_LU.ISO8859-15',
1118 'fran\xe7ais': 'fr_FR.ISO8859-1',
1119 'fre_fr': 'fr_FR.ISO8859-1',
1120 'fre_fr.8859': 'fr_FR.ISO8859-1',
1121 'french': 'fr_FR.ISO8859-1',
1122 'french.iso88591': 'fr_CH.ISO8859-1',
1123 'french_france': 'fr_FR.ISO8859-1',
1124 'french_france.8859': 'fr_FR.ISO8859-1',
1125 'ga': 'ga_IE.ISO8859-1',
1126 'ga_ie': 'ga_IE.ISO8859-1',
1127 'ga_ie.iso88591': 'ga_IE.ISO8859-1',
1128 'ga_ie.iso885914': 'ga_IE.ISO8859-14',
1129 'ga_ie.iso885915': 'ga_IE.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001130 'ga_ie.iso885915@euro': 'ga_IE.ISO8859-15',
1131 'ga_ie.utf8@euro': 'ga_IE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001132 'ga_ie@euro': 'ga_IE.ISO8859-15',
1133 'galego': 'gl_ES.ISO8859-1',
1134 'galician': 'gl_ES.ISO8859-1',
1135 'gd': 'gd_GB.ISO8859-1',
1136 'gd_gb': 'gd_GB.ISO8859-1',
1137 'gd_gb.iso88591': 'gd_GB.ISO8859-1',
1138 'gd_gb.iso885914': 'gd_GB.ISO8859-14',
1139 'gd_gb.iso885915': 'gd_GB.ISO8859-15',
1140 'gd_gb@euro': 'gd_GB.ISO8859-15',
1141 'ger_de': 'de_DE.ISO8859-1',
1142 'ger_de.8859': 'de_DE.ISO8859-1',
1143 'german': 'de_DE.ISO8859-1',
1144 'german.iso88591': 'de_CH.ISO8859-1',
1145 'german_germany': 'de_DE.ISO8859-1',
1146 'german_germany.8859': 'de_DE.ISO8859-1',
1147 'gl': 'gl_ES.ISO8859-1',
1148 'gl_es': 'gl_ES.ISO8859-1',
1149 'gl_es.iso88591': 'gl_ES.ISO8859-1',
1150 'gl_es.iso885915': 'gl_ES.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001151 'gl_es.iso885915@euro': 'gl_ES.ISO8859-15',
1152 'gl_es.utf8@euro': 'gl_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001153 'gl_es@euro': 'gl_ES.ISO8859-15',
1154 'greek': 'el_GR.ISO8859-7',
1155 'greek.iso88597': 'el_GR.ISO8859-7',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001156 'gu_in': 'gu_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001157 'gv': 'gv_GB.ISO8859-1',
1158 'gv_gb': 'gv_GB.ISO8859-1',
1159 'gv_gb.iso88591': 'gv_GB.ISO8859-1',
1160 'gv_gb.iso885914': 'gv_GB.ISO8859-14',
1161 'gv_gb.iso885915': 'gv_GB.ISO8859-15',
1162 'gv_gb@euro': 'gv_GB.ISO8859-15',
1163 'he': 'he_IL.ISO8859-8',
1164 'he_il': 'he_IL.ISO8859-8',
1165 'he_il.cp1255': 'he_IL.CP1255',
1166 'he_il.iso88598': 'he_IL.ISO8859-8',
1167 'he_il.microsoftcp1255': 'he_IL.CP1255',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001168 'hebrew': 'iw_IL.ISO8859-8',
1169 'hebrew.iso88598': 'iw_IL.ISO8859-8',
1170 'hi': 'hi_IN.ISCII-DEV',
1171 'hi_in': 'hi_IN.ISCII-DEV',
1172 'hi_in.isciidev': 'hi_IN.ISCII-DEV',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001173 'hne': 'hne_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001174 'hr': 'hr_HR.ISO8859-2',
1175 'hr_hr': 'hr_HR.ISO8859-2',
1176 'hr_hr.iso88592': 'hr_HR.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001177 'hrvatski': 'hr_HR.ISO8859-2',
1178 'hu': 'hu_HU.ISO8859-2',
1179 'hu_hu': 'hu_HU.ISO8859-2',
1180 'hu_hu.iso88592': 'hu_HU.ISO8859-2',
1181 'hungarian': 'hu_HU.ISO8859-2',
1182 'icelandic': 'is_IS.ISO8859-1',
1183 'icelandic.iso88591': 'is_IS.ISO8859-1',
1184 'id': 'id_ID.ISO8859-1',
1185 'id_id': 'id_ID.ISO8859-1',
1186 'in': 'id_ID.ISO8859-1',
1187 'in_id': 'id_ID.ISO8859-1',
1188 'is': 'is_IS.ISO8859-1',
1189 'is_is': 'is_IS.ISO8859-1',
1190 'is_is.iso88591': 'is_IS.ISO8859-1',
1191 'is_is.iso885915': 'is_IS.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001192 'is_is@euro': 'is_IS.ISO8859-15',
1193 'iso-8859-1': 'en_US.ISO8859-1',
1194 'iso-8859-15': 'en_US.ISO8859-15',
1195 'iso8859-1': 'en_US.ISO8859-1',
1196 'iso8859-15': 'en_US.ISO8859-15',
1197 'iso_8859_1': 'en_US.ISO8859-1',
1198 'iso_8859_15': 'en_US.ISO8859-15',
1199 'it': 'it_IT.ISO8859-1',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001200 'it.iso885915': 'it_IT.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001201 'it_ch': 'it_CH.ISO8859-1',
1202 'it_ch.iso88591': 'it_CH.ISO8859-1',
1203 'it_ch.iso885915': 'it_CH.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001204 'it_ch@euro': 'it_CH.ISO8859-15',
1205 'it_it': 'it_IT.ISO8859-1',
1206 'it_it.88591': 'it_IT.ISO8859-1',
1207 'it_it.iso88591': 'it_IT.ISO8859-1',
1208 'it_it.iso885915': 'it_IT.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001209 'it_it.iso885915@euro': 'it_IT.ISO8859-15',
1210 'it_it.utf8@euro': 'it_IT.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001211 'it_it@euro': 'it_IT.ISO8859-15',
1212 'italian': 'it_IT.ISO8859-1',
1213 'italian.iso88591': 'it_IT.ISO8859-1',
1214 'iu': 'iu_CA.NUNACOM-8',
1215 'iu_ca': 'iu_CA.NUNACOM-8',
1216 'iu_ca.nunacom8': 'iu_CA.NUNACOM-8',
1217 'iw': 'he_IL.ISO8859-8',
1218 'iw_il': 'he_IL.ISO8859-8',
1219 'iw_il.iso88598': 'he_IL.ISO8859-8',
1220 'ja': 'ja_JP.eucJP',
1221 'ja.jis': 'ja_JP.JIS7',
1222 'ja.sjis': 'ja_JP.SJIS',
1223 'ja_jp': 'ja_JP.eucJP',
1224 'ja_jp.ajec': 'ja_JP.eucJP',
1225 'ja_jp.euc': 'ja_JP.eucJP',
1226 'ja_jp.eucjp': 'ja_JP.eucJP',
1227 'ja_jp.iso-2022-jp': 'ja_JP.JIS7',
1228 'ja_jp.iso2022jp': 'ja_JP.JIS7',
1229 'ja_jp.jis': 'ja_JP.JIS7',
1230 'ja_jp.jis7': 'ja_JP.JIS7',
1231 'ja_jp.mscode': 'ja_JP.SJIS',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001232 'ja_jp.pck': 'ja_JP.SJIS',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001233 'ja_jp.sjis': 'ja_JP.SJIS',
1234 'ja_jp.ujis': 'ja_JP.eucJP',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001235 'japan': 'ja_JP.eucJP',
1236 'japanese': 'ja_JP.eucJP',
1237 'japanese-euc': 'ja_JP.eucJP',
1238 'japanese.euc': 'ja_JP.eucJP',
1239 'japanese.sjis': 'ja_JP.SJIS',
1240 'jp_jp': 'ja_JP.eucJP',
1241 'ka': 'ka_GE.GEORGIAN-ACADEMY',
1242 'ka_ge': 'ka_GE.GEORGIAN-ACADEMY',
1243 'ka_ge.georgianacademy': 'ka_GE.GEORGIAN-ACADEMY',
1244 'ka_ge.georgianps': 'ka_GE.GEORGIAN-PS',
1245 'ka_ge.georgianrs': 'ka_GE.GEORGIAN-ACADEMY',
1246 'kl': 'kl_GL.ISO8859-1',
1247 'kl_gl': 'kl_GL.ISO8859-1',
1248 'kl_gl.iso88591': 'kl_GL.ISO8859-1',
1249 'kl_gl.iso885915': 'kl_GL.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001250 'kl_gl@euro': 'kl_GL.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001251 'km_kh': 'km_KH.UTF-8',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001252 'kn': 'kn_IN.UTF-8',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001253 'kn_in': 'kn_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001254 'ko': 'ko_KR.eucKR',
1255 'ko_kr': 'ko_KR.eucKR',
1256 'ko_kr.euc': 'ko_KR.eucKR',
1257 'ko_kr.euckr': 'ko_KR.eucKR',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001258 'korean': 'ko_KR.eucKR',
1259 'korean.euc': 'ko_KR.eucKR',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001260 'ks': 'ks_IN.UTF-8',
1261 'ks_in@devanagari': 'ks_IN@devanagari.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001262 'kw': 'kw_GB.ISO8859-1',
1263 'kw_gb': 'kw_GB.ISO8859-1',
1264 'kw_gb.iso88591': 'kw_GB.ISO8859-1',
1265 'kw_gb.iso885914': 'kw_GB.ISO8859-14',
1266 'kw_gb.iso885915': 'kw_GB.ISO8859-15',
1267 'kw_gb@euro': 'kw_GB.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001268 'ky': 'ky_KG.UTF-8',
1269 'ky_kg': 'ky_KG.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001270 'lithuanian': 'lt_LT.ISO8859-13',
1271 'lo': 'lo_LA.MULELAO-1',
1272 'lo_la': 'lo_LA.MULELAO-1',
1273 'lo_la.cp1133': 'lo_LA.IBM-CP1133',
1274 'lo_la.ibmcp1133': 'lo_LA.IBM-CP1133',
1275 'lo_la.mulelao1': 'lo_LA.MULELAO-1',
1276 'lt': 'lt_LT.ISO8859-13',
1277 'lt_lt': 'lt_LT.ISO8859-13',
1278 'lt_lt.iso885913': 'lt_LT.ISO8859-13',
1279 'lt_lt.iso88594': 'lt_LT.ISO8859-4',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001280 'lv': 'lv_LV.ISO8859-13',
1281 'lv_lv': 'lv_LV.ISO8859-13',
1282 'lv_lv.iso885913': 'lv_LV.ISO8859-13',
1283 'lv_lv.iso88594': 'lv_LV.ISO8859-4',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001284 'mai': 'mai_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001285 'mi': 'mi_NZ.ISO8859-1',
1286 'mi_nz': 'mi_NZ.ISO8859-1',
1287 'mi_nz.iso88591': 'mi_NZ.ISO8859-1',
1288 'mk': 'mk_MK.ISO8859-5',
1289 'mk_mk': 'mk_MK.ISO8859-5',
1290 'mk_mk.cp1251': 'mk_MK.CP1251',
1291 'mk_mk.iso88595': 'mk_MK.ISO8859-5',
1292 'mk_mk.microsoftcp1251': 'mk_MK.CP1251',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001293 'ml': 'ml_IN.UTF-8',
1294 'mr': 'mr_IN.UTF-8',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001295 'mr_in': 'mr_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001296 'ms': 'ms_MY.ISO8859-1',
1297 'ms_my': 'ms_MY.ISO8859-1',
1298 'ms_my.iso88591': 'ms_MY.ISO8859-1',
1299 'mt': 'mt_MT.ISO8859-3',
1300 'mt_mt': 'mt_MT.ISO8859-3',
1301 'mt_mt.iso88593': 'mt_MT.ISO8859-3',
1302 'nb': 'nb_NO.ISO8859-1',
1303 'nb_no': 'nb_NO.ISO8859-1',
1304 'nb_no.88591': 'nb_NO.ISO8859-1',
1305 'nb_no.iso88591': 'nb_NO.ISO8859-1',
1306 'nb_no.iso885915': 'nb_NO.ISO8859-15',
1307 'nb_no@euro': 'nb_NO.ISO8859-15',
1308 'nl': 'nl_NL.ISO8859-1',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001309 'nl.iso885915': 'nl_NL.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001310 'nl_be': 'nl_BE.ISO8859-1',
1311 'nl_be.88591': 'nl_BE.ISO8859-1',
1312 'nl_be.iso88591': 'nl_BE.ISO8859-1',
1313 'nl_be.iso885915': 'nl_BE.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001314 'nl_be.iso885915@euro': 'nl_BE.ISO8859-15',
1315 'nl_be.utf8@euro': 'nl_BE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001316 'nl_be@euro': 'nl_BE.ISO8859-15',
1317 'nl_nl': 'nl_NL.ISO8859-1',
1318 'nl_nl.88591': 'nl_NL.ISO8859-1',
1319 'nl_nl.iso88591': 'nl_NL.ISO8859-1',
1320 'nl_nl.iso885915': 'nl_NL.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001321 'nl_nl.iso885915@euro': 'nl_NL.ISO8859-15',
1322 'nl_nl.utf8@euro': 'nl_NL.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001323 'nl_nl@euro': 'nl_NL.ISO8859-15',
1324 'nn': 'nn_NO.ISO8859-1',
1325 'nn_no': 'nn_NO.ISO8859-1',
1326 'nn_no.88591': 'nn_NO.ISO8859-1',
1327 'nn_no.iso88591': 'nn_NO.ISO8859-1',
1328 'nn_no.iso885915': 'nn_NO.ISO8859-15',
1329 'nn_no@euro': 'nn_NO.ISO8859-15',
1330 'no': 'no_NO.ISO8859-1',
1331 'no@nynorsk': 'ny_NO.ISO8859-1',
1332 'no_no': 'no_NO.ISO8859-1',
1333 'no_no.88591': 'no_NO.ISO8859-1',
1334 'no_no.iso88591': 'no_NO.ISO8859-1',
1335 'no_no.iso885915': 'no_NO.ISO8859-15',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001336 'no_no.iso88591@bokmal': 'no_NO.ISO8859-1',
1337 'no_no.iso88591@nynorsk': 'no_NO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001338 'no_no@euro': 'no_NO.ISO8859-15',
1339 'norwegian': 'no_NO.ISO8859-1',
1340 'norwegian.iso88591': 'no_NO.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001341 'nr': 'nr_ZA.ISO8859-1',
1342 'nr_za': 'nr_ZA.ISO8859-1',
1343 'nr_za.iso88591': 'nr_ZA.ISO8859-1',
1344 'nso': 'nso_ZA.ISO8859-15',
1345 'nso_za': 'nso_ZA.ISO8859-15',
1346 'nso_za.iso885915': 'nso_ZA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001347 'ny': 'ny_NO.ISO8859-1',
1348 'ny_no': 'ny_NO.ISO8859-1',
1349 'ny_no.88591': 'ny_NO.ISO8859-1',
1350 'ny_no.iso88591': 'ny_NO.ISO8859-1',
1351 'ny_no.iso885915': 'ny_NO.ISO8859-15',
1352 'ny_no@euro': 'ny_NO.ISO8859-15',
1353 'nynorsk': 'nn_NO.ISO8859-1',
1354 'oc': 'oc_FR.ISO8859-1',
1355 'oc_fr': 'oc_FR.ISO8859-1',
1356 'oc_fr.iso88591': 'oc_FR.ISO8859-1',
1357 'oc_fr.iso885915': 'oc_FR.ISO8859-15',
1358 'oc_fr@euro': 'oc_FR.ISO8859-15',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001359 'or': 'or_IN.UTF-8',
1360 'pa': 'pa_IN.UTF-8',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001361 'pa_in': 'pa_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001362 'pd': 'pd_US.ISO8859-1',
1363 'pd_de': 'pd_DE.ISO8859-1',
1364 'pd_de.iso88591': 'pd_DE.ISO8859-1',
1365 'pd_de.iso885915': 'pd_DE.ISO8859-15',
1366 'pd_de@euro': 'pd_DE.ISO8859-15',
1367 'pd_us': 'pd_US.ISO8859-1',
1368 'pd_us.iso88591': 'pd_US.ISO8859-1',
1369 'pd_us.iso885915': 'pd_US.ISO8859-15',
1370 'pd_us@euro': 'pd_US.ISO8859-15',
1371 'ph': 'ph_PH.ISO8859-1',
1372 'ph_ph': 'ph_PH.ISO8859-1',
1373 'ph_ph.iso88591': 'ph_PH.ISO8859-1',
1374 'pl': 'pl_PL.ISO8859-2',
1375 'pl_pl': 'pl_PL.ISO8859-2',
1376 'pl_pl.iso88592': 'pl_PL.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001377 'polish': 'pl_PL.ISO8859-2',
1378 'portuguese': 'pt_PT.ISO8859-1',
1379 'portuguese.iso88591': 'pt_PT.ISO8859-1',
1380 'portuguese_brazil': 'pt_BR.ISO8859-1',
1381 'portuguese_brazil.8859': 'pt_BR.ISO8859-1',
1382 'posix': 'C',
1383 'posix-utf2': 'C',
1384 'pp': 'pp_AN.ISO8859-1',
1385 'pp_an': 'pp_AN.ISO8859-1',
1386 'pp_an.iso88591': 'pp_AN.ISO8859-1',
1387 'pt': 'pt_PT.ISO8859-1',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001388 'pt.iso885915': 'pt_PT.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001389 'pt_br': 'pt_BR.ISO8859-1',
1390 'pt_br.88591': 'pt_BR.ISO8859-1',
1391 'pt_br.iso88591': 'pt_BR.ISO8859-1',
1392 'pt_br.iso885915': 'pt_BR.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001393 'pt_br@euro': 'pt_BR.ISO8859-15',
1394 'pt_pt': 'pt_PT.ISO8859-1',
1395 'pt_pt.88591': 'pt_PT.ISO8859-1',
1396 'pt_pt.iso88591': 'pt_PT.ISO8859-1',
1397 'pt_pt.iso885915': 'pt_PT.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001398 'pt_pt.iso885915@euro': 'pt_PT.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001399 'pt_pt.utf8@euro': 'pt_PT.UTF-8',
1400 'pt_pt@euro': 'pt_PT.ISO8859-15',
1401 'ro': 'ro_RO.ISO8859-2',
1402 'ro_ro': 'ro_RO.ISO8859-2',
1403 'ro_ro.iso88592': 'ro_RO.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001404 'romanian': 'ro_RO.ISO8859-2',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001405 'ru': 'ru_RU.UTF-8',
1406 'ru.koi8r': 'ru_RU.KOI8-R',
1407 'ru_ru': 'ru_RU.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001408 'ru_ru.cp1251': 'ru_RU.CP1251',
1409 'ru_ru.iso88595': 'ru_RU.ISO8859-5',
1410 'ru_ru.koi8r': 'ru_RU.KOI8-R',
1411 'ru_ru.microsoftcp1251': 'ru_RU.CP1251',
1412 'ru_ua': 'ru_UA.KOI8-U',
1413 'ru_ua.cp1251': 'ru_UA.CP1251',
1414 'ru_ua.koi8u': 'ru_UA.KOI8-U',
1415 'ru_ua.microsoftcp1251': 'ru_UA.CP1251',
1416 'rumanian': 'ro_RO.ISO8859-2',
1417 'russian': 'ru_RU.ISO8859-5',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001418 'rw': 'rw_RW.ISO8859-1',
1419 'rw_rw': 'rw_RW.ISO8859-1',
1420 'rw_rw.iso88591': 'rw_RW.ISO8859-1',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001421 'sd': 'sd_IN@devanagari.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001422 'se_no': 'se_NO.UTF-8',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001423 'serbocroatian': 'sr_RS.UTF-8@latin',
1424 'sh': 'sr_RS.UTF-8@latin',
1425 'sh_ba.iso88592@bosnia': 'sr_CS.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001426 'sh_hr': 'sh_HR.ISO8859-2',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001427 'sh_hr.iso88592': 'hr_HR.ISO8859-2',
1428 'sh_sp': 'sr_CS.ISO8859-2',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001429 'sh_yu': 'sr_RS.UTF-8@latin',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001430 'si': 'si_LK.UTF-8',
1431 'si_lk': 'si_LK.UTF-8',
1432 'sinhala': 'si_LK.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001433 'sk': 'sk_SK.ISO8859-2',
1434 'sk_sk': 'sk_SK.ISO8859-2',
1435 'sk_sk.iso88592': 'sk_SK.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001436 'sl': 'sl_SI.ISO8859-2',
1437 'sl_cs': 'sl_CS.ISO8859-2',
1438 'sl_si': 'sl_SI.ISO8859-2',
1439 'sl_si.iso88592': 'sl_SI.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001440 'slovak': 'sk_SK.ISO8859-2',
1441 'slovene': 'sl_SI.ISO8859-2',
1442 'slovenian': 'sl_SI.ISO8859-2',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001443 'sp': 'sr_CS.ISO8859-5',
1444 'sp_yu': 'sr_CS.ISO8859-5',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001445 'spanish': 'es_ES.ISO8859-1',
1446 'spanish.iso88591': 'es_ES.ISO8859-1',
1447 'spanish_spain': 'es_ES.ISO8859-1',
1448 'spanish_spain.8859': 'es_ES.ISO8859-1',
1449 'sq': 'sq_AL.ISO8859-2',
1450 'sq_al': 'sq_AL.ISO8859-2',
1451 'sq_al.iso88592': 'sq_AL.ISO8859-2',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001452 'sr': 'sr_RS.UTF-8',
1453 'sr@cyrillic': 'sr_RS.UTF-8',
1454 'sr@latin': 'sr_RS.UTF-8@latin',
1455 'sr@latn': 'sr_RS.UTF-8@latin',
1456 'sr_cs': 'sr_RS.UTF-8',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001457 'sr_cs.iso88592': 'sr_CS.ISO8859-2',
1458 'sr_cs.iso88592@latn': 'sr_CS.ISO8859-2',
1459 'sr_cs.iso88595': 'sr_CS.ISO8859-5',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001460 'sr_cs.utf8@latn': 'sr_RS.UTF-8@latin',
1461 'sr_cs@latn': 'sr_RS.UTF-8@latin',
1462 'sr_me': 'sr_ME.UTF-8',
1463 'sr_rs': 'sr_RS.UTF-8',
1464 'sr_rs.utf8@latn': 'sr_RS.UTF-8@latin',
1465 'sr_rs@latin': 'sr_RS.UTF-8@latin',
1466 'sr_rs@latn': 'sr_RS.UTF-8@latin',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001467 'sr_sp': 'sr_CS.ISO8859-2',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001468 'sr_yu': 'sr_RS.UTF-8@latin',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001469 'sr_yu.cp1251@cyrillic': 'sr_CS.CP1251',
1470 'sr_yu.iso88592': 'sr_CS.ISO8859-2',
1471 'sr_yu.iso88595': 'sr_CS.ISO8859-5',
1472 'sr_yu.iso88595@cyrillic': 'sr_CS.ISO8859-5',
1473 'sr_yu.microsoftcp1251@cyrillic': 'sr_CS.CP1251',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001474 'sr_yu.utf8@cyrillic': 'sr_RS.UTF-8',
1475 'sr_yu@cyrillic': 'sr_RS.UTF-8',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001476 'ss': 'ss_ZA.ISO8859-1',
1477 'ss_za': 'ss_ZA.ISO8859-1',
1478 'ss_za.iso88591': 'ss_ZA.ISO8859-1',
1479 'st': 'st_ZA.ISO8859-1',
1480 'st_za': 'st_ZA.ISO8859-1',
1481 'st_za.iso88591': 'st_ZA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001482 'sv': 'sv_SE.ISO8859-1',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001483 'sv.iso885915': 'sv_SE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001484 'sv_fi': 'sv_FI.ISO8859-1',
1485 'sv_fi.iso88591': 'sv_FI.ISO8859-1',
1486 'sv_fi.iso885915': 'sv_FI.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001487 'sv_fi.iso885915@euro': 'sv_FI.ISO8859-15',
1488 'sv_fi.utf8@euro': 'sv_FI.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001489 'sv_fi@euro': 'sv_FI.ISO8859-15',
1490 'sv_se': 'sv_SE.ISO8859-1',
1491 'sv_se.88591': 'sv_SE.ISO8859-1',
1492 'sv_se.iso88591': 'sv_SE.ISO8859-1',
1493 'sv_se.iso885915': 'sv_SE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001494 'sv_se@euro': 'sv_SE.ISO8859-15',
1495 'swedish': 'sv_SE.ISO8859-1',
1496 'swedish.iso88591': 'sv_SE.ISO8859-1',
1497 'ta': 'ta_IN.TSCII-0',
1498 'ta_in': 'ta_IN.TSCII-0',
1499 'ta_in.tscii': 'ta_IN.TSCII-0',
1500 'ta_in.tscii0': 'ta_IN.TSCII-0',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001501 'te': 'te_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001502 'tg': 'tg_TJ.KOI8-C',
1503 'tg_tj': 'tg_TJ.KOI8-C',
1504 'tg_tj.koi8c': 'tg_TJ.KOI8-C',
1505 'th': 'th_TH.ISO8859-11',
1506 'th_th': 'th_TH.ISO8859-11',
1507 'th_th.iso885911': 'th_TH.ISO8859-11',
1508 'th_th.tactis': 'th_TH.TIS620',
1509 'th_th.tis620': 'th_TH.TIS620',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001510 'thai': 'th_TH.ISO8859-11',
1511 'tl': 'tl_PH.ISO8859-1',
1512 'tl_ph': 'tl_PH.ISO8859-1',
1513 'tl_ph.iso88591': 'tl_PH.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001514 'tn': 'tn_ZA.ISO8859-15',
1515 'tn_za': 'tn_ZA.ISO8859-15',
1516 'tn_za.iso885915': 'tn_ZA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001517 'tr': 'tr_TR.ISO8859-9',
1518 'tr_tr': 'tr_TR.ISO8859-9',
1519 'tr_tr.iso88599': 'tr_TR.ISO8859-9',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001520 'ts': 'ts_ZA.ISO8859-1',
1521 'ts_za': 'ts_ZA.ISO8859-1',
1522 'ts_za.iso88591': 'ts_ZA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001523 'tt': 'tt_RU.TATAR-CYR',
1524 'tt_ru': 'tt_RU.TATAR-CYR',
1525 'tt_ru.koi8c': 'tt_RU.KOI8-C',
1526 'tt_ru.tatarcyr': 'tt_RU.TATAR-CYR',
1527 'turkish': 'tr_TR.ISO8859-9',
1528 'turkish.iso88599': 'tr_TR.ISO8859-9',
1529 'uk': 'uk_UA.KOI8-U',
1530 'uk_ua': 'uk_UA.KOI8-U',
1531 'uk_ua.cp1251': 'uk_UA.CP1251',
1532 'uk_ua.iso88595': 'uk_UA.ISO8859-5',
1533 'uk_ua.koi8u': 'uk_UA.KOI8-U',
1534 'uk_ua.microsoftcp1251': 'uk_UA.CP1251',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001535 'univ': 'en_US.utf',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001536 'universal': 'en_US.utf',
1537 'universal.utf8@ucs4': 'en_US.UTF-8',
1538 'ur': 'ur_PK.CP1256',
1539 'ur_pk': 'ur_PK.CP1256',
1540 'ur_pk.cp1256': 'ur_PK.CP1256',
1541 'ur_pk.microsoftcp1256': 'ur_PK.CP1256',
1542 'uz': 'uz_UZ.UTF-8',
1543 'uz_uz': 'uz_UZ.UTF-8',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001544 'uz_uz.iso88591': 'uz_UZ.ISO8859-1',
1545 'uz_uz.utf8@cyrillic': 'uz_UZ.UTF-8',
1546 'uz_uz@cyrillic': 'uz_UZ.UTF-8',
1547 've': 've_ZA.UTF-8',
1548 've_za': 've_ZA.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001549 'vi': 'vi_VN.TCVN',
1550 'vi_vn': 'vi_VN.TCVN',
1551 'vi_vn.tcvn': 'vi_VN.TCVN',
1552 'vi_vn.tcvn5712': 'vi_VN.TCVN',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001553 'vi_vn.viscii': 'vi_VN.VISCII',
1554 'vi_vn.viscii111': 'vi_VN.VISCII',
1555 'wa': 'wa_BE.ISO8859-1',
1556 'wa_be': 'wa_BE.ISO8859-1',
1557 'wa_be.iso88591': 'wa_BE.ISO8859-1',
1558 'wa_be.iso885915': 'wa_BE.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001559 'wa_be.iso885915@euro': 'wa_BE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001560 'wa_be@euro': 'wa_BE.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001561 'xh': 'xh_ZA.ISO8859-1',
1562 'xh_za': 'xh_ZA.ISO8859-1',
1563 'xh_za.iso88591': 'xh_ZA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001564 'yi': 'yi_US.CP1255',
1565 'yi_us': 'yi_US.CP1255',
1566 'yi_us.cp1255': 'yi_US.CP1255',
1567 'yi_us.microsoftcp1255': 'yi_US.CP1255',
1568 'zh': 'zh_CN.eucCN',
1569 'zh_cn': 'zh_CN.gb2312',
1570 'zh_cn.big5': 'zh_TW.big5',
1571 'zh_cn.euc': 'zh_CN.eucCN',
1572 'zh_cn.gb18030': 'zh_CN.gb18030',
1573 'zh_cn.gb2312': 'zh_CN.gb2312',
1574 'zh_cn.gbk': 'zh_CN.gbk',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001575 'zh_hk': 'zh_HK.big5hkscs',
1576 'zh_hk.big5': 'zh_HK.big5',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001577 'zh_hk.big5hk': 'zh_HK.big5hkscs',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001578 'zh_hk.big5hkscs': 'zh_HK.big5hkscs',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001579 'zh_tw': 'zh_TW.big5',
1580 'zh_tw.big5': 'zh_TW.big5',
1581 'zh_tw.euc': 'zh_TW.eucTW',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001582 'zh_tw.euctw': 'zh_TW.eucTW',
1583 'zu': 'zu_ZA.ISO8859-1',
1584 'zu_za': 'zu_ZA.ISO8859-1',
1585 'zu_za.iso88591': 'zu_ZA.ISO8859-1',
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001586}
1587
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001588#
Georg Brandlb709c2c2006-01-20 09:07:35 +00001589# This maps Windows language identifiers to locale strings.
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001590#
Tim Peters777f1082006-01-20 20:03:24 +00001591# This list has been updated from
Georg Brandlb709c2c2006-01-20 09:07:35 +00001592# http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nls_238z.asp
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001593# to include every locale up to Windows Vista.
Fredrik Lundh37a09822002-10-19 20:19:10 +00001594#
Georg Brandl5035c1c2006-01-20 13:38:26 +00001595# NOTE: this mapping is incomplete. If your language is missing, please
1596# submit a bug report to Python bug manager, which you can find via:
1597# http://www.python.org/dev/
1598# Make sure you include the missing language identifier and the suggested
1599# locale code.
1600#
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001601
1602windows_locale = {
Georg Brandlb709c2c2006-01-20 09:07:35 +00001603 0x0436: "af_ZA", # Afrikaans
1604 0x041c: "sq_AL", # Albanian
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001605 0x0484: "gsw_FR",# Alsatian - France
1606 0x045e: "am_ET", # Amharic - Ethiopia
Georg Brandlb709c2c2006-01-20 09:07:35 +00001607 0x0401: "ar_SA", # Arabic - Saudi Arabia
1608 0x0801: "ar_IQ", # Arabic - Iraq
1609 0x0c01: "ar_EG", # Arabic - Egypt
1610 0x1001: "ar_LY", # Arabic - Libya
1611 0x1401: "ar_DZ", # Arabic - Algeria
1612 0x1801: "ar_MA", # Arabic - Morocco
1613 0x1c01: "ar_TN", # Arabic - Tunisia
1614 0x2001: "ar_OM", # Arabic - Oman
1615 0x2401: "ar_YE", # Arabic - Yemen
1616 0x2801: "ar_SY", # Arabic - Syria
1617 0x2c01: "ar_JO", # Arabic - Jordan
1618 0x3001: "ar_LB", # Arabic - Lebanon
1619 0x3401: "ar_KW", # Arabic - Kuwait
1620 0x3801: "ar_AE", # Arabic - United Arab Emirates
1621 0x3c01: "ar_BH", # Arabic - Bahrain
1622 0x4001: "ar_QA", # Arabic - Qatar
1623 0x042b: "hy_AM", # Armenian
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001624 0x044d: "as_IN", # Assamese - India
1625 0x042c: "az_AZ", # Azeri - Latin
Georg Brandlb709c2c2006-01-20 09:07:35 +00001626 0x082c: "az_AZ", # Azeri - Cyrillic
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001627 0x046d: "ba_RU", # Bashkir
1628 0x042d: "eu_ES", # Basque - Russia
Georg Brandlb709c2c2006-01-20 09:07:35 +00001629 0x0423: "be_BY", # Belarusian
1630 0x0445: "bn_IN", # Begali
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001631 0x201a: "bs_BA", # Bosnian - Cyrillic
1632 0x141a: "bs_BA", # Bosnian - Latin
Georg Brandlb709c2c2006-01-20 09:07:35 +00001633 0x047e: "br_FR", # Breton - France
1634 0x0402: "bg_BG", # Bulgarian
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001635# 0x0455: "my_MM", # Burmese - Not supported
Georg Brandlb709c2c2006-01-20 09:07:35 +00001636 0x0403: "ca_ES", # Catalan
1637 0x0004: "zh_CHS",# Chinese - Simplified
1638 0x0404: "zh_TW", # Chinese - Taiwan
1639 0x0804: "zh_CN", # Chinese - PRC
1640 0x0c04: "zh_HK", # Chinese - Hong Kong S.A.R.
1641 0x1004: "zh_SG", # Chinese - Singapore
1642 0x1404: "zh_MO", # Chinese - Macao S.A.R.
1643 0x7c04: "zh_CHT",# Chinese - Traditional
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001644 0x0483: "co_FR", # Corsican - France
Georg Brandlb709c2c2006-01-20 09:07:35 +00001645 0x041a: "hr_HR", # Croatian
1646 0x101a: "hr_BA", # Croatian - Bosnia
1647 0x0405: "cs_CZ", # Czech
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001648 0x0406: "da_DK", # Danish
Georg Brandlb709c2c2006-01-20 09:07:35 +00001649 0x048c: "gbz_AF",# Dari - Afghanistan
1650 0x0465: "div_MV",# Divehi - Maldives
1651 0x0413: "nl_NL", # Dutch - The Netherlands
1652 0x0813: "nl_BE", # Dutch - Belgium
1653 0x0409: "en_US", # English - United States
1654 0x0809: "en_GB", # English - United Kingdom
1655 0x0c09: "en_AU", # English - Australia
1656 0x1009: "en_CA", # English - Canada
1657 0x1409: "en_NZ", # English - New Zealand
1658 0x1809: "en_IE", # English - Ireland
1659 0x1c09: "en_ZA", # English - South Africa
1660 0x2009: "en_JA", # English - Jamaica
1661 0x2409: "en_CB", # English - Carribbean
1662 0x2809: "en_BZ", # English - Belize
1663 0x2c09: "en_TT", # English - Trinidad
1664 0x3009: "en_ZW", # English - Zimbabwe
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001665 0x3409: "en_PH", # English - Philippines
1666 0x4009: "en_IN", # English - India
1667 0x4409: "en_MY", # English - Malaysia
1668 0x4809: "en_IN", # English - Singapore
Georg Brandlb709c2c2006-01-20 09:07:35 +00001669 0x0425: "et_EE", # Estonian
1670 0x0438: "fo_FO", # Faroese
1671 0x0464: "fil_PH",# Filipino
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001672 0x040b: "fi_FI", # Finnish
Georg Brandlb709c2c2006-01-20 09:07:35 +00001673 0x040c: "fr_FR", # French - France
1674 0x080c: "fr_BE", # French - Belgium
1675 0x0c0c: "fr_CA", # French - Canada
1676 0x100c: "fr_CH", # French - Switzerland
1677 0x140c: "fr_LU", # French - Luxembourg
1678 0x180c: "fr_MC", # French - Monaco
1679 0x0462: "fy_NL", # Frisian - Netherlands
1680 0x0456: "gl_ES", # Galician
1681 0x0437: "ka_GE", # Georgian
1682 0x0407: "de_DE", # German - Germany
1683 0x0807: "de_CH", # German - Switzerland
1684 0x0c07: "de_AT", # German - Austria
1685 0x1007: "de_LU", # German - Luxembourg
1686 0x1407: "de_LI", # German - Liechtenstein
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001687 0x0408: "el_GR", # Greek
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001688 0x046f: "kl_GL", # Greenlandic - Greenland
Georg Brandlb709c2c2006-01-20 09:07:35 +00001689 0x0447: "gu_IN", # Gujarati
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001690 0x0468: "ha_NG", # Hausa - Latin
Georg Brandlb709c2c2006-01-20 09:07:35 +00001691 0x040d: "he_IL", # Hebrew
1692 0x0439: "hi_IN", # Hindi
1693 0x040e: "hu_HU", # Hungarian
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001694 0x040f: "is_IS", # Icelandic
Georg Brandlb709c2c2006-01-20 09:07:35 +00001695 0x0421: "id_ID", # Indonesian
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001696 0x045d: "iu_CA", # Inuktitut - Syllabics
Georg Brandlb709c2c2006-01-20 09:07:35 +00001697 0x085d: "iu_CA", # Inuktitut - Latin
1698 0x083c: "ga_IE", # Irish - Ireland
Georg Brandlb709c2c2006-01-20 09:07:35 +00001699 0x0410: "it_IT", # Italian - Italy
1700 0x0810: "it_CH", # Italian - Switzerland
1701 0x0411: "ja_JP", # Japanese
1702 0x044b: "kn_IN", # Kannada - India
1703 0x043f: "kk_KZ", # Kazakh
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001704 0x0453: "kh_KH", # Khmer - Cambodia
1705 0x0486: "qut_GT",# K'iche - Guatemala
1706 0x0487: "rw_RW", # Kinyarwanda - Rwanda
Georg Brandlb709c2c2006-01-20 09:07:35 +00001707 0x0457: "kok_IN",# Konkani
1708 0x0412: "ko_KR", # Korean
1709 0x0440: "ky_KG", # Kyrgyz
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001710 0x0454: "lo_LA", # Lao - Lao PDR
Georg Brandlb709c2c2006-01-20 09:07:35 +00001711 0x0426: "lv_LV", # Latvian
1712 0x0427: "lt_LT", # Lithuanian
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001713 0x082e: "dsb_DE",# Lower Sorbian - Germany
Georg Brandlb709c2c2006-01-20 09:07:35 +00001714 0x046e: "lb_LU", # Luxembourgish
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001715 0x042f: "mk_MK", # FYROM Macedonian
Georg Brandlb709c2c2006-01-20 09:07:35 +00001716 0x043e: "ms_MY", # Malay - Malaysia
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001717 0x083e: "ms_BN", # Malay - Brunei Darussalam
Georg Brandlb709c2c2006-01-20 09:07:35 +00001718 0x044c: "ml_IN", # Malayalam - India
1719 0x043a: "mt_MT", # Maltese
1720 0x0481: "mi_NZ", # Maori
1721 0x047a: "arn_CL",# Mapudungun
1722 0x044e: "mr_IN", # Marathi
1723 0x047c: "moh_CA",# Mohawk - Canada
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001724 0x0450: "mn_MN", # Mongolian - Cyrillic
1725 0x0850: "mn_CN", # Mongolian - PRC
Georg Brandlb709c2c2006-01-20 09:07:35 +00001726 0x0461: "ne_NP", # Nepali
1727 0x0414: "nb_NO", # Norwegian - Bokmal
1728 0x0814: "nn_NO", # Norwegian - Nynorsk
1729 0x0482: "oc_FR", # Occitan - France
1730 0x0448: "or_IN", # Oriya - India
1731 0x0463: "ps_AF", # Pashto - Afghanistan
1732 0x0429: "fa_IR", # Persian
1733 0x0415: "pl_PL", # Polish
1734 0x0416: "pt_BR", # Portuguese - Brazil
1735 0x0816: "pt_PT", # Portuguese - Portugal
1736 0x0446: "pa_IN", # Punjabi
1737 0x046b: "quz_BO",# Quechua (Bolivia)
1738 0x086b: "quz_EC",# Quechua (Ecuador)
1739 0x0c6b: "quz_PE",# Quechua (Peru)
1740 0x0418: "ro_RO", # Romanian - Romania
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001741 0x0417: "rm_CH", # Romansh
Georg Brandlb709c2c2006-01-20 09:07:35 +00001742 0x0419: "ru_RU", # Russian
1743 0x243b: "smn_FI",# Sami Finland
1744 0x103b: "smj_NO",# Sami Norway
1745 0x143b: "smj_SE",# Sami Sweden
1746 0x043b: "se_NO", # Sami Northern Norway
1747 0x083b: "se_SE", # Sami Northern Sweden
1748 0x0c3b: "se_FI", # Sami Northern Finland
1749 0x203b: "sms_FI",# Sami Skolt
1750 0x183b: "sma_NO",# Sami Southern Norway
1751 0x1c3b: "sma_SE",# Sami Southern Sweden
1752 0x044f: "sa_IN", # Sanskrit
1753 0x0c1a: "sr_SP", # Serbian - Cyrillic
1754 0x1c1a: "sr_BA", # Serbian - Bosnia Cyrillic
1755 0x081a: "sr_SP", # Serbian - Latin
1756 0x181a: "sr_BA", # Serbian - Bosnia Latin
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001757 0x045b: "si_LK", # Sinhala - Sri Lanka
Georg Brandlb709c2c2006-01-20 09:07:35 +00001758 0x046c: "ns_ZA", # Northern Sotho
1759 0x0432: "tn_ZA", # Setswana - Southern Africa
1760 0x041b: "sk_SK", # Slovak
1761 0x0424: "sl_SI", # Slovenian
1762 0x040a: "es_ES", # Spanish - Spain
1763 0x080a: "es_MX", # Spanish - Mexico
1764 0x0c0a: "es_ES", # Spanish - Spain (Modern)
1765 0x100a: "es_GT", # Spanish - Guatemala
1766 0x140a: "es_CR", # Spanish - Costa Rica
1767 0x180a: "es_PA", # Spanish - Panama
1768 0x1c0a: "es_DO", # Spanish - Dominican Republic
1769 0x200a: "es_VE", # Spanish - Venezuela
1770 0x240a: "es_CO", # Spanish - Colombia
1771 0x280a: "es_PE", # Spanish - Peru
1772 0x2c0a: "es_AR", # Spanish - Argentina
1773 0x300a: "es_EC", # Spanish - Ecuador
1774 0x340a: "es_CL", # Spanish - Chile
1775 0x380a: "es_UR", # Spanish - Uruguay
1776 0x3c0a: "es_PY", # Spanish - Paraguay
1777 0x400a: "es_BO", # Spanish - Bolivia
1778 0x440a: "es_SV", # Spanish - El Salvador
1779 0x480a: "es_HN", # Spanish - Honduras
1780 0x4c0a: "es_NI", # Spanish - Nicaragua
1781 0x500a: "es_PR", # Spanish - Puerto Rico
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001782 0x540a: "es_US", # Spanish - United States
1783# 0x0430: "", # Sutu - Not supported
Georg Brandlb709c2c2006-01-20 09:07:35 +00001784 0x0441: "sw_KE", # Swahili
1785 0x041d: "sv_SE", # Swedish - Sweden
1786 0x081d: "sv_FI", # Swedish - Finland
1787 0x045a: "syr_SY",# Syriac
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001788 0x0428: "tg_TJ", # Tajik - Cyrillic
1789 0x085f: "tmz_DZ",# Tamazight - Latin
Georg Brandlb709c2c2006-01-20 09:07:35 +00001790 0x0449: "ta_IN", # Tamil
1791 0x0444: "tt_RU", # Tatar
1792 0x044a: "te_IN", # Telugu
1793 0x041e: "th_TH", # Thai
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001794 0x0851: "bo_BT", # Tibetan - Bhutan
1795 0x0451: "bo_CN", # Tibetan - PRC
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001796 0x041f: "tr_TR", # Turkish
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001797 0x0442: "tk_TM", # Turkmen - Cyrillic
1798 0x0480: "ug_CN", # Uighur - Arabic
Georg Brandlb709c2c2006-01-20 09:07:35 +00001799 0x0422: "uk_UA", # Ukrainian
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001800 0x042e: "wen_DE",# Upper Sorbian - Germany
Georg Brandlb709c2c2006-01-20 09:07:35 +00001801 0x0420: "ur_PK", # Urdu
1802 0x0820: "ur_IN", # Urdu - India
1803 0x0443: "uz_UZ", # Uzbek - Latin
1804 0x0843: "uz_UZ", # Uzbek - Cyrillic
1805 0x042a: "vi_VN", # Vietnamese
1806 0x0452: "cy_GB", # Welsh
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001807 0x0488: "wo_SN", # Wolof - Senegal
1808 0x0434: "xh_ZA", # Xhosa - South Africa
1809 0x0485: "sah_RU",# Yakut - Cyrillic
1810 0x0478: "ii_CN", # Yi - PRC
1811 0x046a: "yo_NG", # Yoruba - Nigeria
1812 0x0435: "zu_ZA", # Zulu
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001813}
1814
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001815def _print_locale():
1816
1817 """ Test function.
1818 """
1819 categories = {}
1820 def _init_categories(categories=categories):
1821 for k,v in globals().items():
1822 if k[:3] == 'LC_':
1823 categories[k] = v
1824 _init_categories()
1825 del categories['LC_ALL']
1826
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001827 print('Locale defaults as determined by getdefaultlocale():')
1828 print('-'*72)
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001829 lang, enc = getdefaultlocale()
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001830 print('Language: ', lang or '(undefined)')
1831 print('Encoding: ', enc or '(undefined)')
1832 print()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001833
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001834 print('Locale settings on startup:')
1835 print('-'*72)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001836 for name,category in categories.items():
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001837 print(name, '...')
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001838 lang, enc = getlocale(category)
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001839 print(' Language: ', lang or '(undefined)')
1840 print(' Encoding: ', enc or '(undefined)')
1841 print()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001842
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001843 print()
1844 print('Locale settings after calling resetlocale():')
1845 print('-'*72)
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001846 resetlocale()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001847 for name,category in categories.items():
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001848 print(name, '...')
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001849 lang, enc = getlocale(category)
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001850 print(' Language: ', lang or '(undefined)')
1851 print(' Encoding: ', enc or '(undefined)')
1852 print()
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001853
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001854 try:
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001855 setlocale(LC_ALL, "")
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001856 except:
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001857 print('NOTE:')
1858 print('setlocale(LC_ALL, "") does not support the default locale')
1859 print('given in the OS environment variables.')
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001860 else:
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001861 print()
1862 print('Locale settings after calling setlocale(LC_ALL, ""):')
1863 print('-'*72)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001864 for name,category in categories.items():
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001865 print(name, '...')
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001866 lang, enc = getlocale(category)
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001867 print(' Language: ', lang or '(undefined)')
1868 print(' Encoding: ', enc or '(undefined)')
1869 print()
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001870
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001871###
Guido van Rossumeef1d4e1997-11-19 19:01:43 +00001872
Tim Peters1baf8292001-01-24 10:13:46 +00001873try:
1874 LC_MESSAGES
Skip Montanaro0897f0c2002-03-25 21:40:36 +00001875except NameError:
Tim Peters1baf8292001-01-24 10:13:46 +00001876 pass
1877else:
1878 __all__.append("LC_MESSAGES")
1879
Guido van Rossumeef1d4e1997-11-19 19:01:43 +00001880if __name__=='__main__':
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001881 print('Locale aliasing:')
1882 print()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001883 _print_locale()
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001884 print()
1885 print('Number formatting:')
1886 print()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001887 _test()