blob: b7aaa52f041990ebee8356566727274130cf8ff9 [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)
145 result = ""
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000146 seps = 0
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000147 if s[-1] == ' ':
Antoine Pitrou350370c2009-03-14 00:13:13 +0000148 stripped = s.rstrip()
149 right_spaces = s[len(stripped):]
150 s = stripped
151 else:
152 right_spaces = ''
153 left_spaces = ''
154 groups = []
155 for interval in _grouping_intervals(grouping):
156 if not s or s[-1] not in "0123456789":
157 # only non-digit characters remain (sign, spaces)
158 left_spaces = s
159 s = ''
Guido van Rossum45e2fbc1998-03-26 21:13:24 +0000160 break
Antoine Pitrou350370c2009-03-14 00:13:13 +0000161 groups.append(s[-interval:])
162 s = s[:-interval]
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000163 if s:
Antoine Pitrou350370c2009-03-14 00:13:13 +0000164 groups.append(s)
165 groups.reverse()
166 return (
167 left_spaces + thousands_sep.join(groups) + right_spaces,
Antoine Pitrou6cf17aa2009-03-18 20:26:42 +0000168 len(thousands_sep) * (len(groups) - 1)
Antoine Pitrou350370c2009-03-14 00:13:13 +0000169 )
170
171# Strip a given amount of excess padding from the given string
172def _strip_padding(s, amount):
173 lpos = 0
174 while amount and s[lpos] == ' ':
175 lpos += 1
176 amount -= 1
177 rpos = len(s) - 1
178 while amount and s[rpos] == ' ':
179 rpos -= 1
180 amount -= 1
181 return s[lpos:rpos+1]
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000182
R. David Murraye59482e2009-04-01 03:42:00 +0000183_percent_re = re.compile(r'%(?:\((?P<key>.*?)\))?'
184 r'(?P<modifiers>[-#0-9 +*.hlL]*?)[eEfFgGdiouxXcrs%]')
185
Thomas Wouters477c8d52006-05-27 19:21:47 +0000186def format(percent, value, grouping=False, monetary=False, *additional):
187 """Returns the locale-aware substitution of a %? specifier
188 (percent).
189
190 additional is for format strings which contain one or more
191 '*' modifiers."""
192 # this is only for one-percent-specifier strings and this should be checked
R. David Murraye59482e2009-04-01 03:42:00 +0000193 match = _percent_re.match(percent)
194 if not match or len(match.group())!= len(percent):
195 raise ValueError(("format() must be given exactly one %%char "
196 "format specifier, %s not valid") % repr(percent))
197 return _format(percent, value, grouping, monetary, *additional)
198
199def _format(percent, value, grouping=False, monetary=False, *additional):
Thomas Wouters477c8d52006-05-27 19:21:47 +0000200 if additional:
201 formatted = percent % ((value,) + additional)
202 else:
203 formatted = percent % value
204 # floats and decimal ints need special action!
205 if percent[-1] in 'eEfFgG':
206 seps = 0
207 parts = formatted.split('.')
208 if grouping:
209 parts[0], seps = _group(parts[0], monetary=monetary)
210 decimal_point = localeconv()[monetary and 'mon_decimal_point'
211 or 'decimal_point']
212 formatted = decimal_point.join(parts)
Antoine Pitrou350370c2009-03-14 00:13:13 +0000213 if seps:
214 formatted = _strip_padding(formatted, seps)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000215 elif percent[-1] in 'diu':
Antoine Pitrou350370c2009-03-14 00:13:13 +0000216 seps = 0
Thomas Wouters477c8d52006-05-27 19:21:47 +0000217 if grouping:
Antoine Pitrou350370c2009-03-14 00:13:13 +0000218 formatted, seps = _group(formatted, monetary=monetary)
219 if seps:
220 formatted = _strip_padding(formatted, seps)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000221 return formatted
222
Thomas Wouters477c8d52006-05-27 19:21:47 +0000223def format_string(f, val, grouping=False):
224 """Formats a string in the same way that the % formatting would use,
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000225 but takes the current locale into account.
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000226 Grouping is applied if the third parameter is true."""
Thomas Wouters477c8d52006-05-27 19:21:47 +0000227 percents = list(_percent_re.finditer(f))
228 new_f = _percent_re.sub('%s', f)
229
230 if isinstance(val, tuple):
231 new_val = list(val)
232 i = 0
233 for perc in percents:
234 starcount = perc.group('modifiers').count('*')
235 new_val[i] = format(perc.group(), new_val[i], grouping, False, *new_val[i+1:i+1+starcount])
236 del new_val[i+1:i+1+starcount]
237 i += (1 + starcount)
238 val = tuple(new_val)
Raymond Hettinger89e12962009-01-26 02:09:03 +0000239 elif isinstance(val, collections.Mapping):
Thomas Wouters477c8d52006-05-27 19:21:47 +0000240 for perc in percents:
241 key = perc.group("key")
242 val[key] = format(perc.group(), val[key], grouping)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000243 else:
Thomas Wouters477c8d52006-05-27 19:21:47 +0000244 # val is a single value
245 val = format(percents[0].group(), val, grouping)
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000246
Thomas Wouters477c8d52006-05-27 19:21:47 +0000247 return new_f % val
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000248
Thomas Wouters477c8d52006-05-27 19:21:47 +0000249def currency(val, symbol=True, grouping=False, international=False):
250 """Formats val according to the currency settings
251 in the current locale."""
252 conv = localeconv()
253
254 # check for illegal values
255 digits = conv[international and 'int_frac_digits' or 'frac_digits']
256 if digits == 127:
257 raise ValueError("Currency formatting is not possible using "
258 "the 'C' locale.")
259
260 s = format('%%.%if' % digits, abs(val), grouping, monetary=True)
261 # '<' and '>' are markers if the sign must be inserted between symbol and value
262 s = '<' + s + '>'
263
264 if symbol:
265 smb = conv[international and 'int_curr_symbol' or 'currency_symbol']
266 precedes = conv[val<0 and 'n_cs_precedes' or 'p_cs_precedes']
267 separated = conv[val<0 and 'n_sep_by_space' or 'p_sep_by_space']
268
269 if precedes:
270 s = smb + (separated and ' ' or '') + s
271 else:
272 s = s + (separated and ' ' or '') + smb
273
274 sign_pos = conv[val<0 and 'n_sign_posn' or 'p_sign_posn']
275 sign = conv[val<0 and 'negative_sign' or 'positive_sign']
276
277 if sign_pos == 0:
278 s = '(' + s + ')'
279 elif sign_pos == 1:
280 s = sign + s
281 elif sign_pos == 2:
282 s = s + sign
283 elif sign_pos == 3:
284 s = s.replace('<', sign)
285 elif sign_pos == 4:
286 s = s.replace('>', sign)
287 else:
288 # the default if nothing specified;
289 # this should be the most fitting sign position
290 s = sign + s
291
292 return s.replace('<', '').replace('>', '')
Martin v. Löwisdb786872001-01-21 18:52:33 +0000293
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000294def str(val):
295 """Convert float to integer, taking the locale into account."""
Thomas Wouters477c8d52006-05-27 19:21:47 +0000296 return format("%.12g", val)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000297
Thomas Wouters477c8d52006-05-27 19:21:47 +0000298def atof(string, func=float):
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000299 "Parses a string as a float according to the locale settings."
300 #First, get rid of the grouping
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000301 ts = localeconv()['thousands_sep']
302 if ts:
Skip Montanaro249369c2004-04-10 16:39:32 +0000303 string = string.replace(ts, '')
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000304 #next, replace the decimal point with a dot
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000305 dd = localeconv()['decimal_point']
306 if dd:
Skip Montanaro249369c2004-04-10 16:39:32 +0000307 string = string.replace(dd, '.')
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000308 #finally, parse the string
Skip Montanaro249369c2004-04-10 16:39:32 +0000309 return func(string)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000310
311def atoi(str):
312 "Converts a string to an integer according to the locale settings."
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000313 return atof(str, int)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000314
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000315def _test():
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000316 setlocale(LC_ALL, "")
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000317 #do grouping
Thomas Wouters477c8d52006-05-27 19:21:47 +0000318 s1 = format("%d", 123456789,1)
Guido van Rossumbe19ed72007-02-09 05:37:30 +0000319 print(s1, "is", atoi(s1))
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000320 #standard formatting
Thomas Wouters477c8d52006-05-27 19:21:47 +0000321 s1 = str(3.14)
Guido van Rossumbe19ed72007-02-09 05:37:30 +0000322 print(s1, "is", atof(s1))
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000323
324### Locale name aliasing engine
325
326# Author: Marc-Andre Lemburg, mal@lemburg.com
Fredrik Lundh37a09822002-10-19 20:19:10 +0000327# Various tweaks by Fredrik Lundh <fredrik@pythonware.com>
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000328
329# store away the low-level version of setlocale (it's
330# overridden below)
331_setlocale = setlocale
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000332
333def normalize(localename):
334
335 """ Returns a normalized locale code for the given locale
336 name.
337
338 The returned locale code is formatted for use with
339 setlocale().
340
341 If normalization fails, the original name is returned
342 unchanged.
343
344 If the given encoding is not known, the function defaults to
345 the default encoding for the locale code just like setlocale()
346 does.
347
348 """
349 # Normalize the locale name and extract the encoding
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000350 fullname = localename.lower()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000351 if ':' in fullname:
352 # ':' is sometimes used as encoding delimiter.
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000353 fullname = fullname.replace(':', '.')
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000354 if '.' in fullname:
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000355 langname, encoding = fullname.split('.')[:2]
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000356 fullname = langname + '.' + encoding
357 else:
358 langname = fullname
359 encoding = ''
360
361 # First lookup: fullname (possibly with encoding)
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000362 norm_encoding = encoding.replace('-', '')
363 norm_encoding = norm_encoding.replace('_', '')
364 lookup_name = langname + '.' + encoding
365 code = locale_alias.get(lookup_name, None)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000366 if code is not None:
367 return code
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000368 #print 'first lookup failed'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000369
370 # Second try: langname (without encoding)
371 code = locale_alias.get(langname, None)
372 if code is not None:
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000373 #print 'langname lookup succeeded'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000374 if '.' in code:
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000375 langname, defenc = code.split('.')
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000376 else:
377 langname = code
378 defenc = ''
379 if encoding:
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000380 # Convert the encoding to a C lib compatible encoding string
381 norm_encoding = encodings.normalize_encoding(encoding)
382 #print 'norm encoding: %r' % norm_encoding
383 norm_encoding = encodings.aliases.aliases.get(norm_encoding,
384 norm_encoding)
385 #print 'aliased encoding: %r' % norm_encoding
386 encoding = locale_encoding_alias.get(norm_encoding,
387 norm_encoding)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000388 else:
389 encoding = defenc
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000390 #print 'found encoding %r' % encoding
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000391 if encoding:
392 return langname + '.' + encoding
393 else:
394 return langname
395
396 else:
397 return localename
398
399def _parse_localename(localename):
400
401 """ Parses the locale code for localename and returns the
402 result as tuple (language code, encoding).
403
404 The localename is normalized and passed through the locale
405 alias engine. A ValueError is raised in case the locale name
406 cannot be parsed.
407
408 The language code corresponds to RFC 1766. code and encoding
409 can be None in case the values cannot be determined or are
Jeremy Hyltona05e2932000-06-28 14:48:01 +0000410 unknown to this implementation.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000411
412 """
413 code = normalize(localename)
Georg Brandlb709c2c2006-01-20 09:07:35 +0000414 if '@' in code:
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000415 # Deal with locale modifiers
416 code, modifier = code.split('@')
417 if modifier == 'euro' and '.' not in code:
418 # Assume Latin-9 for @euro locales. This is bogus,
419 # since some systems may use other encodings for these
420 # locales. Also, we ignore other modifiers.
421 return code, 'iso-8859-15'
Tim Peters230a60c2002-11-09 05:08:07 +0000422
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000423 if '.' in code:
Raymond Hettinger346e67f2005-01-01 06:10:26 +0000424 return tuple(code.split('.')[:2])
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000425 elif code == 'C':
426 return None, None
Collin Winterce36ad82007-08-30 01:19:48 +0000427 raise ValueError('unknown locale: %s' % localename)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000428
429def _build_localename(localetuple):
430
431 """ Builds a locale code from the given tuple (language code,
432 encoding).
433
434 No aliasing or normalizing takes place.
435
436 """
437 language, encoding = localetuple
438 if language is None:
439 language = 'C'
440 if encoding is None:
441 return language
442 else:
443 return language + '.' + encoding
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000444
Matthias Klosef3f231f2005-09-20 07:02:49 +0000445def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000446
447 """ Tries to determine the default locale settings and returns
448 them as tuple (language code, encoding).
449
450 According to POSIX, a program which has not called
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000451 setlocale(LC_ALL, "") runs using the portable 'C' locale.
452 Calling setlocale(LC_ALL, "") lets it use the default locale as
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000453 defined by the LANG variable. Since we don't want to interfere
Thomas Wouters7e474022000-07-16 12:04:32 +0000454 with the current locale setting we thus emulate the behavior
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000455 in the way described above.
456
457 To maintain compatibility with other platforms, not only the
458 LANG variable is tested, but a list of variables given as
459 envvars parameter. The first found to be defined will be
460 used. envvars defaults to the search path used in GNU gettext;
461 it must always contain the variable name 'LANG'.
462
463 Except for the code 'C', the language code corresponds to RFC
464 1766. code and encoding can be None in case the values cannot
465 be determined.
466
467 """
Fredrik Lundh04661322000-07-09 23:16:10 +0000468
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000469 try:
470 # check if it's supported by the _locale module
471 import _locale
472 code, encoding = _locale._getdefaultlocale()
Fredrik Lundh04661322000-07-09 23:16:10 +0000473 except (ImportError, AttributeError):
474 pass
475 else:
Fredrik Lundh663809e2000-07-10 19:32:19 +0000476 # make sure the code/encoding values are valid
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000477 if sys.platform == "win32" and code and code[:2] == "0x":
478 # map windows language identifier to language name
479 code = windows_locale.get(int(code, 0))
Fredrik Lundh663809e2000-07-10 19:32:19 +0000480 # ...add other platform-specific processing here, if
481 # necessary...
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000482 return code, encoding
Fredrik Lundh04661322000-07-09 23:16:10 +0000483
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000484 # fall back on POSIX behaviour
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000485 import os
486 lookup = os.environ.get
487 for variable in envvars:
488 localename = lookup(variable,None)
Martin v. Löwisc8ae31d2004-07-26 12:45:18 +0000489 if localename:
Matthias Klosef3f231f2005-09-20 07:02:49 +0000490 if variable == 'LANGUAGE':
491 localename = localename.split(':')[0]
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000492 break
493 else:
494 localename = 'C'
495 return _parse_localename(localename)
496
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000497
498def getlocale(category=LC_CTYPE):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000499
500 """ Returns the current setting for the given locale category as
501 tuple (language code, encoding).
502
503 category may be one of the LC_* value except LC_ALL. It
504 defaults to LC_CTYPE.
505
506 Except for the code 'C', the language code corresponds to RFC
507 1766. code and encoding can be None in case the values cannot
508 be determined.
509
510 """
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000511 localename = _setlocale(category)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000512 if category == LC_ALL and ';' in localename:
Collin Winterce36ad82007-08-30 01:19:48 +0000513 raise TypeError('category LC_ALL is not supported')
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000514 return _parse_localename(localename)
515
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000516def setlocale(category, locale=None):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000517
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000518 """ Set the locale for the given category. The locale can be
519 a string, a locale tuple (language code, encoding), or None.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000520
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000521 Locale tuples are converted to strings the locale aliasing
522 engine. Locale strings are passed directly to the C lib.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000523
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000524 category may be given as one of the LC_* values.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000525
526 """
Guido van Rossum3172c5d2007-10-16 18:12:55 +0000527 if locale and not isinstance(locale, _builtin_str):
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000528 # convert to string
529 locale = normalize(_build_localename(locale))
530 return _setlocale(category, locale)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000531
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000532def resetlocale(category=LC_ALL):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000533
534 """ Sets the locale for category to the default setting.
535
536 The default setting is determined by calling
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000537 getdefaultlocale(). category defaults to LC_ALL.
538
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000539 """
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000540 _setlocale(category, _build_localename(getdefaultlocale()))
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000541
Ronald Oussorenfe8a3d62009-06-07 15:29:46 +0000542if sys.platform.startswith("win"):
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000543 # On Win32, this will return the ANSI code page
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000544 def getpreferredencoding(do_setlocale = True):
545 """Return the charset that the user is likely using."""
546 import _locale
Tim Petersa326f472002-11-05 03:49:09 +0000547 return _locale._getdefaultlocale()[1]
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000548else:
549 # On Unix, if CODESET is available, use that.
550 try:
551 CODESET
552 except NameError:
553 # Fall back to parsing environment variables :-(
554 def getpreferredencoding(do_setlocale = True):
555 """Return the charset that the user is likely using,
556 by looking at environment variables."""
Martin v. Löwis071ef772008-03-08 11:24:24 +0000557 res = getdefaultlocale()[1]
558 if res is None:
559 # LANG not set, default conservatively to ASCII
560 res = 'ascii'
561 return res
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000562 else:
563 def getpreferredencoding(do_setlocale = True):
564 """Return the charset that the user is likely using,
565 according to the system configuration."""
566 if do_setlocale:
567 oldloc = setlocale(LC_CTYPE)
Jeroen Ruigrok van der Wervenbcf85062009-05-06 05:33:24 +0000568 try:
569 setlocale(LC_CTYPE, "")
Jeroen Ruigrok van der Werven6ca2e0a2009-05-06 13:18:35 +0000570 except Error:
Jeroen Ruigrok van der Wervenbcf85062009-05-06 05:33:24 +0000571 pass
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000572 result = nl_langinfo(CODESET)
Ronald Oussoren6d77e072009-09-06 13:59:02 +0000573 if not result and sys.platform == 'darwin':
574 # nl_langinfo can return an empty string
575 # when the setting has an invalid value.
576 # Default to UTF-8 in that case because
577 # UTF-8 is the default charset on OSX and
578 # returning nothing will crash the
579 # interpreter.
580 result = 'UTF-8'
581
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000582 setlocale(LC_CTYPE, oldloc)
583 return result
584 else:
Ronald Oussoren6d77e072009-09-06 13:59:02 +0000585 result = nl_langinfo(CODESET)
586 if not result and sys.platform == 'darwin':
587 # See above for explanation
588 result = 'UTF-8'
Tim Peters230a60c2002-11-09 05:08:07 +0000589
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000590
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000591### Database
592#
593# The following data was extracted from the locale.alias file which
594# comes with X11 and then hand edited removing the explicit encoding
595# definitions and adding some more aliases. The file is usually
596# available as /usr/lib/X11/locale/locale.alias.
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000597#
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000598
599#
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000600# The local_encoding_alias table maps lowercase encoding alias names
601# to C locale encoding names (case-sensitive). Note that normalize()
602# first looks up the encoding in the encodings.aliases dictionary and
603# then applies this mapping to find the correct C lib name for the
604# encoding.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000605#
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000606locale_encoding_alias = {
607
608 # Mappings for non-standard encoding names used in locale names
609 '437': 'C',
610 'c': 'C',
611 'en': 'ISO8859-1',
612 'jis': 'JIS7',
613 'jis7': 'JIS7',
614 'ajec': 'eucJP',
615
616 # Mappings from Python codec names to C lib encoding names
617 'ascii': 'ISO8859-1',
618 'latin_1': 'ISO8859-1',
619 'iso8859_1': 'ISO8859-1',
620 'iso8859_10': 'ISO8859-10',
621 'iso8859_11': 'ISO8859-11',
622 'iso8859_13': 'ISO8859-13',
623 'iso8859_14': 'ISO8859-14',
624 'iso8859_15': 'ISO8859-15',
Jeroen Ruigrok van der Werven4072ff32009-05-08 14:17:00 +0000625 'iso8859_16': 'ISO8859-16',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000626 'iso8859_2': 'ISO8859-2',
627 'iso8859_3': 'ISO8859-3',
628 'iso8859_4': 'ISO8859-4',
629 'iso8859_5': 'ISO8859-5',
630 'iso8859_6': 'ISO8859-6',
631 'iso8859_7': 'ISO8859-7',
632 'iso8859_8': 'ISO8859-8',
633 'iso8859_9': 'ISO8859-9',
634 'iso2022_jp': 'JIS7',
635 'shift_jis': 'SJIS',
636 'tactis': 'TACTIS',
637 'euc_jp': 'eucJP',
638 'euc_kr': 'eucKR',
Marc-André Lemburgb4cebd42004-12-13 19:56:01 +0000639 'utf_8': 'UTF8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000640 'koi8_r': 'KOI8-R',
641 'koi8_u': 'KOI8-U',
642 # XXX This list is still incomplete. If you know more
643 # mappings, please file a bug report. Thanks.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000644}
645
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000646#
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000647# The locale_alias table maps lowercase alias names to C locale names
648# (case-sensitive). Encodings are always separated from the locale
649# name using a dot ('.'); they should only be given in case the
650# language name is needed to interpret the given encoding alias
651# correctly (CJK codes often have this need).
652#
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000653# Note that the normalize() function which uses this tables
654# removes '_' and '-' characters from the encoding part of the
655# locale name before doing the lookup. This saves a lot of
656# space in the table.
657#
658# MAL 2004-12-10:
659# Updated alias mapping to most recent locale.alias file
660# from X.org distribution using makelocalealias.py.
661#
662# These are the differences compared to the old mapping (Python 2.4
663# and older):
664#
665# updated 'bg' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
666# updated 'bg_bg' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
667# updated 'bulgarian' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
668# updated 'cz' -> 'cz_CZ.ISO8859-2' to 'cs_CZ.ISO8859-2'
669# updated 'cz_cz' -> 'cz_CZ.ISO8859-2' to 'cs_CZ.ISO8859-2'
670# updated 'czech' -> 'cs_CS.ISO8859-2' to 'cs_CZ.ISO8859-2'
671# updated 'dutch' -> 'nl_BE.ISO8859-1' to 'nl_NL.ISO8859-1'
672# updated 'et' -> 'et_EE.ISO8859-4' to 'et_EE.ISO8859-15'
673# updated 'et_ee' -> 'et_EE.ISO8859-4' to 'et_EE.ISO8859-15'
674# updated 'fi' -> 'fi_FI.ISO8859-1' to 'fi_FI.ISO8859-15'
675# updated 'fi_fi' -> 'fi_FI.ISO8859-1' to 'fi_FI.ISO8859-15'
676# updated 'iw' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
677# updated 'iw_il' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
678# updated 'japanese' -> 'ja_JP.SJIS' to 'ja_JP.eucJP'
679# updated 'lt' -> 'lt_LT.ISO8859-4' to 'lt_LT.ISO8859-13'
680# updated 'lv' -> 'lv_LV.ISO8859-4' to 'lv_LV.ISO8859-13'
681# updated 'sl' -> 'sl_CS.ISO8859-2' to 'sl_SI.ISO8859-2'
682# updated 'slovene' -> 'sl_CS.ISO8859-2' to 'sl_SI.ISO8859-2'
683# updated 'th_th' -> 'th_TH.TACTIS' to 'th_TH.ISO8859-11'
684# updated 'zh_cn' -> 'zh_CN.eucCN' to 'zh_CN.gb2312'
685# updated 'zh_cn.big5' -> 'zh_TW.eucTW' to 'zh_TW.big5'
686# updated 'zh_tw' -> 'zh_TW.eucTW' to 'zh_TW.big5'
687#
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000688# MAL 2008-05-30:
689# Updated alias mapping to most recent locale.alias file
690# from X.org distribution using makelocalealias.py.
691#
692# These are the differences compared to the old mapping (Python 2.5
693# and older):
694#
695# updated 'cs_cs.iso88592' -> 'cs_CZ.ISO8859-2' to 'cs_CS.ISO8859-2'
696# updated 'serbocroatian' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
697# updated 'sh' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
698# updated 'sh_hr.iso88592' -> 'sh_HR.ISO8859-2' to 'hr_HR.ISO8859-2'
699# updated 'sh_sp' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
700# updated 'sh_yu' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
701# updated 'sp' -> 'sp_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
702# updated 'sp_yu' -> 'sp_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
703# updated 'sr' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
704# updated 'sr@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
705# updated 'sr_sp' -> 'sr_SP.ISO8859-2' to 'sr_CS.ISO8859-2'
706# updated 'sr_yu' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
707# updated 'sr_yu.cp1251@cyrillic' -> 'sr_YU.CP1251' to 'sr_CS.CP1251'
708# updated 'sr_yu.iso88592' -> 'sr_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
709# updated 'sr_yu.iso88595' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
710# updated 'sr_yu.iso88595@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
711# updated 'sr_yu.microsoftcp1251@cyrillic' -> 'sr_YU.CP1251' to 'sr_CS.CP1251'
712# updated 'sr_yu.utf8@cyrillic' -> 'sr_YU.UTF-8' to 'sr_CS.UTF-8'
713# updated 'sr_yu@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
714
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000715locale_alias = {
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000716 'a3': 'a3_AZ.KOI8-C',
717 'a3_az': 'a3_AZ.KOI8-C',
718 'a3_az.koi8c': 'a3_AZ.KOI8-C',
719 'af': 'af_ZA.ISO8859-1',
720 'af_za': 'af_ZA.ISO8859-1',
721 'af_za.iso88591': 'af_ZA.ISO8859-1',
722 'am': 'am_ET.UTF-8',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000723 'am_et': 'am_ET.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000724 'american': 'en_US.ISO8859-1',
725 'american.iso88591': 'en_US.ISO8859-1',
726 'ar': 'ar_AA.ISO8859-6',
727 'ar_aa': 'ar_AA.ISO8859-6',
728 'ar_aa.iso88596': 'ar_AA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000729 'ar_ae': 'ar_AE.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000730 'ar_ae.iso88596': 'ar_AE.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000731 'ar_bh': 'ar_BH.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000732 'ar_bh.iso88596': 'ar_BH.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000733 'ar_dz': 'ar_DZ.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000734 'ar_dz.iso88596': 'ar_DZ.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000735 'ar_eg': 'ar_EG.ISO8859-6',
736 'ar_eg.iso88596': 'ar_EG.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000737 'ar_iq': 'ar_IQ.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000738 'ar_iq.iso88596': 'ar_IQ.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000739 'ar_jo': 'ar_JO.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000740 'ar_jo.iso88596': 'ar_JO.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000741 'ar_kw': 'ar_KW.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000742 'ar_kw.iso88596': 'ar_KW.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000743 'ar_lb': 'ar_LB.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000744 'ar_lb.iso88596': 'ar_LB.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000745 'ar_ly': 'ar_LY.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000746 'ar_ly.iso88596': 'ar_LY.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000747 'ar_ma': 'ar_MA.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000748 'ar_ma.iso88596': 'ar_MA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000749 'ar_om': 'ar_OM.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000750 'ar_om.iso88596': 'ar_OM.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000751 'ar_qa': 'ar_QA.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000752 'ar_qa.iso88596': 'ar_QA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000753 'ar_sa': 'ar_SA.ISO8859-6',
754 'ar_sa.iso88596': 'ar_SA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000755 'ar_sd': 'ar_SD.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000756 'ar_sd.iso88596': 'ar_SD.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000757 'ar_sy': 'ar_SY.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000758 'ar_sy.iso88596': 'ar_SY.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000759 'ar_tn': 'ar_TN.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000760 'ar_tn.iso88596': 'ar_TN.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000761 'ar_ye': 'ar_YE.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000762 'ar_ye.iso88596': 'ar_YE.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000763 'arabic': 'ar_AA.ISO8859-6',
764 'arabic.iso88596': 'ar_AA.ISO8859-6',
765 'az': 'az_AZ.ISO8859-9E',
766 'az_az': 'az_AZ.ISO8859-9E',
767 'az_az.iso88599e': 'az_AZ.ISO8859-9E',
768 'be': 'be_BY.CP1251',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000769 'be_by': 'be_BY.CP1251',
770 'be_by.cp1251': 'be_BY.CP1251',
771 'be_by.microsoftcp1251': 'be_BY.CP1251',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000772 'bg': 'bg_BG.CP1251',
773 'bg_bg': 'bg_BG.CP1251',
774 'bg_bg.cp1251': 'bg_BG.CP1251',
775 'bg_bg.iso88595': 'bg_BG.ISO8859-5',
776 'bg_bg.koi8r': 'bg_BG.KOI8-R',
777 'bg_bg.microsoftcp1251': 'bg_BG.CP1251',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000778 'bn_in': 'bn_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000779 'bokmal': 'nb_NO.ISO8859-1',
780 'bokm\xe5l': 'nb_NO.ISO8859-1',
781 'br': 'br_FR.ISO8859-1',
782 'br_fr': 'br_FR.ISO8859-1',
783 'br_fr.iso88591': 'br_FR.ISO8859-1',
784 'br_fr.iso885914': 'br_FR.ISO8859-14',
785 'br_fr.iso885915': 'br_FR.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000786 'br_fr.iso885915@euro': 'br_FR.ISO8859-15',
787 'br_fr.utf8@euro': 'br_FR.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000788 'br_fr@euro': 'br_FR.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000789 'bs': 'bs_BA.ISO8859-2',
790 'bs_ba': 'bs_BA.ISO8859-2',
791 'bs_ba.iso88592': 'bs_BA.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000792 'bulgarian': 'bg_BG.CP1251',
793 'c': 'C',
794 'c-french': 'fr_CA.ISO8859-1',
795 'c-french.iso88591': 'fr_CA.ISO8859-1',
796 'c.en': 'C',
797 'c.iso88591': 'en_US.ISO8859-1',
798 'c_c': 'C',
799 'c_c.c': 'C',
800 'ca': 'ca_ES.ISO8859-1',
801 'ca_es': 'ca_ES.ISO8859-1',
802 'ca_es.iso88591': 'ca_ES.ISO8859-1',
803 'ca_es.iso885915': 'ca_ES.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000804 'ca_es.iso885915@euro': 'ca_ES.ISO8859-15',
805 'ca_es.utf8@euro': 'ca_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000806 'ca_es@euro': 'ca_ES.ISO8859-15',
807 'catalan': 'ca_ES.ISO8859-1',
808 'cextend': 'en_US.ISO8859-1',
809 'cextend.en': 'en_US.ISO8859-1',
810 'chinese-s': 'zh_CN.eucCN',
811 'chinese-t': 'zh_TW.eucTW',
812 'croatian': 'hr_HR.ISO8859-2',
813 'cs': 'cs_CZ.ISO8859-2',
814 'cs_cs': 'cs_CZ.ISO8859-2',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000815 'cs_cs.iso88592': 'cs_CS.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000816 'cs_cz': 'cs_CZ.ISO8859-2',
817 'cs_cz.iso88592': 'cs_CZ.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000818 'cy': 'cy_GB.ISO8859-1',
819 'cy_gb': 'cy_GB.ISO8859-1',
820 'cy_gb.iso88591': 'cy_GB.ISO8859-1',
821 'cy_gb.iso885914': 'cy_GB.ISO8859-14',
822 'cy_gb.iso885915': 'cy_GB.ISO8859-15',
823 'cy_gb@euro': 'cy_GB.ISO8859-15',
824 'cz': 'cs_CZ.ISO8859-2',
825 'cz_cz': 'cs_CZ.ISO8859-2',
826 'czech': 'cs_CZ.ISO8859-2',
827 'da': 'da_DK.ISO8859-1',
828 'da_dk': 'da_DK.ISO8859-1',
829 'da_dk.88591': 'da_DK.ISO8859-1',
830 'da_dk.885915': 'da_DK.ISO8859-15',
831 'da_dk.iso88591': 'da_DK.ISO8859-1',
832 'da_dk.iso885915': 'da_DK.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000833 'da_dk@euro': 'da_DK.ISO8859-15',
834 'danish': 'da_DK.ISO8859-1',
835 'danish.iso88591': 'da_DK.ISO8859-1',
836 'dansk': 'da_DK.ISO8859-1',
837 'de': 'de_DE.ISO8859-1',
838 'de_at': 'de_AT.ISO8859-1',
839 'de_at.iso88591': 'de_AT.ISO8859-1',
840 'de_at.iso885915': 'de_AT.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000841 'de_at.iso885915@euro': 'de_AT.ISO8859-15',
842 'de_at.utf8@euro': 'de_AT.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000843 'de_at@euro': 'de_AT.ISO8859-15',
844 'de_be': 'de_BE.ISO8859-1',
845 'de_be.iso88591': 'de_BE.ISO8859-1',
846 'de_be.iso885915': 'de_BE.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000847 'de_be.iso885915@euro': 'de_BE.ISO8859-15',
848 'de_be.utf8@euro': 'de_BE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000849 'de_be@euro': 'de_BE.ISO8859-15',
850 'de_ch': 'de_CH.ISO8859-1',
851 'de_ch.iso88591': 'de_CH.ISO8859-1',
852 'de_ch.iso885915': 'de_CH.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000853 'de_ch@euro': 'de_CH.ISO8859-15',
854 'de_de': 'de_DE.ISO8859-1',
855 'de_de.88591': 'de_DE.ISO8859-1',
856 'de_de.885915': 'de_DE.ISO8859-15',
857 'de_de.885915@euro': 'de_DE.ISO8859-15',
858 'de_de.iso88591': 'de_DE.ISO8859-1',
859 'de_de.iso885915': 'de_DE.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000860 'de_de.iso885915@euro': 'de_DE.ISO8859-15',
861 'de_de.utf8@euro': 'de_DE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000862 'de_de@euro': 'de_DE.ISO8859-15',
863 'de_lu': 'de_LU.ISO8859-1',
864 'de_lu.iso88591': 'de_LU.ISO8859-1',
865 'de_lu.iso885915': 'de_LU.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000866 'de_lu.iso885915@euro': 'de_LU.ISO8859-15',
867 'de_lu.utf8@euro': 'de_LU.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000868 'de_lu@euro': 'de_LU.ISO8859-15',
869 'deutsch': 'de_DE.ISO8859-1',
870 'dutch': 'nl_NL.ISO8859-1',
871 'dutch.iso88591': 'nl_BE.ISO8859-1',
872 'ee': 'ee_EE.ISO8859-4',
873 'ee_ee': 'ee_EE.ISO8859-4',
874 'ee_ee.iso88594': 'ee_EE.ISO8859-4',
875 'eesti': 'et_EE.ISO8859-1',
876 'el': 'el_GR.ISO8859-7',
877 'el_gr': 'el_GR.ISO8859-7',
878 'el_gr.iso88597': 'el_GR.ISO8859-7',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000879 'el_gr@euro': 'el_GR.ISO8859-15',
880 'en': 'en_US.ISO8859-1',
881 'en.iso88591': 'en_US.ISO8859-1',
882 'en_au': 'en_AU.ISO8859-1',
883 'en_au.iso88591': 'en_AU.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000884 'en_be': 'en_BE.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000885 'en_be@euro': 'en_BE.ISO8859-15',
886 'en_bw': 'en_BW.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000887 'en_bw.iso88591': 'en_BW.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000888 'en_ca': 'en_CA.ISO8859-1',
889 'en_ca.iso88591': 'en_CA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000890 'en_gb': 'en_GB.ISO8859-1',
891 'en_gb.88591': 'en_GB.ISO8859-1',
892 'en_gb.iso88591': 'en_GB.ISO8859-1',
893 'en_gb.iso885915': 'en_GB.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000894 'en_gb@euro': 'en_GB.ISO8859-15',
895 'en_hk': 'en_HK.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000896 'en_hk.iso88591': 'en_HK.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000897 'en_ie': 'en_IE.ISO8859-1',
898 'en_ie.iso88591': 'en_IE.ISO8859-1',
899 'en_ie.iso885915': 'en_IE.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000900 'en_ie.iso885915@euro': 'en_IE.ISO8859-15',
901 'en_ie.utf8@euro': 'en_IE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000902 'en_ie@euro': 'en_IE.ISO8859-15',
903 'en_in': 'en_IN.ISO8859-1',
904 'en_nz': 'en_NZ.ISO8859-1',
905 'en_nz.iso88591': 'en_NZ.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000906 'en_ph': 'en_PH.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000907 'en_ph.iso88591': 'en_PH.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000908 'en_sg': 'en_SG.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000909 'en_sg.iso88591': 'en_SG.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000910 'en_uk': 'en_GB.ISO8859-1',
911 'en_us': 'en_US.ISO8859-1',
912 'en_us.88591': 'en_US.ISO8859-1',
913 'en_us.885915': 'en_US.ISO8859-15',
914 'en_us.iso88591': 'en_US.ISO8859-1',
915 'en_us.iso885915': 'en_US.ISO8859-15',
916 'en_us.iso885915@euro': 'en_US.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000917 'en_us@euro': 'en_US.ISO8859-15',
918 'en_us@euro@euro': 'en_US.ISO8859-15',
919 'en_za': 'en_ZA.ISO8859-1',
920 'en_za.88591': 'en_ZA.ISO8859-1',
921 'en_za.iso88591': 'en_ZA.ISO8859-1',
922 'en_za.iso885915': 'en_ZA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000923 'en_za@euro': 'en_ZA.ISO8859-15',
924 'en_zw': 'en_ZW.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000925 'en_zw.iso88591': 'en_ZW.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000926 'eng_gb': 'en_GB.ISO8859-1',
927 'eng_gb.8859': 'en_GB.ISO8859-1',
928 'english': 'en_EN.ISO8859-1',
929 'english.iso88591': 'en_EN.ISO8859-1',
930 'english_uk': 'en_GB.ISO8859-1',
931 'english_uk.8859': 'en_GB.ISO8859-1',
932 'english_united-states': 'en_US.ISO8859-1',
933 'english_united-states.437': 'C',
934 'english_us': 'en_US.ISO8859-1',
935 'english_us.8859': 'en_US.ISO8859-1',
936 'english_us.ascii': 'en_US.ISO8859-1',
937 'eo': 'eo_XX.ISO8859-3',
938 'eo_eo': 'eo_EO.ISO8859-3',
939 'eo_eo.iso88593': 'eo_EO.ISO8859-3',
940 'eo_xx': 'eo_XX.ISO8859-3',
941 'eo_xx.iso88593': 'eo_XX.ISO8859-3',
942 'es': 'es_ES.ISO8859-1',
943 'es_ar': 'es_AR.ISO8859-1',
944 'es_ar.iso88591': 'es_AR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000945 'es_bo': 'es_BO.ISO8859-1',
946 'es_bo.iso88591': 'es_BO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000947 'es_cl': 'es_CL.ISO8859-1',
948 'es_cl.iso88591': 'es_CL.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000949 'es_co': 'es_CO.ISO8859-1',
950 'es_co.iso88591': 'es_CO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000951 'es_cr': 'es_CR.ISO8859-1',
952 'es_cr.iso88591': 'es_CR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000953 'es_do': 'es_DO.ISO8859-1',
954 'es_do.iso88591': 'es_DO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000955 'es_ec': 'es_EC.ISO8859-1',
956 'es_ec.iso88591': 'es_EC.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000957 'es_es': 'es_ES.ISO8859-1',
958 'es_es.88591': 'es_ES.ISO8859-1',
959 'es_es.iso88591': 'es_ES.ISO8859-1',
960 'es_es.iso885915': 'es_ES.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000961 'es_es.iso885915@euro': 'es_ES.ISO8859-15',
962 'es_es.utf8@euro': 'es_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000963 'es_es@euro': 'es_ES.ISO8859-15',
964 'es_gt': 'es_GT.ISO8859-1',
965 'es_gt.iso88591': 'es_GT.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000966 'es_hn': 'es_HN.ISO8859-1',
967 'es_hn.iso88591': 'es_HN.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000968 'es_mx': 'es_MX.ISO8859-1',
969 'es_mx.iso88591': 'es_MX.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000970 'es_ni': 'es_NI.ISO8859-1',
971 'es_ni.iso88591': 'es_NI.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000972 'es_pa': 'es_PA.ISO8859-1',
973 'es_pa.iso88591': 'es_PA.ISO8859-1',
974 'es_pa.iso885915': 'es_PA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000975 'es_pa@euro': 'es_PA.ISO8859-15',
976 'es_pe': 'es_PE.ISO8859-1',
977 'es_pe.iso88591': 'es_PE.ISO8859-1',
978 'es_pe.iso885915': 'es_PE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000979 'es_pe@euro': 'es_PE.ISO8859-15',
980 'es_pr': 'es_PR.ISO8859-1',
981 'es_pr.iso88591': 'es_PR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000982 'es_py': 'es_PY.ISO8859-1',
983 'es_py.iso88591': 'es_PY.ISO8859-1',
984 'es_py.iso885915': 'es_PY.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000985 'es_py@euro': 'es_PY.ISO8859-15',
986 'es_sv': 'es_SV.ISO8859-1',
987 'es_sv.iso88591': 'es_SV.ISO8859-1',
988 'es_sv.iso885915': 'es_SV.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000989 'es_sv@euro': 'es_SV.ISO8859-15',
990 'es_us': 'es_US.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000991 'es_us.iso88591': 'es_US.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000992 'es_uy': 'es_UY.ISO8859-1',
993 'es_uy.iso88591': 'es_UY.ISO8859-1',
994 'es_uy.iso885915': 'es_UY.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000995 'es_uy@euro': 'es_UY.ISO8859-15',
996 'es_ve': 'es_VE.ISO8859-1',
997 'es_ve.iso88591': 'es_VE.ISO8859-1',
998 'es_ve.iso885915': 'es_VE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000999 'es_ve@euro': 'es_VE.ISO8859-15',
1000 'estonian': 'et_EE.ISO8859-1',
1001 'et': 'et_EE.ISO8859-15',
1002 'et_ee': 'et_EE.ISO8859-15',
1003 'et_ee.iso88591': 'et_EE.ISO8859-1',
1004 'et_ee.iso885913': 'et_EE.ISO8859-13',
1005 'et_ee.iso885915': 'et_EE.ISO8859-15',
1006 'et_ee.iso88594': 'et_EE.ISO8859-4',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001007 'et_ee@euro': 'et_EE.ISO8859-15',
1008 'eu': 'eu_ES.ISO8859-1',
1009 'eu_es': 'eu_ES.ISO8859-1',
1010 'eu_es.iso88591': 'eu_ES.ISO8859-1',
1011 'eu_es.iso885915': 'eu_ES.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001012 'eu_es.iso885915@euro': 'eu_ES.ISO8859-15',
1013 'eu_es.utf8@euro': 'eu_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001014 'eu_es@euro': 'eu_ES.ISO8859-15',
1015 'fa': 'fa_IR.UTF-8',
1016 'fa_ir': 'fa_IR.UTF-8',
1017 'fa_ir.isiri3342': 'fa_IR.ISIRI-3342',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001018 'fi': 'fi_FI.ISO8859-15',
1019 'fi_fi': 'fi_FI.ISO8859-15',
1020 'fi_fi.88591': 'fi_FI.ISO8859-1',
1021 'fi_fi.iso88591': 'fi_FI.ISO8859-1',
1022 'fi_fi.iso885915': 'fi_FI.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001023 'fi_fi.iso885915@euro': 'fi_FI.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001024 'fi_fi.utf8@euro': 'fi_FI.UTF-8',
1025 'fi_fi@euro': 'fi_FI.ISO8859-15',
1026 'finnish': 'fi_FI.ISO8859-1',
1027 'finnish.iso88591': 'fi_FI.ISO8859-1',
1028 'fo': 'fo_FO.ISO8859-1',
1029 'fo_fo': 'fo_FO.ISO8859-1',
1030 'fo_fo.iso88591': 'fo_FO.ISO8859-1',
1031 'fo_fo.iso885915': 'fo_FO.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001032 'fo_fo@euro': 'fo_FO.ISO8859-15',
1033 'fr': 'fr_FR.ISO8859-1',
1034 'fr_be': 'fr_BE.ISO8859-1',
1035 'fr_be.88591': 'fr_BE.ISO8859-1',
1036 'fr_be.iso88591': 'fr_BE.ISO8859-1',
1037 'fr_be.iso885915': 'fr_BE.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001038 'fr_be.iso885915@euro': 'fr_BE.ISO8859-15',
1039 'fr_be.utf8@euro': 'fr_BE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001040 'fr_be@euro': 'fr_BE.ISO8859-15',
1041 'fr_ca': 'fr_CA.ISO8859-1',
1042 'fr_ca.88591': 'fr_CA.ISO8859-1',
1043 'fr_ca.iso88591': 'fr_CA.ISO8859-1',
1044 'fr_ca.iso885915': 'fr_CA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001045 'fr_ca@euro': 'fr_CA.ISO8859-15',
1046 'fr_ch': 'fr_CH.ISO8859-1',
1047 'fr_ch.88591': 'fr_CH.ISO8859-1',
1048 'fr_ch.iso88591': 'fr_CH.ISO8859-1',
1049 'fr_ch.iso885915': 'fr_CH.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001050 'fr_ch@euro': 'fr_CH.ISO8859-15',
1051 'fr_fr': 'fr_FR.ISO8859-1',
1052 'fr_fr.88591': 'fr_FR.ISO8859-1',
1053 'fr_fr.iso88591': 'fr_FR.ISO8859-1',
1054 'fr_fr.iso885915': 'fr_FR.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001055 'fr_fr.iso885915@euro': 'fr_FR.ISO8859-15',
1056 'fr_fr.utf8@euro': 'fr_FR.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001057 'fr_fr@euro': 'fr_FR.ISO8859-15',
1058 'fr_lu': 'fr_LU.ISO8859-1',
1059 'fr_lu.88591': 'fr_LU.ISO8859-1',
1060 'fr_lu.iso88591': 'fr_LU.ISO8859-1',
1061 'fr_lu.iso885915': 'fr_LU.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001062 'fr_lu.iso885915@euro': 'fr_LU.ISO8859-15',
1063 'fr_lu.utf8@euro': 'fr_LU.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001064 'fr_lu@euro': 'fr_LU.ISO8859-15',
1065 'fran\xe7ais': 'fr_FR.ISO8859-1',
1066 'fre_fr': 'fr_FR.ISO8859-1',
1067 'fre_fr.8859': 'fr_FR.ISO8859-1',
1068 'french': 'fr_FR.ISO8859-1',
1069 'french.iso88591': 'fr_CH.ISO8859-1',
1070 'french_france': 'fr_FR.ISO8859-1',
1071 'french_france.8859': 'fr_FR.ISO8859-1',
1072 'ga': 'ga_IE.ISO8859-1',
1073 'ga_ie': 'ga_IE.ISO8859-1',
1074 'ga_ie.iso88591': 'ga_IE.ISO8859-1',
1075 'ga_ie.iso885914': 'ga_IE.ISO8859-14',
1076 'ga_ie.iso885915': 'ga_IE.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001077 'ga_ie.iso885915@euro': 'ga_IE.ISO8859-15',
1078 'ga_ie.utf8@euro': 'ga_IE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001079 'ga_ie@euro': 'ga_IE.ISO8859-15',
1080 'galego': 'gl_ES.ISO8859-1',
1081 'galician': 'gl_ES.ISO8859-1',
1082 'gd': 'gd_GB.ISO8859-1',
1083 'gd_gb': 'gd_GB.ISO8859-1',
1084 'gd_gb.iso88591': 'gd_GB.ISO8859-1',
1085 'gd_gb.iso885914': 'gd_GB.ISO8859-14',
1086 'gd_gb.iso885915': 'gd_GB.ISO8859-15',
1087 'gd_gb@euro': 'gd_GB.ISO8859-15',
1088 'ger_de': 'de_DE.ISO8859-1',
1089 'ger_de.8859': 'de_DE.ISO8859-1',
1090 'german': 'de_DE.ISO8859-1',
1091 'german.iso88591': 'de_CH.ISO8859-1',
1092 'german_germany': 'de_DE.ISO8859-1',
1093 'german_germany.8859': 'de_DE.ISO8859-1',
1094 'gl': 'gl_ES.ISO8859-1',
1095 'gl_es': 'gl_ES.ISO8859-1',
1096 'gl_es.iso88591': 'gl_ES.ISO8859-1',
1097 'gl_es.iso885915': 'gl_ES.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001098 'gl_es.iso885915@euro': 'gl_ES.ISO8859-15',
1099 'gl_es.utf8@euro': 'gl_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001100 'gl_es@euro': 'gl_ES.ISO8859-15',
1101 'greek': 'el_GR.ISO8859-7',
1102 'greek.iso88597': 'el_GR.ISO8859-7',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001103 'gu_in': 'gu_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001104 'gv': 'gv_GB.ISO8859-1',
1105 'gv_gb': 'gv_GB.ISO8859-1',
1106 'gv_gb.iso88591': 'gv_GB.ISO8859-1',
1107 'gv_gb.iso885914': 'gv_GB.ISO8859-14',
1108 'gv_gb.iso885915': 'gv_GB.ISO8859-15',
1109 'gv_gb@euro': 'gv_GB.ISO8859-15',
1110 'he': 'he_IL.ISO8859-8',
1111 'he_il': 'he_IL.ISO8859-8',
1112 'he_il.cp1255': 'he_IL.CP1255',
1113 'he_il.iso88598': 'he_IL.ISO8859-8',
1114 'he_il.microsoftcp1255': 'he_IL.CP1255',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001115 'hebrew': 'iw_IL.ISO8859-8',
1116 'hebrew.iso88598': 'iw_IL.ISO8859-8',
1117 'hi': 'hi_IN.ISCII-DEV',
1118 'hi_in': 'hi_IN.ISCII-DEV',
1119 'hi_in.isciidev': 'hi_IN.ISCII-DEV',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001120 'hr': 'hr_HR.ISO8859-2',
1121 'hr_hr': 'hr_HR.ISO8859-2',
1122 'hr_hr.iso88592': 'hr_HR.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001123 'hrvatski': 'hr_HR.ISO8859-2',
1124 'hu': 'hu_HU.ISO8859-2',
1125 'hu_hu': 'hu_HU.ISO8859-2',
1126 'hu_hu.iso88592': 'hu_HU.ISO8859-2',
1127 'hungarian': 'hu_HU.ISO8859-2',
1128 'icelandic': 'is_IS.ISO8859-1',
1129 'icelandic.iso88591': 'is_IS.ISO8859-1',
1130 'id': 'id_ID.ISO8859-1',
1131 'id_id': 'id_ID.ISO8859-1',
1132 'in': 'id_ID.ISO8859-1',
1133 'in_id': 'id_ID.ISO8859-1',
1134 'is': 'is_IS.ISO8859-1',
1135 'is_is': 'is_IS.ISO8859-1',
1136 'is_is.iso88591': 'is_IS.ISO8859-1',
1137 'is_is.iso885915': 'is_IS.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001138 'is_is@euro': 'is_IS.ISO8859-15',
1139 'iso-8859-1': 'en_US.ISO8859-1',
1140 'iso-8859-15': 'en_US.ISO8859-15',
1141 'iso8859-1': 'en_US.ISO8859-1',
1142 'iso8859-15': 'en_US.ISO8859-15',
1143 'iso_8859_1': 'en_US.ISO8859-1',
1144 'iso_8859_15': 'en_US.ISO8859-15',
1145 'it': 'it_IT.ISO8859-1',
1146 'it_ch': 'it_CH.ISO8859-1',
1147 'it_ch.iso88591': 'it_CH.ISO8859-1',
1148 'it_ch.iso885915': 'it_CH.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001149 'it_ch@euro': 'it_CH.ISO8859-15',
1150 'it_it': 'it_IT.ISO8859-1',
1151 'it_it.88591': 'it_IT.ISO8859-1',
1152 'it_it.iso88591': 'it_IT.ISO8859-1',
1153 'it_it.iso885915': 'it_IT.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001154 'it_it.iso885915@euro': 'it_IT.ISO8859-15',
1155 'it_it.utf8@euro': 'it_IT.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001156 'it_it@euro': 'it_IT.ISO8859-15',
1157 'italian': 'it_IT.ISO8859-1',
1158 'italian.iso88591': 'it_IT.ISO8859-1',
1159 'iu': 'iu_CA.NUNACOM-8',
1160 'iu_ca': 'iu_CA.NUNACOM-8',
1161 'iu_ca.nunacom8': 'iu_CA.NUNACOM-8',
1162 'iw': 'he_IL.ISO8859-8',
1163 'iw_il': 'he_IL.ISO8859-8',
1164 'iw_il.iso88598': 'he_IL.ISO8859-8',
1165 'ja': 'ja_JP.eucJP',
1166 'ja.jis': 'ja_JP.JIS7',
1167 'ja.sjis': 'ja_JP.SJIS',
1168 'ja_jp': 'ja_JP.eucJP',
1169 'ja_jp.ajec': 'ja_JP.eucJP',
1170 'ja_jp.euc': 'ja_JP.eucJP',
1171 'ja_jp.eucjp': 'ja_JP.eucJP',
1172 'ja_jp.iso-2022-jp': 'ja_JP.JIS7',
1173 'ja_jp.iso2022jp': 'ja_JP.JIS7',
1174 'ja_jp.jis': 'ja_JP.JIS7',
1175 'ja_jp.jis7': 'ja_JP.JIS7',
1176 'ja_jp.mscode': 'ja_JP.SJIS',
1177 'ja_jp.sjis': 'ja_JP.SJIS',
1178 'ja_jp.ujis': 'ja_JP.eucJP',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001179 'japan': 'ja_JP.eucJP',
1180 'japanese': 'ja_JP.eucJP',
1181 'japanese-euc': 'ja_JP.eucJP',
1182 'japanese.euc': 'ja_JP.eucJP',
1183 'japanese.sjis': 'ja_JP.SJIS',
1184 'jp_jp': 'ja_JP.eucJP',
1185 'ka': 'ka_GE.GEORGIAN-ACADEMY',
1186 'ka_ge': 'ka_GE.GEORGIAN-ACADEMY',
1187 'ka_ge.georgianacademy': 'ka_GE.GEORGIAN-ACADEMY',
1188 'ka_ge.georgianps': 'ka_GE.GEORGIAN-PS',
1189 'ka_ge.georgianrs': 'ka_GE.GEORGIAN-ACADEMY',
1190 'kl': 'kl_GL.ISO8859-1',
1191 'kl_gl': 'kl_GL.ISO8859-1',
1192 'kl_gl.iso88591': 'kl_GL.ISO8859-1',
1193 'kl_gl.iso885915': 'kl_GL.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001194 'kl_gl@euro': 'kl_GL.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001195 'km_kh': 'km_KH.UTF-8',
1196 'kn_in': 'kn_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001197 'ko': 'ko_KR.eucKR',
1198 'ko_kr': 'ko_KR.eucKR',
1199 'ko_kr.euc': 'ko_KR.eucKR',
1200 'ko_kr.euckr': 'ko_KR.eucKR',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001201 'korean': 'ko_KR.eucKR',
1202 'korean.euc': 'ko_KR.eucKR',
1203 'kw': 'kw_GB.ISO8859-1',
1204 'kw_gb': 'kw_GB.ISO8859-1',
1205 'kw_gb.iso88591': 'kw_GB.ISO8859-1',
1206 'kw_gb.iso885914': 'kw_GB.ISO8859-14',
1207 'kw_gb.iso885915': 'kw_GB.ISO8859-15',
1208 'kw_gb@euro': 'kw_GB.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001209 'ky': 'ky_KG.UTF-8',
1210 'ky_kg': 'ky_KG.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001211 'lithuanian': 'lt_LT.ISO8859-13',
1212 'lo': 'lo_LA.MULELAO-1',
1213 'lo_la': 'lo_LA.MULELAO-1',
1214 'lo_la.cp1133': 'lo_LA.IBM-CP1133',
1215 'lo_la.ibmcp1133': 'lo_LA.IBM-CP1133',
1216 'lo_la.mulelao1': 'lo_LA.MULELAO-1',
1217 'lt': 'lt_LT.ISO8859-13',
1218 'lt_lt': 'lt_LT.ISO8859-13',
1219 'lt_lt.iso885913': 'lt_LT.ISO8859-13',
1220 'lt_lt.iso88594': 'lt_LT.ISO8859-4',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001221 'lv': 'lv_LV.ISO8859-13',
1222 'lv_lv': 'lv_LV.ISO8859-13',
1223 'lv_lv.iso885913': 'lv_LV.ISO8859-13',
1224 'lv_lv.iso88594': 'lv_LV.ISO8859-4',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001225 'mi': 'mi_NZ.ISO8859-1',
1226 'mi_nz': 'mi_NZ.ISO8859-1',
1227 'mi_nz.iso88591': 'mi_NZ.ISO8859-1',
1228 'mk': 'mk_MK.ISO8859-5',
1229 'mk_mk': 'mk_MK.ISO8859-5',
1230 'mk_mk.cp1251': 'mk_MK.CP1251',
1231 'mk_mk.iso88595': 'mk_MK.ISO8859-5',
1232 'mk_mk.microsoftcp1251': 'mk_MK.CP1251',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001233 'mr_in': 'mr_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001234 'ms': 'ms_MY.ISO8859-1',
1235 'ms_my': 'ms_MY.ISO8859-1',
1236 'ms_my.iso88591': 'ms_MY.ISO8859-1',
1237 'mt': 'mt_MT.ISO8859-3',
1238 'mt_mt': 'mt_MT.ISO8859-3',
1239 'mt_mt.iso88593': 'mt_MT.ISO8859-3',
1240 'nb': 'nb_NO.ISO8859-1',
1241 'nb_no': 'nb_NO.ISO8859-1',
1242 'nb_no.88591': 'nb_NO.ISO8859-1',
1243 'nb_no.iso88591': 'nb_NO.ISO8859-1',
1244 'nb_no.iso885915': 'nb_NO.ISO8859-15',
1245 'nb_no@euro': 'nb_NO.ISO8859-15',
1246 'nl': 'nl_NL.ISO8859-1',
1247 'nl_be': 'nl_BE.ISO8859-1',
1248 'nl_be.88591': 'nl_BE.ISO8859-1',
1249 'nl_be.iso88591': 'nl_BE.ISO8859-1',
1250 'nl_be.iso885915': 'nl_BE.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001251 'nl_be.iso885915@euro': 'nl_BE.ISO8859-15',
1252 'nl_be.utf8@euro': 'nl_BE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001253 'nl_be@euro': 'nl_BE.ISO8859-15',
1254 'nl_nl': 'nl_NL.ISO8859-1',
1255 'nl_nl.88591': 'nl_NL.ISO8859-1',
1256 'nl_nl.iso88591': 'nl_NL.ISO8859-1',
1257 'nl_nl.iso885915': 'nl_NL.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001258 'nl_nl.iso885915@euro': 'nl_NL.ISO8859-15',
1259 'nl_nl.utf8@euro': 'nl_NL.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001260 'nl_nl@euro': 'nl_NL.ISO8859-15',
1261 'nn': 'nn_NO.ISO8859-1',
1262 'nn_no': 'nn_NO.ISO8859-1',
1263 'nn_no.88591': 'nn_NO.ISO8859-1',
1264 'nn_no.iso88591': 'nn_NO.ISO8859-1',
1265 'nn_no.iso885915': 'nn_NO.ISO8859-15',
1266 'nn_no@euro': 'nn_NO.ISO8859-15',
1267 'no': 'no_NO.ISO8859-1',
1268 'no@nynorsk': 'ny_NO.ISO8859-1',
1269 'no_no': 'no_NO.ISO8859-1',
1270 'no_no.88591': 'no_NO.ISO8859-1',
1271 'no_no.iso88591': 'no_NO.ISO8859-1',
1272 'no_no.iso885915': 'no_NO.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001273 'no_no@euro': 'no_NO.ISO8859-15',
1274 'norwegian': 'no_NO.ISO8859-1',
1275 'norwegian.iso88591': 'no_NO.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001276 'nr': 'nr_ZA.ISO8859-1',
1277 'nr_za': 'nr_ZA.ISO8859-1',
1278 'nr_za.iso88591': 'nr_ZA.ISO8859-1',
1279 'nso': 'nso_ZA.ISO8859-15',
1280 'nso_za': 'nso_ZA.ISO8859-15',
1281 'nso_za.iso885915': 'nso_ZA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001282 'ny': 'ny_NO.ISO8859-1',
1283 'ny_no': 'ny_NO.ISO8859-1',
1284 'ny_no.88591': 'ny_NO.ISO8859-1',
1285 'ny_no.iso88591': 'ny_NO.ISO8859-1',
1286 'ny_no.iso885915': 'ny_NO.ISO8859-15',
1287 'ny_no@euro': 'ny_NO.ISO8859-15',
1288 'nynorsk': 'nn_NO.ISO8859-1',
1289 'oc': 'oc_FR.ISO8859-1',
1290 'oc_fr': 'oc_FR.ISO8859-1',
1291 'oc_fr.iso88591': 'oc_FR.ISO8859-1',
1292 'oc_fr.iso885915': 'oc_FR.ISO8859-15',
1293 'oc_fr@euro': 'oc_FR.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001294 'pa_in': 'pa_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001295 'pd': 'pd_US.ISO8859-1',
1296 'pd_de': 'pd_DE.ISO8859-1',
1297 'pd_de.iso88591': 'pd_DE.ISO8859-1',
1298 'pd_de.iso885915': 'pd_DE.ISO8859-15',
1299 'pd_de@euro': 'pd_DE.ISO8859-15',
1300 'pd_us': 'pd_US.ISO8859-1',
1301 'pd_us.iso88591': 'pd_US.ISO8859-1',
1302 'pd_us.iso885915': 'pd_US.ISO8859-15',
1303 'pd_us@euro': 'pd_US.ISO8859-15',
1304 'ph': 'ph_PH.ISO8859-1',
1305 'ph_ph': 'ph_PH.ISO8859-1',
1306 'ph_ph.iso88591': 'ph_PH.ISO8859-1',
1307 'pl': 'pl_PL.ISO8859-2',
1308 'pl_pl': 'pl_PL.ISO8859-2',
1309 'pl_pl.iso88592': 'pl_PL.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001310 'polish': 'pl_PL.ISO8859-2',
1311 'portuguese': 'pt_PT.ISO8859-1',
1312 'portuguese.iso88591': 'pt_PT.ISO8859-1',
1313 'portuguese_brazil': 'pt_BR.ISO8859-1',
1314 'portuguese_brazil.8859': 'pt_BR.ISO8859-1',
1315 'posix': 'C',
1316 'posix-utf2': 'C',
1317 'pp': 'pp_AN.ISO8859-1',
1318 'pp_an': 'pp_AN.ISO8859-1',
1319 'pp_an.iso88591': 'pp_AN.ISO8859-1',
1320 'pt': 'pt_PT.ISO8859-1',
1321 'pt_br': 'pt_BR.ISO8859-1',
1322 'pt_br.88591': 'pt_BR.ISO8859-1',
1323 'pt_br.iso88591': 'pt_BR.ISO8859-1',
1324 'pt_br.iso885915': 'pt_BR.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001325 'pt_br@euro': 'pt_BR.ISO8859-15',
1326 'pt_pt': 'pt_PT.ISO8859-1',
1327 'pt_pt.88591': 'pt_PT.ISO8859-1',
1328 'pt_pt.iso88591': 'pt_PT.ISO8859-1',
1329 'pt_pt.iso885915': 'pt_PT.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001330 'pt_pt.iso885915@euro': 'pt_PT.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001331 'pt_pt.utf8@euro': 'pt_PT.UTF-8',
1332 'pt_pt@euro': 'pt_PT.ISO8859-15',
1333 'ro': 'ro_RO.ISO8859-2',
1334 'ro_ro': 'ro_RO.ISO8859-2',
1335 'ro_ro.iso88592': 'ro_RO.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001336 'romanian': 'ro_RO.ISO8859-2',
1337 'ru': 'ru_RU.ISO8859-5',
1338 'ru_ru': 'ru_RU.ISO8859-5',
1339 'ru_ru.cp1251': 'ru_RU.CP1251',
1340 'ru_ru.iso88595': 'ru_RU.ISO8859-5',
1341 'ru_ru.koi8r': 'ru_RU.KOI8-R',
1342 'ru_ru.microsoftcp1251': 'ru_RU.CP1251',
1343 'ru_ua': 'ru_UA.KOI8-U',
1344 'ru_ua.cp1251': 'ru_UA.CP1251',
1345 'ru_ua.koi8u': 'ru_UA.KOI8-U',
1346 'ru_ua.microsoftcp1251': 'ru_UA.CP1251',
1347 'rumanian': 'ro_RO.ISO8859-2',
1348 'russian': 'ru_RU.ISO8859-5',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001349 'rw': 'rw_RW.ISO8859-1',
1350 'rw_rw': 'rw_RW.ISO8859-1',
1351 'rw_rw.iso88591': 'rw_RW.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001352 'se_no': 'se_NO.UTF-8',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001353 'serbocroatian': 'sr_CS.ISO8859-2',
1354 'sh': 'sr_CS.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001355 'sh_hr': 'sh_HR.ISO8859-2',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001356 'sh_hr.iso88592': 'hr_HR.ISO8859-2',
1357 'sh_sp': 'sr_CS.ISO8859-2',
1358 'sh_yu': 'sr_CS.ISO8859-2',
1359 'si': 'si_LK.UTF-8',
1360 'si_lk': 'si_LK.UTF-8',
1361 'sinhala': 'si_LK.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001362 'sk': 'sk_SK.ISO8859-2',
1363 'sk_sk': 'sk_SK.ISO8859-2',
1364 'sk_sk.iso88592': 'sk_SK.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001365 'sl': 'sl_SI.ISO8859-2',
1366 'sl_cs': 'sl_CS.ISO8859-2',
1367 'sl_si': 'sl_SI.ISO8859-2',
1368 'sl_si.iso88592': 'sl_SI.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001369 'slovak': 'sk_SK.ISO8859-2',
1370 'slovene': 'sl_SI.ISO8859-2',
1371 'slovenian': 'sl_SI.ISO8859-2',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001372 'sp': 'sr_CS.ISO8859-5',
1373 'sp_yu': 'sr_CS.ISO8859-5',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001374 'spanish': 'es_ES.ISO8859-1',
1375 'spanish.iso88591': 'es_ES.ISO8859-1',
1376 'spanish_spain': 'es_ES.ISO8859-1',
1377 'spanish_spain.8859': 'es_ES.ISO8859-1',
1378 'sq': 'sq_AL.ISO8859-2',
1379 'sq_al': 'sq_AL.ISO8859-2',
1380 'sq_al.iso88592': 'sq_AL.ISO8859-2',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001381 'sr': 'sr_CS.ISO8859-5',
1382 'sr@cyrillic': 'sr_CS.ISO8859-5',
1383 'sr@latn': 'sr_CS.ISO8859-2',
1384 'sr_cs.iso88592': 'sr_CS.ISO8859-2',
1385 'sr_cs.iso88592@latn': 'sr_CS.ISO8859-2',
1386 'sr_cs.iso88595': 'sr_CS.ISO8859-5',
1387 'sr_cs.utf8@latn': 'sr_CS.UTF-8',
1388 'sr_cs@latn': 'sr_CS.ISO8859-2',
1389 'sr_sp': 'sr_CS.ISO8859-2',
1390 'sr_yu': 'sr_CS.ISO8859-5',
1391 'sr_yu.cp1251@cyrillic': 'sr_CS.CP1251',
1392 'sr_yu.iso88592': 'sr_CS.ISO8859-2',
1393 'sr_yu.iso88595': 'sr_CS.ISO8859-5',
1394 'sr_yu.iso88595@cyrillic': 'sr_CS.ISO8859-5',
1395 'sr_yu.microsoftcp1251@cyrillic': 'sr_CS.CP1251',
1396 'sr_yu.utf8@cyrillic': 'sr_CS.UTF-8',
1397 'sr_yu@cyrillic': 'sr_CS.ISO8859-5',
1398 'ss': 'ss_ZA.ISO8859-1',
1399 'ss_za': 'ss_ZA.ISO8859-1',
1400 'ss_za.iso88591': 'ss_ZA.ISO8859-1',
1401 'st': 'st_ZA.ISO8859-1',
1402 'st_za': 'st_ZA.ISO8859-1',
1403 'st_za.iso88591': 'st_ZA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001404 'sv': 'sv_SE.ISO8859-1',
1405 'sv_fi': 'sv_FI.ISO8859-1',
1406 'sv_fi.iso88591': 'sv_FI.ISO8859-1',
1407 'sv_fi.iso885915': 'sv_FI.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001408 'sv_fi.iso885915@euro': 'sv_FI.ISO8859-15',
1409 'sv_fi.utf8@euro': 'sv_FI.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001410 'sv_fi@euro': 'sv_FI.ISO8859-15',
1411 'sv_se': 'sv_SE.ISO8859-1',
1412 'sv_se.88591': 'sv_SE.ISO8859-1',
1413 'sv_se.iso88591': 'sv_SE.ISO8859-1',
1414 'sv_se.iso885915': 'sv_SE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001415 'sv_se@euro': 'sv_SE.ISO8859-15',
1416 'swedish': 'sv_SE.ISO8859-1',
1417 'swedish.iso88591': 'sv_SE.ISO8859-1',
1418 'ta': 'ta_IN.TSCII-0',
1419 'ta_in': 'ta_IN.TSCII-0',
1420 'ta_in.tscii': 'ta_IN.TSCII-0',
1421 'ta_in.tscii0': 'ta_IN.TSCII-0',
1422 'tg': 'tg_TJ.KOI8-C',
1423 'tg_tj': 'tg_TJ.KOI8-C',
1424 'tg_tj.koi8c': 'tg_TJ.KOI8-C',
1425 'th': 'th_TH.ISO8859-11',
1426 'th_th': 'th_TH.ISO8859-11',
1427 'th_th.iso885911': 'th_TH.ISO8859-11',
1428 'th_th.tactis': 'th_TH.TIS620',
1429 'th_th.tis620': 'th_TH.TIS620',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001430 'thai': 'th_TH.ISO8859-11',
1431 'tl': 'tl_PH.ISO8859-1',
1432 'tl_ph': 'tl_PH.ISO8859-1',
1433 'tl_ph.iso88591': 'tl_PH.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001434 'tn': 'tn_ZA.ISO8859-15',
1435 'tn_za': 'tn_ZA.ISO8859-15',
1436 'tn_za.iso885915': 'tn_ZA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001437 'tr': 'tr_TR.ISO8859-9',
1438 'tr_tr': 'tr_TR.ISO8859-9',
1439 'tr_tr.iso88599': 'tr_TR.ISO8859-9',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001440 'ts': 'ts_ZA.ISO8859-1',
1441 'ts_za': 'ts_ZA.ISO8859-1',
1442 'ts_za.iso88591': 'ts_ZA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001443 'tt': 'tt_RU.TATAR-CYR',
1444 'tt_ru': 'tt_RU.TATAR-CYR',
1445 'tt_ru.koi8c': 'tt_RU.KOI8-C',
1446 'tt_ru.tatarcyr': 'tt_RU.TATAR-CYR',
1447 'turkish': 'tr_TR.ISO8859-9',
1448 'turkish.iso88599': 'tr_TR.ISO8859-9',
1449 'uk': 'uk_UA.KOI8-U',
1450 'uk_ua': 'uk_UA.KOI8-U',
1451 'uk_ua.cp1251': 'uk_UA.CP1251',
1452 'uk_ua.iso88595': 'uk_UA.ISO8859-5',
1453 'uk_ua.koi8u': 'uk_UA.KOI8-U',
1454 'uk_ua.microsoftcp1251': 'uk_UA.CP1251',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001455 'univ': 'en_US.utf',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001456 'universal': 'en_US.utf',
1457 'universal.utf8@ucs4': 'en_US.UTF-8',
1458 'ur': 'ur_PK.CP1256',
1459 'ur_pk': 'ur_PK.CP1256',
1460 'ur_pk.cp1256': 'ur_PK.CP1256',
1461 'ur_pk.microsoftcp1256': 'ur_PK.CP1256',
1462 'uz': 'uz_UZ.UTF-8',
1463 'uz_uz': 'uz_UZ.UTF-8',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001464 'uz_uz.iso88591': 'uz_UZ.ISO8859-1',
1465 'uz_uz.utf8@cyrillic': 'uz_UZ.UTF-8',
1466 'uz_uz@cyrillic': 'uz_UZ.UTF-8',
1467 've': 've_ZA.UTF-8',
1468 've_za': 've_ZA.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001469 'vi': 'vi_VN.TCVN',
1470 'vi_vn': 'vi_VN.TCVN',
1471 'vi_vn.tcvn': 'vi_VN.TCVN',
1472 'vi_vn.tcvn5712': 'vi_VN.TCVN',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001473 'vi_vn.viscii': 'vi_VN.VISCII',
1474 'vi_vn.viscii111': 'vi_VN.VISCII',
1475 'wa': 'wa_BE.ISO8859-1',
1476 'wa_be': 'wa_BE.ISO8859-1',
1477 'wa_be.iso88591': 'wa_BE.ISO8859-1',
1478 'wa_be.iso885915': 'wa_BE.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001479 'wa_be.iso885915@euro': 'wa_BE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001480 'wa_be@euro': 'wa_BE.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001481 'xh': 'xh_ZA.ISO8859-1',
1482 'xh_za': 'xh_ZA.ISO8859-1',
1483 'xh_za.iso88591': 'xh_ZA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001484 'yi': 'yi_US.CP1255',
1485 'yi_us': 'yi_US.CP1255',
1486 'yi_us.cp1255': 'yi_US.CP1255',
1487 'yi_us.microsoftcp1255': 'yi_US.CP1255',
1488 'zh': 'zh_CN.eucCN',
1489 'zh_cn': 'zh_CN.gb2312',
1490 'zh_cn.big5': 'zh_TW.big5',
1491 'zh_cn.euc': 'zh_CN.eucCN',
1492 'zh_cn.gb18030': 'zh_CN.gb18030',
1493 'zh_cn.gb2312': 'zh_CN.gb2312',
1494 'zh_cn.gbk': 'zh_CN.gbk',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001495 'zh_hk': 'zh_HK.big5hkscs',
1496 'zh_hk.big5': 'zh_HK.big5',
1497 'zh_hk.big5hkscs': 'zh_HK.big5hkscs',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001498 'zh_tw': 'zh_TW.big5',
1499 'zh_tw.big5': 'zh_TW.big5',
1500 'zh_tw.euc': 'zh_TW.eucTW',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001501 'zh_tw.euctw': 'zh_TW.eucTW',
1502 'zu': 'zu_ZA.ISO8859-1',
1503 'zu_za': 'zu_ZA.ISO8859-1',
1504 'zu_za.iso88591': 'zu_ZA.ISO8859-1',
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001505}
1506
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001507#
Georg Brandlb709c2c2006-01-20 09:07:35 +00001508# This maps Windows language identifiers to locale strings.
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001509#
Tim Peters777f1082006-01-20 20:03:24 +00001510# This list has been updated from
Georg Brandlb709c2c2006-01-20 09:07:35 +00001511# 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 +00001512# to include every locale up to Windows Vista.
Fredrik Lundh37a09822002-10-19 20:19:10 +00001513#
Georg Brandl5035c1c2006-01-20 13:38:26 +00001514# NOTE: this mapping is incomplete. If your language is missing, please
1515# submit a bug report to Python bug manager, which you can find via:
1516# http://www.python.org/dev/
1517# Make sure you include the missing language identifier and the suggested
1518# locale code.
1519#
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001520
1521windows_locale = {
Georg Brandlb709c2c2006-01-20 09:07:35 +00001522 0x0436: "af_ZA", # Afrikaans
1523 0x041c: "sq_AL", # Albanian
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001524 0x0484: "gsw_FR",# Alsatian - France
1525 0x045e: "am_ET", # Amharic - Ethiopia
Georg Brandlb709c2c2006-01-20 09:07:35 +00001526 0x0401: "ar_SA", # Arabic - Saudi Arabia
1527 0x0801: "ar_IQ", # Arabic - Iraq
1528 0x0c01: "ar_EG", # Arabic - Egypt
1529 0x1001: "ar_LY", # Arabic - Libya
1530 0x1401: "ar_DZ", # Arabic - Algeria
1531 0x1801: "ar_MA", # Arabic - Morocco
1532 0x1c01: "ar_TN", # Arabic - Tunisia
1533 0x2001: "ar_OM", # Arabic - Oman
1534 0x2401: "ar_YE", # Arabic - Yemen
1535 0x2801: "ar_SY", # Arabic - Syria
1536 0x2c01: "ar_JO", # Arabic - Jordan
1537 0x3001: "ar_LB", # Arabic - Lebanon
1538 0x3401: "ar_KW", # Arabic - Kuwait
1539 0x3801: "ar_AE", # Arabic - United Arab Emirates
1540 0x3c01: "ar_BH", # Arabic - Bahrain
1541 0x4001: "ar_QA", # Arabic - Qatar
1542 0x042b: "hy_AM", # Armenian
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001543 0x044d: "as_IN", # Assamese - India
1544 0x042c: "az_AZ", # Azeri - Latin
Georg Brandlb709c2c2006-01-20 09:07:35 +00001545 0x082c: "az_AZ", # Azeri - Cyrillic
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001546 0x046d: "ba_RU", # Bashkir
1547 0x042d: "eu_ES", # Basque - Russia
Georg Brandlb709c2c2006-01-20 09:07:35 +00001548 0x0423: "be_BY", # Belarusian
1549 0x0445: "bn_IN", # Begali
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001550 0x201a: "bs_BA", # Bosnian - Cyrillic
1551 0x141a: "bs_BA", # Bosnian - Latin
Georg Brandlb709c2c2006-01-20 09:07:35 +00001552 0x047e: "br_FR", # Breton - France
1553 0x0402: "bg_BG", # Bulgarian
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001554# 0x0455: "my_MM", # Burmese - Not supported
Georg Brandlb709c2c2006-01-20 09:07:35 +00001555 0x0403: "ca_ES", # Catalan
1556 0x0004: "zh_CHS",# Chinese - Simplified
1557 0x0404: "zh_TW", # Chinese - Taiwan
1558 0x0804: "zh_CN", # Chinese - PRC
1559 0x0c04: "zh_HK", # Chinese - Hong Kong S.A.R.
1560 0x1004: "zh_SG", # Chinese - Singapore
1561 0x1404: "zh_MO", # Chinese - Macao S.A.R.
1562 0x7c04: "zh_CHT",# Chinese - Traditional
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001563 0x0483: "co_FR", # Corsican - France
Georg Brandlb709c2c2006-01-20 09:07:35 +00001564 0x041a: "hr_HR", # Croatian
1565 0x101a: "hr_BA", # Croatian - Bosnia
1566 0x0405: "cs_CZ", # Czech
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001567 0x0406: "da_DK", # Danish
Georg Brandlb709c2c2006-01-20 09:07:35 +00001568 0x048c: "gbz_AF",# Dari - Afghanistan
1569 0x0465: "div_MV",# Divehi - Maldives
1570 0x0413: "nl_NL", # Dutch - The Netherlands
1571 0x0813: "nl_BE", # Dutch - Belgium
1572 0x0409: "en_US", # English - United States
1573 0x0809: "en_GB", # English - United Kingdom
1574 0x0c09: "en_AU", # English - Australia
1575 0x1009: "en_CA", # English - Canada
1576 0x1409: "en_NZ", # English - New Zealand
1577 0x1809: "en_IE", # English - Ireland
1578 0x1c09: "en_ZA", # English - South Africa
1579 0x2009: "en_JA", # English - Jamaica
1580 0x2409: "en_CB", # English - Carribbean
1581 0x2809: "en_BZ", # English - Belize
1582 0x2c09: "en_TT", # English - Trinidad
1583 0x3009: "en_ZW", # English - Zimbabwe
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001584 0x3409: "en_PH", # English - Philippines
1585 0x4009: "en_IN", # English - India
1586 0x4409: "en_MY", # English - Malaysia
1587 0x4809: "en_IN", # English - Singapore
Georg Brandlb709c2c2006-01-20 09:07:35 +00001588 0x0425: "et_EE", # Estonian
1589 0x0438: "fo_FO", # Faroese
1590 0x0464: "fil_PH",# Filipino
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001591 0x040b: "fi_FI", # Finnish
Georg Brandlb709c2c2006-01-20 09:07:35 +00001592 0x040c: "fr_FR", # French - France
1593 0x080c: "fr_BE", # French - Belgium
1594 0x0c0c: "fr_CA", # French - Canada
1595 0x100c: "fr_CH", # French - Switzerland
1596 0x140c: "fr_LU", # French - Luxembourg
1597 0x180c: "fr_MC", # French - Monaco
1598 0x0462: "fy_NL", # Frisian - Netherlands
1599 0x0456: "gl_ES", # Galician
1600 0x0437: "ka_GE", # Georgian
1601 0x0407: "de_DE", # German - Germany
1602 0x0807: "de_CH", # German - Switzerland
1603 0x0c07: "de_AT", # German - Austria
1604 0x1007: "de_LU", # German - Luxembourg
1605 0x1407: "de_LI", # German - Liechtenstein
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001606 0x0408: "el_GR", # Greek
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001607 0x046f: "kl_GL", # Greenlandic - Greenland
Georg Brandlb709c2c2006-01-20 09:07:35 +00001608 0x0447: "gu_IN", # Gujarati
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001609 0x0468: "ha_NG", # Hausa - Latin
Georg Brandlb709c2c2006-01-20 09:07:35 +00001610 0x040d: "he_IL", # Hebrew
1611 0x0439: "hi_IN", # Hindi
1612 0x040e: "hu_HU", # Hungarian
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001613 0x040f: "is_IS", # Icelandic
Georg Brandlb709c2c2006-01-20 09:07:35 +00001614 0x0421: "id_ID", # Indonesian
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001615 0x045d: "iu_CA", # Inuktitut - Syllabics
Georg Brandlb709c2c2006-01-20 09:07:35 +00001616 0x085d: "iu_CA", # Inuktitut - Latin
1617 0x083c: "ga_IE", # Irish - Ireland
Georg Brandlb709c2c2006-01-20 09:07:35 +00001618 0x0410: "it_IT", # Italian - Italy
1619 0x0810: "it_CH", # Italian - Switzerland
1620 0x0411: "ja_JP", # Japanese
1621 0x044b: "kn_IN", # Kannada - India
1622 0x043f: "kk_KZ", # Kazakh
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001623 0x0453: "kh_KH", # Khmer - Cambodia
1624 0x0486: "qut_GT",# K'iche - Guatemala
1625 0x0487: "rw_RW", # Kinyarwanda - Rwanda
Georg Brandlb709c2c2006-01-20 09:07:35 +00001626 0x0457: "kok_IN",# Konkani
1627 0x0412: "ko_KR", # Korean
1628 0x0440: "ky_KG", # Kyrgyz
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001629 0x0454: "lo_LA", # Lao - Lao PDR
Georg Brandlb709c2c2006-01-20 09:07:35 +00001630 0x0426: "lv_LV", # Latvian
1631 0x0427: "lt_LT", # Lithuanian
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001632 0x082e: "dsb_DE",# Lower Sorbian - Germany
Georg Brandlb709c2c2006-01-20 09:07:35 +00001633 0x046e: "lb_LU", # Luxembourgish
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001634 0x042f: "mk_MK", # FYROM Macedonian
Georg Brandlb709c2c2006-01-20 09:07:35 +00001635 0x043e: "ms_MY", # Malay - Malaysia
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001636 0x083e: "ms_BN", # Malay - Brunei Darussalam
Georg Brandlb709c2c2006-01-20 09:07:35 +00001637 0x044c: "ml_IN", # Malayalam - India
1638 0x043a: "mt_MT", # Maltese
1639 0x0481: "mi_NZ", # Maori
1640 0x047a: "arn_CL",# Mapudungun
1641 0x044e: "mr_IN", # Marathi
1642 0x047c: "moh_CA",# Mohawk - Canada
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001643 0x0450: "mn_MN", # Mongolian - Cyrillic
1644 0x0850: "mn_CN", # Mongolian - PRC
Georg Brandlb709c2c2006-01-20 09:07:35 +00001645 0x0461: "ne_NP", # Nepali
1646 0x0414: "nb_NO", # Norwegian - Bokmal
1647 0x0814: "nn_NO", # Norwegian - Nynorsk
1648 0x0482: "oc_FR", # Occitan - France
1649 0x0448: "or_IN", # Oriya - India
1650 0x0463: "ps_AF", # Pashto - Afghanistan
1651 0x0429: "fa_IR", # Persian
1652 0x0415: "pl_PL", # Polish
1653 0x0416: "pt_BR", # Portuguese - Brazil
1654 0x0816: "pt_PT", # Portuguese - Portugal
1655 0x0446: "pa_IN", # Punjabi
1656 0x046b: "quz_BO",# Quechua (Bolivia)
1657 0x086b: "quz_EC",# Quechua (Ecuador)
1658 0x0c6b: "quz_PE",# Quechua (Peru)
1659 0x0418: "ro_RO", # Romanian - Romania
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001660 0x0417: "rm_CH", # Romansh
Georg Brandlb709c2c2006-01-20 09:07:35 +00001661 0x0419: "ru_RU", # Russian
1662 0x243b: "smn_FI",# Sami Finland
1663 0x103b: "smj_NO",# Sami Norway
1664 0x143b: "smj_SE",# Sami Sweden
1665 0x043b: "se_NO", # Sami Northern Norway
1666 0x083b: "se_SE", # Sami Northern Sweden
1667 0x0c3b: "se_FI", # Sami Northern Finland
1668 0x203b: "sms_FI",# Sami Skolt
1669 0x183b: "sma_NO",# Sami Southern Norway
1670 0x1c3b: "sma_SE",# Sami Southern Sweden
1671 0x044f: "sa_IN", # Sanskrit
1672 0x0c1a: "sr_SP", # Serbian - Cyrillic
1673 0x1c1a: "sr_BA", # Serbian - Bosnia Cyrillic
1674 0x081a: "sr_SP", # Serbian - Latin
1675 0x181a: "sr_BA", # Serbian - Bosnia Latin
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001676 0x045b: "si_LK", # Sinhala - Sri Lanka
Georg Brandlb709c2c2006-01-20 09:07:35 +00001677 0x046c: "ns_ZA", # Northern Sotho
1678 0x0432: "tn_ZA", # Setswana - Southern Africa
1679 0x041b: "sk_SK", # Slovak
1680 0x0424: "sl_SI", # Slovenian
1681 0x040a: "es_ES", # Spanish - Spain
1682 0x080a: "es_MX", # Spanish - Mexico
1683 0x0c0a: "es_ES", # Spanish - Spain (Modern)
1684 0x100a: "es_GT", # Spanish - Guatemala
1685 0x140a: "es_CR", # Spanish - Costa Rica
1686 0x180a: "es_PA", # Spanish - Panama
1687 0x1c0a: "es_DO", # Spanish - Dominican Republic
1688 0x200a: "es_VE", # Spanish - Venezuela
1689 0x240a: "es_CO", # Spanish - Colombia
1690 0x280a: "es_PE", # Spanish - Peru
1691 0x2c0a: "es_AR", # Spanish - Argentina
1692 0x300a: "es_EC", # Spanish - Ecuador
1693 0x340a: "es_CL", # Spanish - Chile
1694 0x380a: "es_UR", # Spanish - Uruguay
1695 0x3c0a: "es_PY", # Spanish - Paraguay
1696 0x400a: "es_BO", # Spanish - Bolivia
1697 0x440a: "es_SV", # Spanish - El Salvador
1698 0x480a: "es_HN", # Spanish - Honduras
1699 0x4c0a: "es_NI", # Spanish - Nicaragua
1700 0x500a: "es_PR", # Spanish - Puerto Rico
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001701 0x540a: "es_US", # Spanish - United States
1702# 0x0430: "", # Sutu - Not supported
Georg Brandlb709c2c2006-01-20 09:07:35 +00001703 0x0441: "sw_KE", # Swahili
1704 0x041d: "sv_SE", # Swedish - Sweden
1705 0x081d: "sv_FI", # Swedish - Finland
1706 0x045a: "syr_SY",# Syriac
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001707 0x0428: "tg_TJ", # Tajik - Cyrillic
1708 0x085f: "tmz_DZ",# Tamazight - Latin
Georg Brandlb709c2c2006-01-20 09:07:35 +00001709 0x0449: "ta_IN", # Tamil
1710 0x0444: "tt_RU", # Tatar
1711 0x044a: "te_IN", # Telugu
1712 0x041e: "th_TH", # Thai
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001713 0x0851: "bo_BT", # Tibetan - Bhutan
1714 0x0451: "bo_CN", # Tibetan - PRC
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001715 0x041f: "tr_TR", # Turkish
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001716 0x0442: "tk_TM", # Turkmen - Cyrillic
1717 0x0480: "ug_CN", # Uighur - Arabic
Georg Brandlb709c2c2006-01-20 09:07:35 +00001718 0x0422: "uk_UA", # Ukrainian
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001719 0x042e: "wen_DE",# Upper Sorbian - Germany
Georg Brandlb709c2c2006-01-20 09:07:35 +00001720 0x0420: "ur_PK", # Urdu
1721 0x0820: "ur_IN", # Urdu - India
1722 0x0443: "uz_UZ", # Uzbek - Latin
1723 0x0843: "uz_UZ", # Uzbek - Cyrillic
1724 0x042a: "vi_VN", # Vietnamese
1725 0x0452: "cy_GB", # Welsh
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001726 0x0488: "wo_SN", # Wolof - Senegal
1727 0x0434: "xh_ZA", # Xhosa - South Africa
1728 0x0485: "sah_RU",# Yakut - Cyrillic
1729 0x0478: "ii_CN", # Yi - PRC
1730 0x046a: "yo_NG", # Yoruba - Nigeria
1731 0x0435: "zu_ZA", # Zulu
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001732}
1733
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001734def _print_locale():
1735
1736 """ Test function.
1737 """
1738 categories = {}
1739 def _init_categories(categories=categories):
1740 for k,v in globals().items():
1741 if k[:3] == 'LC_':
1742 categories[k] = v
1743 _init_categories()
1744 del categories['LC_ALL']
1745
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001746 print('Locale defaults as determined by getdefaultlocale():')
1747 print('-'*72)
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001748 lang, enc = getdefaultlocale()
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001749 print('Language: ', lang or '(undefined)')
1750 print('Encoding: ', enc or '(undefined)')
1751 print()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001752
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001753 print('Locale settings on startup:')
1754 print('-'*72)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001755 for name,category in categories.items():
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001756 print(name, '...')
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001757 lang, enc = getlocale(category)
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001758 print(' Language: ', lang or '(undefined)')
1759 print(' Encoding: ', enc or '(undefined)')
1760 print()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001761
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001762 print()
1763 print('Locale settings after calling resetlocale():')
1764 print('-'*72)
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001765 resetlocale()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001766 for name,category in categories.items():
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001767 print(name, '...')
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001768 lang, enc = getlocale(category)
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001769 print(' Language: ', lang or '(undefined)')
1770 print(' Encoding: ', enc or '(undefined)')
1771 print()
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001772
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001773 try:
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001774 setlocale(LC_ALL, "")
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001775 except:
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001776 print('NOTE:')
1777 print('setlocale(LC_ALL, "") does not support the default locale')
1778 print('given in the OS environment variables.')
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001779 else:
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001780 print()
1781 print('Locale settings after calling setlocale(LC_ALL, ""):')
1782 print('-'*72)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001783 for name,category in categories.items():
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001784 print(name, '...')
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001785 lang, enc = getlocale(category)
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001786 print(' Language: ', lang or '(undefined)')
1787 print(' Encoding: ', enc or '(undefined)')
1788 print()
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001789
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001790###
Guido van Rossumeef1d4e1997-11-19 19:01:43 +00001791
Tim Peters1baf8292001-01-24 10:13:46 +00001792try:
1793 LC_MESSAGES
Skip Montanaro0897f0c2002-03-25 21:40:36 +00001794except NameError:
Tim Peters1baf8292001-01-24 10:13:46 +00001795 pass
1796else:
1797 __all__.append("LC_MESSAGES")
1798
Guido van Rossumeef1d4e1997-11-19 19:01:43 +00001799if __name__=='__main__':
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001800 print('Locale aliasing:')
1801 print()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001802 _print_locale()
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001803 print()
1804 print('Number formatting:')
1805 print()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001806 _test()