blob: 074f6e02fafaaaaf257ccfe62ce8ee66b1ce6431 [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
Brett Cannoncd171c82013-07-04 17:43:24 -040050except ImportError:
Marc-André Lemburg23481142000-06-08 17:49:41 +000051
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
Antoine Pitroub64bca92014-10-23 22:52:31 +0200304def delocalize(string):
305 "Parses a string as a normalized number according to the locale settings."
Victor Stinner2753a092015-11-03 14:34:51 +0100306
307 conv = localeconv()
308
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000309 #First, get rid of the grouping
Victor Stinner2753a092015-11-03 14:34:51 +0100310 ts = conv['thousands_sep']
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000311 if ts:
Skip Montanaro249369c2004-04-10 16:39:32 +0000312 string = string.replace(ts, '')
Victor Stinner2753a092015-11-03 14:34:51 +0100313
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000314 #next, replace the decimal point with a dot
Victor Stinner2753a092015-11-03 14:34:51 +0100315 dd = conv['decimal_point']
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000316 if dd:
Skip Montanaro249369c2004-04-10 16:39:32 +0000317 string = string.replace(dd, '.')
Antoine Pitroub64bca92014-10-23 22:52:31 +0200318 return string
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000319
Antoine Pitroub64bca92014-10-23 22:52:31 +0200320def atof(string, func=float):
321 "Parses a string as a float according to the locale settings."
322 return func(delocalize(string))
323
324def atoi(string):
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000325 "Converts a string to an integer according to the locale settings."
Antoine Pitroub64bca92014-10-23 22:52:31 +0200326 return int(delocalize(string))
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000327
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000328def _test():
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000329 setlocale(LC_ALL, "")
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000330 #do grouping
Thomas Wouters477c8d52006-05-27 19:21:47 +0000331 s1 = format("%d", 123456789,1)
Guido van Rossumbe19ed72007-02-09 05:37:30 +0000332 print(s1, "is", atoi(s1))
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000333 #standard formatting
Thomas Wouters477c8d52006-05-27 19:21:47 +0000334 s1 = str(3.14)
Guido van Rossumbe19ed72007-02-09 05:37:30 +0000335 print(s1, "is", atof(s1))
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000336
337### Locale name aliasing engine
338
339# Author: Marc-Andre Lemburg, mal@lemburg.com
Fredrik Lundh37a09822002-10-19 20:19:10 +0000340# Various tweaks by Fredrik Lundh <fredrik@pythonware.com>
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000341
342# store away the low-level version of setlocale (it's
343# overridden below)
344_setlocale = setlocale
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000345
Serhiy Storchaka16f02d22013-12-19 21:21:40 +0200346def _replace_encoding(code, encoding):
347 if '.' in code:
348 langname = code[:code.index('.')]
349 else:
350 langname = code
351 # Convert the encoding to a C lib compatible encoding string
352 norm_encoding = encodings.normalize_encoding(encoding)
353 #print('norm encoding: %r' % norm_encoding)
Serhiy Storchaka8c4f57d2013-12-27 00:56:53 +0200354 norm_encoding = encodings.aliases.aliases.get(norm_encoding.lower(),
Serhiy Storchaka16f02d22013-12-19 21:21:40 +0200355 norm_encoding)
356 #print('aliased encoding: %r' % norm_encoding)
Serhiy Storchaka8c4f57d2013-12-27 00:56:53 +0200357 encoding = norm_encoding
358 norm_encoding = norm_encoding.lower()
359 if norm_encoding in locale_encoding_alias:
360 encoding = locale_encoding_alias[norm_encoding]
361 else:
362 norm_encoding = norm_encoding.replace('_', '')
363 norm_encoding = norm_encoding.replace('-', '')
364 if norm_encoding in locale_encoding_alias:
365 encoding = locale_encoding_alias[norm_encoding]
Serhiy Storchaka16f02d22013-12-19 21:21:40 +0200366 #print('found encoding %r' % encoding)
367 return langname + '.' + encoding
368
Serhiy Storchaka8c4f57d2013-12-27 00:56:53 +0200369def _append_modifier(code, modifier):
370 if modifier == 'euro':
371 if '.' not in code:
372 return code + '.ISO8859-15'
373 _, _, encoding = code.partition('.')
374 if encoding in ('ISO8859-15', 'UTF-8'):
375 return code
376 if encoding == 'ISO8859-1':
377 return _replace_encoding(code, 'ISO8859-15')
378 return code + '@' + modifier
379
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000380def normalize(localename):
381
382 """ Returns a normalized locale code for the given locale
383 name.
384
385 The returned locale code is formatted for use with
386 setlocale().
387
388 If normalization fails, the original name is returned
389 unchanged.
390
391 If the given encoding is not known, the function defaults to
392 the default encoding for the locale code just like setlocale()
393 does.
394
395 """
Serhiy Storchaka16f02d22013-12-19 21:21:40 +0200396 # Normalize the locale name and extract the encoding and modifier
397 code = localename.lower()
398 if ':' in code:
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000399 # ':' is sometimes used as encoding delimiter.
Serhiy Storchaka16f02d22013-12-19 21:21:40 +0200400 code = code.replace(':', '.')
401 if '@' in code:
402 code, modifier = code.split('@', 1)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000403 else:
Serhiy Storchaka16f02d22013-12-19 21:21:40 +0200404 modifier = ''
405 if '.' in code:
406 langname, encoding = code.split('.')[:2]
407 else:
408 langname = code
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000409 encoding = ''
410
Serhiy Storchaka16f02d22013-12-19 21:21:40 +0200411 # First lookup: fullname (possibly with encoding and modifier)
412 lang_enc = langname
413 if encoding:
414 norm_encoding = encoding.replace('-', '')
415 norm_encoding = norm_encoding.replace('_', '')
416 lang_enc += '.' + norm_encoding
417 lookup_name = lang_enc
418 if modifier:
419 lookup_name += '@' + modifier
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000420 code = locale_alias.get(lookup_name, None)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000421 if code is not None:
422 return code
Serhiy Storchaka16f02d22013-12-19 21:21:40 +0200423 #print('first lookup failed')
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000424
Serhiy Storchaka16f02d22013-12-19 21:21:40 +0200425 if modifier:
426 # Second try: fullname without modifier (possibly with encoding)
427 code = locale_alias.get(lang_enc, None)
428 if code is not None:
429 #print('lookup without modifier succeeded')
430 if '@' not in code:
Serhiy Storchaka8c4f57d2013-12-27 00:56:53 +0200431 return _append_modifier(code, modifier)
Serhiy Storchaka16f02d22013-12-19 21:21:40 +0200432 if code.split('@', 1)[1].lower() == modifier:
433 return code
434 #print('second lookup failed')
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000435
Serhiy Storchaka16f02d22013-12-19 21:21:40 +0200436 if encoding:
437 # Third try: langname (without encoding, possibly with modifier)
438 lookup_name = langname
439 if modifier:
440 lookup_name += '@' + modifier
441 code = locale_alias.get(lookup_name, None)
442 if code is not None:
443 #print('lookup without encoding succeeded')
444 if '@' not in code:
445 return _replace_encoding(code, encoding)
446 code, modifier = code.split('@', 1)
447 return _replace_encoding(code, encoding) + '@' + modifier
448
449 if modifier:
450 # Fourth try: langname (without encoding and modifier)
451 code = locale_alias.get(langname, None)
452 if code is not None:
453 #print('lookup without modifier and encoding succeeded')
454 if '@' not in code:
Serhiy Storchaka8c4f57d2013-12-27 00:56:53 +0200455 code = _replace_encoding(code, encoding)
456 return _append_modifier(code, modifier)
Serhiy Storchaka16f02d22013-12-19 21:21:40 +0200457 code, defmod = code.split('@', 1)
458 if defmod.lower() == modifier:
459 return _replace_encoding(code, encoding) + '@' + defmod
460
461 return localename
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000462
463def _parse_localename(localename):
464
465 """ Parses the locale code for localename and returns the
466 result as tuple (language code, encoding).
467
468 The localename is normalized and passed through the locale
469 alias engine. A ValueError is raised in case the locale name
470 cannot be parsed.
471
472 The language code corresponds to RFC 1766. code and encoding
473 can be None in case the values cannot be determined or are
Jeremy Hyltona05e2932000-06-28 14:48:01 +0000474 unknown to this implementation.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000475
476 """
477 code = normalize(localename)
Georg Brandlb709c2c2006-01-20 09:07:35 +0000478 if '@' in code:
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000479 # Deal with locale modifiers
Serhiy Storchaka16f02d22013-12-19 21:21:40 +0200480 code, modifier = code.split('@', 1)
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000481 if modifier == 'euro' and '.' not in code:
482 # Assume Latin-9 for @euro locales. This is bogus,
483 # since some systems may use other encodings for these
484 # locales. Also, we ignore other modifiers.
485 return code, 'iso-8859-15'
Tim Peters230a60c2002-11-09 05:08:07 +0000486
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000487 if '.' in code:
Raymond Hettinger346e67f2005-01-01 06:10:26 +0000488 return tuple(code.split('.')[:2])
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000489 elif code == 'C':
490 return None, None
Collin Winterce36ad82007-08-30 01:19:48 +0000491 raise ValueError('unknown locale: %s' % localename)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000492
493def _build_localename(localetuple):
494
495 """ Builds a locale code from the given tuple (language code,
496 encoding).
497
498 No aliasing or normalizing takes place.
499
500 """
Petri Lehtinen3c85fe02011-11-04 21:35:07 +0200501 try:
502 language, encoding = localetuple
503
504 if language is None:
505 language = 'C'
506 if encoding is None:
507 return language
508 else:
509 return language + '.' + encoding
510 except (TypeError, ValueError):
511 raise TypeError('Locale must be None, a string, or an iterable of two strings -- language code, encoding.')
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000512
Matthias Klosef3f231f2005-09-20 07:02:49 +0000513def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000514
515 """ Tries to determine the default locale settings and returns
516 them as tuple (language code, encoding).
517
518 According to POSIX, a program which has not called
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000519 setlocale(LC_ALL, "") runs using the portable 'C' locale.
520 Calling setlocale(LC_ALL, "") lets it use the default locale as
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000521 defined by the LANG variable. Since we don't want to interfere
Thomas Wouters7e474022000-07-16 12:04:32 +0000522 with the current locale setting we thus emulate the behavior
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000523 in the way described above.
524
525 To maintain compatibility with other platforms, not only the
526 LANG variable is tested, but a list of variables given as
527 envvars parameter. The first found to be defined will be
528 used. envvars defaults to the search path used in GNU gettext;
529 it must always contain the variable name 'LANG'.
530
531 Except for the code 'C', the language code corresponds to RFC
532 1766. code and encoding can be None in case the values cannot
533 be determined.
534
535 """
Fredrik Lundh04661322000-07-09 23:16:10 +0000536
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000537 try:
538 # check if it's supported by the _locale module
539 import _locale
540 code, encoding = _locale._getdefaultlocale()
Fredrik Lundh04661322000-07-09 23:16:10 +0000541 except (ImportError, AttributeError):
542 pass
543 else:
Fredrik Lundh663809e2000-07-10 19:32:19 +0000544 # make sure the code/encoding values are valid
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000545 if sys.platform == "win32" and code and code[:2] == "0x":
546 # map windows language identifier to language name
547 code = windows_locale.get(int(code, 0))
Fredrik Lundh663809e2000-07-10 19:32:19 +0000548 # ...add other platform-specific processing here, if
549 # necessary...
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000550 return code, encoding
Fredrik Lundh04661322000-07-09 23:16:10 +0000551
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000552 # fall back on POSIX behaviour
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000553 import os
554 lookup = os.environ.get
555 for variable in envvars:
556 localename = lookup(variable,None)
Martin v. Löwisc8ae31d2004-07-26 12:45:18 +0000557 if localename:
Matthias Klosef3f231f2005-09-20 07:02:49 +0000558 if variable == 'LANGUAGE':
559 localename = localename.split(':')[0]
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000560 break
561 else:
562 localename = 'C'
563 return _parse_localename(localename)
564
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000565
566def getlocale(category=LC_CTYPE):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000567
568 """ Returns the current setting for the given locale category as
569 tuple (language code, encoding).
570
571 category may be one of the LC_* value except LC_ALL. It
572 defaults to LC_CTYPE.
573
574 Except for the code 'C', the language code corresponds to RFC
575 1766. code and encoding can be None in case the values cannot
576 be determined.
577
578 """
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000579 localename = _setlocale(category)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000580 if category == LC_ALL and ';' in localename:
Collin Winterce36ad82007-08-30 01:19:48 +0000581 raise TypeError('category LC_ALL is not supported')
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000582 return _parse_localename(localename)
583
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000584def setlocale(category, locale=None):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000585
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000586 """ Set the locale for the given category. The locale can be
Petri Lehtinen395ca722011-11-05 10:18:50 +0200587 a string, an iterable of two strings (language code and encoding),
588 or None.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000589
Petri Lehtinen395ca722011-11-05 10:18:50 +0200590 Iterables are converted to strings using the locale aliasing
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000591 engine. Locale strings are passed directly to the C lib.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000592
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000593 category may be given as one of the LC_* values.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000594
595 """
Guido van Rossum3172c5d2007-10-16 18:12:55 +0000596 if locale and not isinstance(locale, _builtin_str):
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000597 # convert to string
598 locale = normalize(_build_localename(locale))
599 return _setlocale(category, locale)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000600
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000601def resetlocale(category=LC_ALL):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000602
603 """ Sets the locale for category to the default setting.
604
605 The default setting is determined by calling
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000606 getdefaultlocale(). category defaults to LC_ALL.
607
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000608 """
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000609 _setlocale(category, _build_localename(getdefaultlocale()))
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000610
Ronald Oussorenfe8a3d62009-06-07 15:29:46 +0000611if sys.platform.startswith("win"):
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000612 # On Win32, this will return the ANSI code page
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000613 def getpreferredencoding(do_setlocale = True):
614 """Return the charset that the user is likely using."""
Antoine Pitroufd4722c2013-10-12 00:13:50 +0200615 import _bootlocale
616 return _bootlocale.getpreferredencoding(False)
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000617else:
618 # On Unix, if CODESET is available, use that.
619 try:
620 CODESET
621 except NameError:
622 # Fall back to parsing environment variables :-(
623 def getpreferredencoding(do_setlocale = True):
624 """Return the charset that the user is likely using,
625 by looking at environment variables."""
Martin v. Löwis071ef772008-03-08 11:24:24 +0000626 res = getdefaultlocale()[1]
627 if res is None:
628 # LANG not set, default conservatively to ASCII
629 res = 'ascii'
630 return res
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000631 else:
632 def getpreferredencoding(do_setlocale = True):
633 """Return the charset that the user is likely using,
634 according to the system configuration."""
Antoine Pitroufd4722c2013-10-12 00:13:50 +0200635 import _bootlocale
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000636 if do_setlocale:
637 oldloc = setlocale(LC_CTYPE)
Jeroen Ruigrok van der Wervenbcf85062009-05-06 05:33:24 +0000638 try:
639 setlocale(LC_CTYPE, "")
Jeroen Ruigrok van der Werven6ca2e0a2009-05-06 13:18:35 +0000640 except Error:
Jeroen Ruigrok van der Wervenbcf85062009-05-06 05:33:24 +0000641 pass
Antoine Pitroufd4722c2013-10-12 00:13:50 +0200642 result = _bootlocale.getpreferredencoding(False)
643 if do_setlocale:
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000644 setlocale(LC_CTYPE, oldloc)
Antoine Pitrou6a448d42009-10-19 19:43:09 +0000645 return result
Tim Peters230a60c2002-11-09 05:08:07 +0000646
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000647
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000648### Database
649#
650# The following data was extracted from the locale.alias file which
651# comes with X11 and then hand edited removing the explicit encoding
652# definitions and adding some more aliases. The file is usually
653# available as /usr/lib/X11/locale/locale.alias.
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000654#
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000655
656#
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000657# The local_encoding_alias table maps lowercase encoding alias names
658# to C locale encoding names (case-sensitive). Note that normalize()
659# first looks up the encoding in the encodings.aliases dictionary and
660# then applies this mapping to find the correct C lib name for the
661# encoding.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000662#
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000663locale_encoding_alias = {
664
665 # Mappings for non-standard encoding names used in locale names
666 '437': 'C',
667 'c': 'C',
668 'en': 'ISO8859-1',
669 'jis': 'JIS7',
670 'jis7': 'JIS7',
671 'ajec': 'eucJP',
Serhiy Storchaka8c4f57d2013-12-27 00:56:53 +0200672 'koi8c': 'KOI8-C',
673 'microsoftcp1251': 'CP1251',
674 'microsoftcp1255': 'CP1255',
675 'microsoftcp1256': 'CP1256',
676 '88591': 'ISO8859-1',
677 '88592': 'ISO8859-2',
678 '88595': 'ISO8859-5',
679 '885915': 'ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000680
681 # Mappings from Python codec names to C lib encoding names
682 'ascii': 'ISO8859-1',
683 'latin_1': 'ISO8859-1',
684 'iso8859_1': 'ISO8859-1',
685 'iso8859_10': 'ISO8859-10',
686 'iso8859_11': 'ISO8859-11',
687 'iso8859_13': 'ISO8859-13',
688 'iso8859_14': 'ISO8859-14',
689 'iso8859_15': 'ISO8859-15',
Jeroen Ruigrok van der Werven4072ff32009-05-08 14:17:00 +0000690 'iso8859_16': 'ISO8859-16',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000691 'iso8859_2': 'ISO8859-2',
692 'iso8859_3': 'ISO8859-3',
693 'iso8859_4': 'ISO8859-4',
694 'iso8859_5': 'ISO8859-5',
695 'iso8859_6': 'ISO8859-6',
696 'iso8859_7': 'ISO8859-7',
697 'iso8859_8': 'ISO8859-8',
698 'iso8859_9': 'ISO8859-9',
699 'iso2022_jp': 'JIS7',
700 'shift_jis': 'SJIS',
701 'tactis': 'TACTIS',
702 'euc_jp': 'eucJP',
703 'euc_kr': 'eucKR',
Ronald Oussoren02a67ac2011-05-17 12:44:54 +0200704 'utf_8': 'UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000705 'koi8_r': 'KOI8-R',
Serhiy Storchakaf0eeedf2015-05-12 23:24:19 +0300706 'koi8_t': 'KOI8-T',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000707 'koi8_u': 'KOI8-U',
Serhiy Storchakaad8a1c32015-05-12 23:16:55 +0300708 'kz1048': 'RK1048',
Serhiy Storchaka8c4f57d2013-12-27 00:56:53 +0200709 'cp1251': 'CP1251',
710 'cp1255': 'CP1255',
711 'cp1256': 'CP1256',
712
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000713 # XXX This list is still incomplete. If you know more
714 # mappings, please file a bug report. Thanks.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000715}
716
Serhiy Storchaka8c4f57d2013-12-27 00:56:53 +0200717for k, v in sorted(locale_encoding_alias.items()):
718 k = k.replace('_', '')
719 locale_encoding_alias.setdefault(k, v)
720
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000721#
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000722# The locale_alias table maps lowercase alias names to C locale names
723# (case-sensitive). Encodings are always separated from the locale
724# name using a dot ('.'); they should only be given in case the
725# language name is needed to interpret the given encoding alias
726# correctly (CJK codes often have this need).
727#
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000728# Note that the normalize() function which uses this tables
729# removes '_' and '-' characters from the encoding part of the
730# locale name before doing the lookup. This saves a lot of
731# space in the table.
732#
733# MAL 2004-12-10:
734# Updated alias mapping to most recent locale.alias file
735# from X.org distribution using makelocalealias.py.
736#
737# These are the differences compared to the old mapping (Python 2.4
738# and older):
739#
740# updated 'bg' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
741# updated 'bg_bg' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
742# updated 'bulgarian' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
743# updated 'cz' -> 'cz_CZ.ISO8859-2' to 'cs_CZ.ISO8859-2'
744# updated 'cz_cz' -> 'cz_CZ.ISO8859-2' to 'cs_CZ.ISO8859-2'
745# updated 'czech' -> 'cs_CS.ISO8859-2' to 'cs_CZ.ISO8859-2'
746# updated 'dutch' -> 'nl_BE.ISO8859-1' to 'nl_NL.ISO8859-1'
747# updated 'et' -> 'et_EE.ISO8859-4' to 'et_EE.ISO8859-15'
748# updated 'et_ee' -> 'et_EE.ISO8859-4' to 'et_EE.ISO8859-15'
749# updated 'fi' -> 'fi_FI.ISO8859-1' to 'fi_FI.ISO8859-15'
750# updated 'fi_fi' -> 'fi_FI.ISO8859-1' to 'fi_FI.ISO8859-15'
751# updated 'iw' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
752# updated 'iw_il' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
753# updated 'japanese' -> 'ja_JP.SJIS' to 'ja_JP.eucJP'
754# updated 'lt' -> 'lt_LT.ISO8859-4' to 'lt_LT.ISO8859-13'
755# updated 'lv' -> 'lv_LV.ISO8859-4' to 'lv_LV.ISO8859-13'
756# updated 'sl' -> 'sl_CS.ISO8859-2' to 'sl_SI.ISO8859-2'
757# updated 'slovene' -> 'sl_CS.ISO8859-2' to 'sl_SI.ISO8859-2'
758# updated 'th_th' -> 'th_TH.TACTIS' to 'th_TH.ISO8859-11'
759# updated 'zh_cn' -> 'zh_CN.eucCN' to 'zh_CN.gb2312'
760# updated 'zh_cn.big5' -> 'zh_TW.eucTW' to 'zh_TW.big5'
761# updated 'zh_tw' -> 'zh_TW.eucTW' to 'zh_TW.big5'
762#
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000763# MAL 2008-05-30:
764# Updated alias mapping to most recent locale.alias file
765# from X.org distribution using makelocalealias.py.
766#
767# These are the differences compared to the old mapping (Python 2.5
768# and older):
769#
770# updated 'cs_cs.iso88592' -> 'cs_CZ.ISO8859-2' to 'cs_CS.ISO8859-2'
771# updated 'serbocroatian' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
772# updated 'sh' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
773# updated 'sh_hr.iso88592' -> 'sh_HR.ISO8859-2' to 'hr_HR.ISO8859-2'
774# updated 'sh_sp' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
775# updated 'sh_yu' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
776# updated 'sp' -> 'sp_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
777# updated 'sp_yu' -> 'sp_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
778# updated 'sr' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
779# updated 'sr@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
780# updated 'sr_sp' -> 'sr_SP.ISO8859-2' to 'sr_CS.ISO8859-2'
781# updated 'sr_yu' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
782# updated 'sr_yu.cp1251@cyrillic' -> 'sr_YU.CP1251' to 'sr_CS.CP1251'
783# updated 'sr_yu.iso88592' -> 'sr_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
784# updated 'sr_yu.iso88595' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
785# updated 'sr_yu.iso88595@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
786# updated 'sr_yu.microsoftcp1251@cyrillic' -> 'sr_YU.CP1251' to 'sr_CS.CP1251'
787# updated 'sr_yu.utf8@cyrillic' -> 'sr_YU.UTF-8' to 'sr_CS.UTF-8'
788# updated 'sr_yu@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +0000789#
790# AP 2010-04-12:
791# Updated alias mapping to most recent locale.alias file
792# from X.org distribution using makelocalealias.py.
793#
794# These are the differences compared to the old mapping (Python 2.6.5
795# and older):
796#
797# updated 'ru' -> 'ru_RU.ISO8859-5' to 'ru_RU.UTF-8'
798# updated 'ru_ru' -> 'ru_RU.ISO8859-5' to 'ru_RU.UTF-8'
799# updated 'serbocroatian' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
800# updated 'sh' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
801# updated 'sh_yu' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
802# updated 'sr' -> 'sr_CS.ISO8859-5' to 'sr_RS.UTF-8'
803# updated 'sr@cyrillic' -> 'sr_CS.ISO8859-5' to 'sr_RS.UTF-8'
804# updated 'sr@latn' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
805# updated 'sr_cs.utf8@latn' -> 'sr_CS.UTF-8' to 'sr_RS.UTF-8@latin'
806# updated 'sr_cs@latn' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
807# updated 'sr_yu' -> 'sr_CS.ISO8859-5' to 'sr_RS.UTF-8@latin'
808# updated 'sr_yu.utf8@cyrillic' -> 'sr_CS.UTF-8' to 'sr_RS.UTF-8'
809# updated 'sr_yu@cyrillic' -> 'sr_CS.ISO8859-5' to 'sr_RS.UTF-8'
810#
Serhiy Storchaka715233c2013-12-20 18:23:26 +0200811# SS 2013-12-20:
812# Updated alias mapping to most recent locale.alias file
813# from X.org distribution using makelocalealias.py.
814#
815# These are the differences compared to the old mapping (Python 3.3.3
816# and older):
817#
818# updated 'a3' -> 'a3_AZ.KOI8-C' to 'az_AZ.KOI8-C'
819# updated 'a3_az' -> 'a3_AZ.KOI8-C' to 'az_AZ.KOI8-C'
820# updated 'a3_az.koi8c' -> 'a3_AZ.KOI8-C' to 'az_AZ.KOI8-C'
821# updated 'cs_cs.iso88592' -> 'cs_CS.ISO8859-2' to 'cs_CZ.ISO8859-2'
822# updated 'hebrew' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
823# updated 'hebrew.iso88598' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
824# updated 'sd' -> 'sd_IN@devanagari.UTF-8' to 'sd_IN.UTF-8'
825# updated 'sr@latn' -> 'sr_RS.UTF-8@latin' to 'sr_CS.UTF-8@latin'
826# updated 'sr_cs' -> 'sr_RS.UTF-8' to 'sr_CS.UTF-8'
827# updated 'sr_cs.utf8@latn' -> 'sr_RS.UTF-8@latin' to 'sr_CS.UTF-8@latin'
828# updated 'sr_cs@latn' -> 'sr_RS.UTF-8@latin' to 'sr_CS.UTF-8@latin'
Serhiy Storchaka9e04eda2014-10-02 10:49:26 +0300829#
830# SS 2014-10-01:
831# Updated alias mapping with glibc 2.19 supported locales.
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000832
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000833locale_alias = {
Serhiy Storchaka715233c2013-12-20 18:23:26 +0200834 'a3': 'az_AZ.KOI8-C',
835 'a3_az': 'az_AZ.KOI8-C',
Serhiy Storchaka715233c2013-12-20 18:23:26 +0200836 'a3_az.koic': 'az_AZ.KOI8-C',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +0300837 'aa_dj': 'aa_DJ.ISO8859-1',
838 'aa_er': 'aa_ER.UTF-8',
839 'aa_et': 'aa_ET.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000840 'af': 'af_ZA.ISO8859-1',
841 'af_za': 'af_ZA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000842 'am': 'am_ET.UTF-8',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000843 'am_et': 'am_ET.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000844 'american': 'en_US.ISO8859-1',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +0300845 'an_es': 'an_ES.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000846 'ar': 'ar_AA.ISO8859-6',
847 'ar_aa': 'ar_AA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000848 'ar_ae': 'ar_AE.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000849 'ar_bh': 'ar_BH.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000850 'ar_dz': 'ar_DZ.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000851 'ar_eg': 'ar_EG.ISO8859-6',
Serhiy Storchaka715233c2013-12-20 18:23:26 +0200852 'ar_in': 'ar_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000853 'ar_iq': 'ar_IQ.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000854 'ar_jo': 'ar_JO.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000855 'ar_kw': 'ar_KW.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000856 'ar_lb': 'ar_LB.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000857 'ar_ly': 'ar_LY.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000858 'ar_ma': 'ar_MA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000859 'ar_om': 'ar_OM.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000860 'ar_qa': 'ar_QA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000861 'ar_sa': 'ar_SA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000862 'ar_sd': 'ar_SD.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000863 'ar_sy': 'ar_SY.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000864 'ar_tn': 'ar_TN.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000865 'ar_ye': 'ar_YE.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000866 'arabic': 'ar_AA.ISO8859-6',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +0000867 'as': 'as_IN.UTF-8',
Serhiy Storchaka715233c2013-12-20 18:23:26 +0200868 'as_in': 'as_IN.UTF-8',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +0300869 'ast_es': 'ast_ES.ISO8859-15',
870 'ayc_pe': 'ayc_PE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000871 'az': 'az_AZ.ISO8859-9E',
872 'az_az': 'az_AZ.ISO8859-9E',
873 'az_az.iso88599e': 'az_AZ.ISO8859-9E',
874 'be': 'be_BY.CP1251',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +0000875 'be@latin': 'be_BY.UTF-8@latin',
Serhiy Storchaka1de0ba22014-10-02 00:09:37 +0300876 'be_bg.utf8': 'bg_BG.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000877 'be_by': 'be_BY.CP1251',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +0000878 'be_by@latin': 'be_BY.UTF-8@latin',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +0300879 'bem_zm': 'bem_ZM.UTF-8',
880 'ber_dz': 'ber_DZ.UTF-8',
881 'ber_ma': 'ber_MA.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000882 'bg': 'bg_BG.CP1251',
883 'bg_bg': 'bg_BG.CP1251',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +0300884 'bho_in': 'bho_IN.UTF-8',
885 'bn_bd': 'bn_BD.UTF-8',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000886 'bn_in': 'bn_IN.UTF-8',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +0300887 'bo_cn': 'bo_CN.UTF-8',
Serhiy Storchaka715233c2013-12-20 18:23:26 +0200888 'bo_in': 'bo_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000889 'bokmal': 'nb_NO.ISO8859-1',
890 'bokm\xe5l': 'nb_NO.ISO8859-1',
891 'br': 'br_FR.ISO8859-1',
892 'br_fr': 'br_FR.ISO8859-1',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +0300893 'brx_in': 'brx_IN.UTF-8',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000894 'bs': 'bs_BA.ISO8859-2',
895 'bs_ba': 'bs_BA.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000896 'bulgarian': 'bg_BG.CP1251',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +0300897 'byn_er': 'byn_ER.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000898 'c': 'C',
899 'c-french': 'fr_CA.ISO8859-1',
Serhiy Storchaka715233c2013-12-20 18:23:26 +0200900 'c.ascii': 'C',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000901 'c.en': 'C',
902 'c.iso88591': 'en_US.ISO8859-1',
Serhiy Storchaka1de0ba22014-10-02 00:09:37 +0300903 'c.utf8': 'en_US.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000904 'c_c': 'C',
905 'c_c.c': 'C',
906 'ca': 'ca_ES.ISO8859-1',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +0000907 'ca_ad': 'ca_AD.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000908 'ca_es': 'ca_ES.ISO8859-1',
Serhiy Storchaka9e04eda2014-10-02 10:49:26 +0300909 'ca_es@valencia': 'ca_ES.ISO8859-15@valencia',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +0000910 'ca_fr': 'ca_FR.ISO8859-1',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +0000911 'ca_it': 'ca_IT.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000912 'catalan': 'ca_ES.ISO8859-1',
913 'cextend': 'en_US.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000914 'chinese-s': 'zh_CN.eucCN',
915 'chinese-t': 'zh_TW.eucTW',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +0300916 'crh_ua': 'crh_UA.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000917 'croatian': 'hr_HR.ISO8859-2',
918 'cs': 'cs_CZ.ISO8859-2',
919 'cs_cs': 'cs_CZ.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000920 'cs_cz': 'cs_CZ.ISO8859-2',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +0300921 'csb_pl': 'csb_PL.UTF-8',
922 'cv_ru': 'cv_RU.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000923 'cy': 'cy_GB.ISO8859-1',
924 'cy_gb': 'cy_GB.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000925 'cz': 'cs_CZ.ISO8859-2',
926 'cz_cz': 'cs_CZ.ISO8859-2',
927 'czech': 'cs_CZ.ISO8859-2',
928 'da': 'da_DK.ISO8859-1',
929 'da_dk': 'da_DK.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000930 'danish': 'da_DK.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000931 'dansk': 'da_DK.ISO8859-1',
932 'de': 'de_DE.ISO8859-1',
933 'de_at': 'de_AT.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000934 'de_be': 'de_BE.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000935 'de_ch': 'de_CH.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000936 'de_de': 'de_DE.ISO8859-1',
Serhiy Storchaka9e04eda2014-10-02 10:49:26 +0300937 'de_li.utf8': 'de_LI.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000938 'de_lu': 'de_LU.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000939 'deutsch': 'de_DE.ISO8859-1',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +0300940 'doi_in': 'doi_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000941 'dutch': 'nl_NL.ISO8859-1',
942 'dutch.iso88591': 'nl_BE.ISO8859-1',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +0300943 'dv_mv': 'dv_MV.UTF-8',
944 'dz_bt': 'dz_BT.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000945 'ee': 'ee_EE.ISO8859-4',
946 'ee_ee': 'ee_EE.ISO8859-4',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000947 'eesti': 'et_EE.ISO8859-1',
948 'el': 'el_GR.ISO8859-7',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +0300949 'el_cy': 'el_CY.ISO8859-7',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000950 'el_gr': 'el_GR.ISO8859-7',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000951 'el_gr@euro': 'el_GR.ISO8859-15',
952 'en': 'en_US.ISO8859-1',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +0300953 'en_ag': 'en_AG.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000954 'en_au': 'en_AU.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000955 'en_be': 'en_BE.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000956 'en_bw': 'en_BW.ISO8859-1',
957 'en_ca': 'en_CA.ISO8859-1',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +0300958 'en_dk': 'en_DK.ISO8859-1',
Serhiy Storchaka1de0ba22014-10-02 00:09:37 +0300959 'en_dl.utf8': 'en_DL.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000960 'en_gb': 'en_GB.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000961 'en_hk': 'en_HK.ISO8859-1',
962 'en_ie': 'en_IE.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000963 'en_in': 'en_IN.ISO8859-1',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +0300964 'en_ng': 'en_NG.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000965 'en_nz': 'en_NZ.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000966 'en_ph': 'en_PH.ISO8859-1',
967 'en_sg': 'en_SG.ISO8859-1',
968 'en_uk': 'en_GB.ISO8859-1',
969 'en_us': 'en_US.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000970 'en_us@euro@euro': 'en_US.ISO8859-15',
971 'en_za': 'en_ZA.ISO8859-1',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +0300972 'en_zm': 'en_ZM.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000973 'en_zw': 'en_ZW.ISO8859-1',
Serhiy Storchaka1de0ba22014-10-02 00:09:37 +0300974 'en_zw.utf8': 'en_ZS.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000975 'eng_gb': 'en_GB.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000976 'english': 'en_EN.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000977 'english_uk': 'en_GB.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000978 'english_united-states': 'en_US.ISO8859-1',
979 'english_united-states.437': 'C',
980 'english_us': 'en_US.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000981 'eo': 'eo_XX.ISO8859-3',
Serhiy Storchaka9e04eda2014-10-02 10:49:26 +0300982 'eo.utf8': 'eo.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000983 'eo_eo': 'eo_EO.ISO8859-3',
Serhiy Storchaka9e04eda2014-10-02 10:49:26 +0300984 'eo_us.utf8': 'eo_US.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000985 'eo_xx': 'eo_XX.ISO8859-3',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000986 'es': 'es_ES.ISO8859-1',
987 'es_ar': 'es_AR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000988 'es_bo': 'es_BO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000989 'es_cl': 'es_CL.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000990 'es_co': 'es_CO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000991 'es_cr': 'es_CR.ISO8859-1',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +0300992 'es_cu': 'es_CU.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000993 'es_do': 'es_DO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000994 'es_ec': 'es_EC.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000995 'es_es': 'es_ES.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000996 'es_gt': 'es_GT.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000997 'es_hn': 'es_HN.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000998 'es_mx': 'es_MX.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000999 'es_ni': 'es_NI.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001000 'es_pa': 'es_PA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001001 'es_pe': 'es_PE.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001002 'es_pr': 'es_PR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001003 'es_py': 'es_PY.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001004 'es_sv': 'es_SV.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001005 'es_us': 'es_US.ISO8859-1',
1006 'es_uy': 'es_UY.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001007 'es_ve': 'es_VE.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001008 'estonian': 'et_EE.ISO8859-1',
1009 'et': 'et_EE.ISO8859-15',
1010 'et_ee': 'et_EE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001011 'eu': 'eu_ES.ISO8859-1',
1012 'eu_es': 'eu_ES.ISO8859-1',
Serhiy Storchaka9e04eda2014-10-02 10:49:26 +03001013 'eu_fr': 'eu_FR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001014 'fa': 'fa_IR.UTF-8',
1015 'fa_ir': 'fa_IR.UTF-8',
1016 'fa_ir.isiri3342': 'fa_IR.ISIRI-3342',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001017 'ff_sn': 'ff_SN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001018 'fi': 'fi_FI.ISO8859-15',
1019 'fi_fi': 'fi_FI.ISO8859-15',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001020 'fil_ph': 'fil_PH.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001021 'finnish': 'fi_FI.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001022 'fo': 'fo_FO.ISO8859-1',
1023 'fo_fo': 'fo_FO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001024 'fr': 'fr_FR.ISO8859-1',
1025 'fr_be': 'fr_BE.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001026 'fr_ca': 'fr_CA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001027 'fr_ch': 'fr_CH.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001028 'fr_fr': 'fr_FR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001029 'fr_lu': 'fr_LU.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001030 'fran\xe7ais': 'fr_FR.ISO8859-1',
1031 'fre_fr': 'fr_FR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001032 'french': 'fr_FR.ISO8859-1',
1033 'french.iso88591': 'fr_CH.ISO8859-1',
1034 'french_france': 'fr_FR.ISO8859-1',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001035 'fur_it': 'fur_IT.UTF-8',
1036 'fy_de': 'fy_DE.UTF-8',
1037 'fy_nl': 'fy_NL.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001038 'ga': 'ga_IE.ISO8859-1',
1039 'ga_ie': 'ga_IE.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001040 'galego': 'gl_ES.ISO8859-1',
1041 'galician': 'gl_ES.ISO8859-1',
1042 'gd': 'gd_GB.ISO8859-1',
1043 'gd_gb': 'gd_GB.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001044 'ger_de': 'de_DE.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001045 'german': 'de_DE.ISO8859-1',
1046 'german.iso88591': 'de_CH.ISO8859-1',
1047 'german_germany': 'de_DE.ISO8859-1',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001048 'gez_er': 'gez_ER.UTF-8',
1049 'gez_et': 'gez_ET.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001050 'gl': 'gl_ES.ISO8859-1',
1051 'gl_es': 'gl_ES.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001052 'greek': 'el_GR.ISO8859-7',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001053 'gu_in': 'gu_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001054 'gv': 'gv_GB.ISO8859-1',
1055 'gv_gb': 'gv_GB.ISO8859-1',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001056 'ha_ng': 'ha_NG.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001057 'he': 'he_IL.ISO8859-8',
1058 'he_il': 'he_IL.ISO8859-8',
Serhiy Storchaka715233c2013-12-20 18:23:26 +02001059 'hebrew': 'he_IL.ISO8859-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001060 'hi': 'hi_IN.ISCII-DEV',
1061 'hi_in': 'hi_IN.ISCII-DEV',
1062 'hi_in.isciidev': 'hi_IN.ISCII-DEV',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001063 'hne': 'hne_IN.UTF-8',
Serhiy Storchaka715233c2013-12-20 18:23:26 +02001064 'hne_in': 'hne_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001065 'hr': 'hr_HR.ISO8859-2',
1066 'hr_hr': 'hr_HR.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001067 'hrvatski': 'hr_HR.ISO8859-2',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001068 'hsb_de': 'hsb_DE.ISO8859-2',
1069 'ht_ht': 'ht_HT.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001070 'hu': 'hu_HU.ISO8859-2',
1071 'hu_hu': 'hu_HU.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001072 'hungarian': 'hu_HU.ISO8859-2',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001073 'hy_am': 'hy_AM.UTF-8',
1074 'hy_am.armscii8': 'hy_AM.ARMSCII_8',
Serhiy Storchaka9e04eda2014-10-02 10:49:26 +03001075 'ia': 'ia.UTF-8',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001076 'ia_fr': 'ia_FR.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001077 'icelandic': 'is_IS.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001078 'id': 'id_ID.ISO8859-1',
1079 'id_id': 'id_ID.ISO8859-1',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001080 'ig_ng': 'ig_NG.UTF-8',
1081 'ik_ca': 'ik_CA.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001082 'in': 'id_ID.ISO8859-1',
1083 'in_id': 'id_ID.ISO8859-1',
1084 'is': 'is_IS.ISO8859-1',
1085 'is_is': 'is_IS.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001086 'iso-8859-1': 'en_US.ISO8859-1',
1087 'iso-8859-15': 'en_US.ISO8859-15',
1088 'iso8859-1': 'en_US.ISO8859-1',
1089 'iso8859-15': 'en_US.ISO8859-15',
1090 'iso_8859_1': 'en_US.ISO8859-1',
1091 'iso_8859_15': 'en_US.ISO8859-15',
1092 'it': 'it_IT.ISO8859-1',
1093 'it_ch': 'it_CH.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001094 'it_it': 'it_IT.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001095 'italian': 'it_IT.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001096 'iu': 'iu_CA.NUNACOM-8',
1097 'iu_ca': 'iu_CA.NUNACOM-8',
1098 'iu_ca.nunacom8': 'iu_CA.NUNACOM-8',
1099 'iw': 'he_IL.ISO8859-8',
1100 'iw_il': 'he_IL.ISO8859-8',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001101 'iw_il.utf8': 'iw_IL.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001102 'ja': 'ja_JP.eucJP',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001103 'ja_jp': 'ja_JP.eucJP',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001104 'ja_jp.euc': 'ja_JP.eucJP',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001105 'ja_jp.mscode': 'ja_JP.SJIS',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001106 'ja_jp.pck': 'ja_JP.SJIS',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001107 'japan': 'ja_JP.eucJP',
1108 'japanese': 'ja_JP.eucJP',
1109 'japanese-euc': 'ja_JP.eucJP',
1110 'japanese.euc': 'ja_JP.eucJP',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001111 'jp_jp': 'ja_JP.eucJP',
1112 'ka': 'ka_GE.GEORGIAN-ACADEMY',
1113 'ka_ge': 'ka_GE.GEORGIAN-ACADEMY',
1114 'ka_ge.georgianacademy': 'ka_GE.GEORGIAN-ACADEMY',
1115 'ka_ge.georgianps': 'ka_GE.GEORGIAN-PS',
1116 'ka_ge.georgianrs': 'ka_GE.GEORGIAN-ACADEMY',
Serhiy Storchaka9e04eda2014-10-02 10:49:26 +03001117 'kk_kz': 'kk_KZ.RK1048',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001118 'kl': 'kl_GL.ISO8859-1',
1119 'kl_gl': 'kl_GL.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001120 'km_kh': 'km_KH.UTF-8',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001121 'kn': 'kn_IN.UTF-8',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001122 'kn_in': 'kn_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001123 'ko': 'ko_KR.eucKR',
1124 'ko_kr': 'ko_KR.eucKR',
1125 'ko_kr.euc': 'ko_KR.eucKR',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001126 'kok_in': 'kok_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001127 'korean': 'ko_KR.eucKR',
1128 'korean.euc': 'ko_KR.eucKR',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001129 'ks': 'ks_IN.UTF-8',
Serhiy Storchaka715233c2013-12-20 18:23:26 +02001130 'ks_in': 'ks_IN.UTF-8',
Serhiy Storchaka1de0ba22014-10-02 00:09:37 +03001131 'ks_in@devanagari.utf8': 'ks_IN.UTF-8@devanagari',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001132 'ku_tr': 'ku_TR.ISO8859-9',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001133 'kw': 'kw_GB.ISO8859-1',
1134 'kw_gb': 'kw_GB.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001135 'ky': 'ky_KG.UTF-8',
1136 'ky_kg': 'ky_KG.UTF-8',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001137 'lb_lu': 'lb_LU.UTF-8',
1138 'lg_ug': 'lg_UG.ISO8859-10',
1139 'li_be': 'li_BE.UTF-8',
1140 'li_nl': 'li_NL.UTF-8',
1141 'lij_it': 'lij_IT.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001142 'lithuanian': 'lt_LT.ISO8859-13',
1143 'lo': 'lo_LA.MULELAO-1',
1144 'lo_la': 'lo_LA.MULELAO-1',
1145 'lo_la.cp1133': 'lo_LA.IBM-CP1133',
1146 'lo_la.ibmcp1133': 'lo_LA.IBM-CP1133',
1147 'lo_la.mulelao1': 'lo_LA.MULELAO-1',
1148 'lt': 'lt_LT.ISO8859-13',
1149 'lt_lt': 'lt_LT.ISO8859-13',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001150 'lv': 'lv_LV.ISO8859-13',
1151 'lv_lv': 'lv_LV.ISO8859-13',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001152 'mag_in': 'mag_IN.UTF-8',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001153 'mai': 'mai_IN.UTF-8',
Serhiy Storchaka715233c2013-12-20 18:23:26 +02001154 'mai_in': 'mai_IN.UTF-8',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001155 'mg_mg': 'mg_MG.ISO8859-15',
1156 'mhr_ru': 'mhr_RU.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001157 'mi': 'mi_NZ.ISO8859-1',
1158 'mi_nz': 'mi_NZ.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001159 'mk': 'mk_MK.ISO8859-5',
1160 'mk_mk': 'mk_MK.ISO8859-5',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001161 'ml': 'ml_IN.UTF-8',
Serhiy Storchaka715233c2013-12-20 18:23:26 +02001162 'ml_in': 'ml_IN.UTF-8',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001163 'mn_mn': 'mn_MN.UTF-8',
1164 'mni_in': 'mni_IN.UTF-8',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001165 'mr': 'mr_IN.UTF-8',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001166 'mr_in': 'mr_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001167 'ms': 'ms_MY.ISO8859-1',
1168 'ms_my': 'ms_MY.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001169 'mt': 'mt_MT.ISO8859-3',
1170 'mt_mt': 'mt_MT.ISO8859-3',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001171 'my_mm': 'my_MM.UTF-8',
1172 'nan_tw@latin': 'nan_TW.UTF-8@latin',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001173 'nb': 'nb_NO.ISO8859-1',
1174 'nb_no': 'nb_NO.ISO8859-1',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001175 'nds_de': 'nds_DE.UTF-8',
1176 'nds_nl': 'nds_NL.UTF-8',
Serhiy Storchaka715233c2013-12-20 18:23:26 +02001177 'ne_np': 'ne_NP.UTF-8',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001178 'nhn_mx': 'nhn_MX.UTF-8',
1179 'niu_nu': 'niu_NU.UTF-8',
1180 'niu_nz': 'niu_NZ.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001181 'nl': 'nl_NL.ISO8859-1',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001182 'nl_aw': 'nl_AW.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001183 'nl_be': 'nl_BE.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001184 'nl_nl': 'nl_NL.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001185 'nn': 'nn_NO.ISO8859-1',
1186 'nn_no': 'nn_NO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001187 'no': 'no_NO.ISO8859-1',
1188 'no@nynorsk': 'ny_NO.ISO8859-1',
1189 'no_no': 'no_NO.ISO8859-1',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001190 'no_no.iso88591@bokmal': 'no_NO.ISO8859-1',
1191 'no_no.iso88591@nynorsk': 'no_NO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001192 'norwegian': 'no_NO.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001193 'nr': 'nr_ZA.ISO8859-1',
1194 'nr_za': 'nr_ZA.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001195 'nso': 'nso_ZA.ISO8859-15',
1196 'nso_za': 'nso_ZA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001197 'ny': 'ny_NO.ISO8859-1',
1198 'ny_no': 'ny_NO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001199 'nynorsk': 'nn_NO.ISO8859-1',
1200 'oc': 'oc_FR.ISO8859-1',
1201 'oc_fr': 'oc_FR.ISO8859-1',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001202 'om_et': 'om_ET.UTF-8',
1203 'om_ke': 'om_KE.ISO8859-1',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001204 'or': 'or_IN.UTF-8',
Serhiy Storchaka715233c2013-12-20 18:23:26 +02001205 'or_in': 'or_IN.UTF-8',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001206 'os_ru': 'os_RU.UTF-8',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001207 'pa': 'pa_IN.UTF-8',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001208 'pa_in': 'pa_IN.UTF-8',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001209 'pa_pk': 'pa_PK.UTF-8',
1210 'pap_an': 'pap_AN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001211 'pd': 'pd_US.ISO8859-1',
1212 'pd_de': 'pd_DE.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001213 'pd_us': 'pd_US.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001214 'ph': 'ph_PH.ISO8859-1',
1215 'ph_ph': 'ph_PH.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001216 'pl': 'pl_PL.ISO8859-2',
1217 'pl_pl': 'pl_PL.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001218 'polish': 'pl_PL.ISO8859-2',
1219 'portuguese': 'pt_PT.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001220 'portuguese_brazil': 'pt_BR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001221 'posix': 'C',
1222 'posix-utf2': 'C',
1223 'pp': 'pp_AN.ISO8859-1',
1224 'pp_an': 'pp_AN.ISO8859-1',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001225 'ps_af': 'ps_AF.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001226 'pt': 'pt_PT.ISO8859-1',
1227 'pt_br': 'pt_BR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001228 'pt_pt': 'pt_PT.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001229 'ro': 'ro_RO.ISO8859-2',
1230 'ro_ro': 'ro_RO.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001231 'romanian': 'ro_RO.ISO8859-2',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001232 'ru': 'ru_RU.UTF-8',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001233 'ru_ru': 'ru_RU.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001234 'ru_ua': 'ru_UA.KOI8-U',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001235 'rumanian': 'ro_RO.ISO8859-2',
1236 'russian': 'ru_RU.ISO8859-5',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001237 'rw': 'rw_RW.ISO8859-1',
1238 'rw_rw': 'rw_RW.ISO8859-1',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001239 'sa_in': 'sa_IN.UTF-8',
1240 'sat_in': 'sat_IN.UTF-8',
1241 'sc_it': 'sc_IT.UTF-8',
Serhiy Storchaka715233c2013-12-20 18:23:26 +02001242 'sd': 'sd_IN.UTF-8',
Serhiy Storchaka5eb01532013-12-26 21:20:59 +02001243 'sd_in': 'sd_IN.UTF-8',
Serhiy Storchaka1de0ba22014-10-02 00:09:37 +03001244 'sd_in@devanagari.utf8': 'sd_IN.UTF-8@devanagari',
Serhiy Storchaka9e04eda2014-10-02 10:49:26 +03001245 'sd_pk': 'sd_PK.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001246 'se_no': 'se_NO.UTF-8',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001247 'serbocroatian': 'sr_RS.UTF-8@latin',
1248 'sh': 'sr_RS.UTF-8@latin',
1249 'sh_ba.iso88592@bosnia': 'sr_CS.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001250 'sh_hr': 'sh_HR.ISO8859-2',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001251 'sh_hr.iso88592': 'hr_HR.ISO8859-2',
1252 'sh_sp': 'sr_CS.ISO8859-2',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001253 'sh_yu': 'sr_RS.UTF-8@latin',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001254 'shs_ca': 'shs_CA.UTF-8',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001255 'si': 'si_LK.UTF-8',
1256 'si_lk': 'si_LK.UTF-8',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001257 'sid_et': 'sid_ET.UTF-8',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001258 'sinhala': 'si_LK.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001259 'sk': 'sk_SK.ISO8859-2',
1260 'sk_sk': 'sk_SK.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001261 'sl': 'sl_SI.ISO8859-2',
1262 'sl_cs': 'sl_CS.ISO8859-2',
1263 'sl_si': 'sl_SI.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001264 'slovak': 'sk_SK.ISO8859-2',
1265 'slovene': 'sl_SI.ISO8859-2',
1266 'slovenian': 'sl_SI.ISO8859-2',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001267 'so_dj': 'so_DJ.ISO8859-1',
1268 'so_et': 'so_ET.UTF-8',
1269 'so_ke': 'so_KE.ISO8859-1',
1270 'so_so': 'so_SO.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001271 'sp': 'sr_CS.ISO8859-5',
1272 'sp_yu': 'sr_CS.ISO8859-5',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001273 'spanish': 'es_ES.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001274 'spanish_spain': 'es_ES.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001275 'sq': 'sq_AL.ISO8859-2',
1276 'sq_al': 'sq_AL.ISO8859-2',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001277 'sq_mk': 'sq_MK.UTF-8',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001278 'sr': 'sr_RS.UTF-8',
1279 'sr@cyrillic': 'sr_RS.UTF-8',
Serhiy Storchaka715233c2013-12-20 18:23:26 +02001280 'sr@latn': 'sr_CS.UTF-8@latin',
1281 'sr_cs': 'sr_CS.UTF-8',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001282 'sr_cs.iso88592@latn': 'sr_CS.ISO8859-2',
Serhiy Storchaka715233c2013-12-20 18:23:26 +02001283 'sr_cs@latn': 'sr_CS.UTF-8@latin',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001284 'sr_me': 'sr_ME.UTF-8',
1285 'sr_rs': 'sr_RS.UTF-8',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001286 'sr_rs@latn': 'sr_RS.UTF-8@latin',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001287 'sr_sp': 'sr_CS.ISO8859-2',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001288 'sr_yu': 'sr_RS.UTF-8@latin',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001289 'sr_yu.cp1251@cyrillic': 'sr_CS.CP1251',
1290 'sr_yu.iso88592': 'sr_CS.ISO8859-2',
1291 'sr_yu.iso88595': 'sr_CS.ISO8859-5',
1292 'sr_yu.iso88595@cyrillic': 'sr_CS.ISO8859-5',
1293 'sr_yu.microsoftcp1251@cyrillic': 'sr_CS.CP1251',
Serhiy Storchaka1de0ba22014-10-02 00:09:37 +03001294 'sr_yu.utf8': 'sr_RS.UTF-8',
1295 'sr_yu.utf8@cyrillic': 'sr_RS.UTF-8',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001296 'sr_yu@cyrillic': 'sr_RS.UTF-8',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001297 'ss': 'ss_ZA.ISO8859-1',
1298 'ss_za': 'ss_ZA.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001299 'st': 'st_ZA.ISO8859-1',
1300 'st_za': 'st_ZA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001301 'sv': 'sv_SE.ISO8859-1',
1302 'sv_fi': 'sv_FI.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001303 'sv_se': 'sv_SE.ISO8859-1',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001304 'sw_ke': 'sw_KE.UTF-8',
1305 'sw_tz': 'sw_TZ.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001306 'swedish': 'sv_SE.ISO8859-1',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001307 'szl_pl': 'szl_PL.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001308 'ta': 'ta_IN.TSCII-0',
1309 'ta_in': 'ta_IN.TSCII-0',
1310 'ta_in.tscii': 'ta_IN.TSCII-0',
1311 'ta_in.tscii0': 'ta_IN.TSCII-0',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001312 'ta_lk': 'ta_LK.UTF-8',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001313 'te': 'te_IN.UTF-8',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001314 'te_in': 'te_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001315 'tg': 'tg_TJ.KOI8-C',
1316 'tg_tj': 'tg_TJ.KOI8-C',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001317 'th': 'th_TH.ISO8859-11',
1318 'th_th': 'th_TH.ISO8859-11',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001319 'th_th.tactis': 'th_TH.TIS620',
1320 'th_th.tis620': 'th_TH.TIS620',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001321 'thai': 'th_TH.ISO8859-11',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001322 'ti_er': 'ti_ER.UTF-8',
1323 'ti_et': 'ti_ET.UTF-8',
1324 'tig_er': 'tig_ER.UTF-8',
1325 'tk_tm': 'tk_TM.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001326 'tl': 'tl_PH.ISO8859-1',
1327 'tl_ph': 'tl_PH.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001328 'tn': 'tn_ZA.ISO8859-15',
1329 'tn_za': 'tn_ZA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001330 'tr': 'tr_TR.ISO8859-9',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001331 'tr_cy': 'tr_CY.ISO8859-9',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001332 'tr_tr': 'tr_TR.ISO8859-9',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001333 'ts': 'ts_ZA.ISO8859-1',
1334 'ts_za': 'ts_ZA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001335 'tt': 'tt_RU.TATAR-CYR',
1336 'tt_ru': 'tt_RU.TATAR-CYR',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001337 'tt_ru.tatarcyr': 'tt_RU.TATAR-CYR',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001338 'tt_ru@iqtelif': 'tt_RU.UTF-8@iqtelif',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001339 'turkish': 'tr_TR.ISO8859-9',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001340 'ug_cn': 'ug_CN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001341 'uk': 'uk_UA.KOI8-U',
1342 'uk_ua': 'uk_UA.KOI8-U',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001343 'univ': 'en_US.utf',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001344 'universal': 'en_US.utf',
1345 'universal.utf8@ucs4': 'en_US.UTF-8',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001346 'unm_us': 'unm_US.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001347 'ur': 'ur_PK.CP1256',
Serhiy Storchaka715233c2013-12-20 18:23:26 +02001348 'ur_in': 'ur_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001349 'ur_pk': 'ur_PK.CP1256',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001350 'uz': 'uz_UZ.UTF-8',
1351 'uz_uz': 'uz_UZ.UTF-8',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001352 'uz_uz@cyrillic': 'uz_UZ.UTF-8',
1353 've': 've_ZA.UTF-8',
1354 've_za': 've_ZA.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001355 'vi': 'vi_VN.TCVN',
1356 'vi_vn': 'vi_VN.TCVN',
1357 'vi_vn.tcvn': 'vi_VN.TCVN',
1358 'vi_vn.tcvn5712': 'vi_VN.TCVN',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001359 'vi_vn.viscii': 'vi_VN.VISCII',
1360 'vi_vn.viscii111': 'vi_VN.VISCII',
1361 'wa': 'wa_BE.ISO8859-1',
1362 'wa_be': 'wa_BE.ISO8859-1',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001363 'wae_ch': 'wae_CH.UTF-8',
1364 'wal_et': 'wal_ET.UTF-8',
1365 'wo_sn': 'wo_SN.UTF-8',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001366 'xh': 'xh_ZA.ISO8859-1',
1367 'xh_za': 'xh_ZA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001368 'yi': 'yi_US.CP1255',
1369 'yi_us': 'yi_US.CP1255',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001370 'yo_ng': 'yo_NG.UTF-8',
1371 'yue_hk': 'yue_HK.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001372 'zh': 'zh_CN.eucCN',
1373 'zh_cn': 'zh_CN.gb2312',
1374 'zh_cn.big5': 'zh_TW.big5',
1375 'zh_cn.euc': 'zh_CN.eucCN',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001376 'zh_hk': 'zh_HK.big5hkscs',
Antoine Pitrou0c70d2d2010-04-11 22:35:34 +00001377 'zh_hk.big5hk': 'zh_HK.big5hkscs',
Serhiy Storchaka99cb41d2014-10-01 23:43:35 +03001378 'zh_sg': 'zh_SG.GB2312',
1379 'zh_sg.gbk': 'zh_SG.GBK',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001380 'zh_tw': 'zh_TW.big5',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001381 'zh_tw.euc': 'zh_TW.eucTW',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001382 'zh_tw.euctw': 'zh_TW.eucTW',
1383 'zu': 'zu_ZA.ISO8859-1',
1384 'zu_za': 'zu_ZA.ISO8859-1',
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001385}
1386
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001387#
Georg Brandlb709c2c2006-01-20 09:07:35 +00001388# This maps Windows language identifiers to locale strings.
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001389#
Tim Peters777f1082006-01-20 20:03:24 +00001390# This list has been updated from
Georg Brandlb709c2c2006-01-20 09:07:35 +00001391# 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 +00001392# to include every locale up to Windows Vista.
Fredrik Lundh37a09822002-10-19 20:19:10 +00001393#
Georg Brandl5035c1c2006-01-20 13:38:26 +00001394# NOTE: this mapping is incomplete. If your language is missing, please
Éric Araujoa2b89e32011-11-29 16:36:17 +01001395# submit a bug report to the Python bug tracker at http://bugs.python.org/
Georg Brandl5035c1c2006-01-20 13:38:26 +00001396# Make sure you include the missing language identifier and the suggested
1397# locale code.
1398#
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001399
1400windows_locale = {
Georg Brandlb709c2c2006-01-20 09:07:35 +00001401 0x0436: "af_ZA", # Afrikaans
1402 0x041c: "sq_AL", # Albanian
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001403 0x0484: "gsw_FR",# Alsatian - France
1404 0x045e: "am_ET", # Amharic - Ethiopia
Georg Brandlb709c2c2006-01-20 09:07:35 +00001405 0x0401: "ar_SA", # Arabic - Saudi Arabia
1406 0x0801: "ar_IQ", # Arabic - Iraq
1407 0x0c01: "ar_EG", # Arabic - Egypt
1408 0x1001: "ar_LY", # Arabic - Libya
1409 0x1401: "ar_DZ", # Arabic - Algeria
1410 0x1801: "ar_MA", # Arabic - Morocco
1411 0x1c01: "ar_TN", # Arabic - Tunisia
1412 0x2001: "ar_OM", # Arabic - Oman
1413 0x2401: "ar_YE", # Arabic - Yemen
1414 0x2801: "ar_SY", # Arabic - Syria
1415 0x2c01: "ar_JO", # Arabic - Jordan
1416 0x3001: "ar_LB", # Arabic - Lebanon
1417 0x3401: "ar_KW", # Arabic - Kuwait
1418 0x3801: "ar_AE", # Arabic - United Arab Emirates
1419 0x3c01: "ar_BH", # Arabic - Bahrain
1420 0x4001: "ar_QA", # Arabic - Qatar
1421 0x042b: "hy_AM", # Armenian
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001422 0x044d: "as_IN", # Assamese - India
1423 0x042c: "az_AZ", # Azeri - Latin
Georg Brandlb709c2c2006-01-20 09:07:35 +00001424 0x082c: "az_AZ", # Azeri - Cyrillic
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001425 0x046d: "ba_RU", # Bashkir
1426 0x042d: "eu_ES", # Basque - Russia
Georg Brandlb709c2c2006-01-20 09:07:35 +00001427 0x0423: "be_BY", # Belarusian
1428 0x0445: "bn_IN", # Begali
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001429 0x201a: "bs_BA", # Bosnian - Cyrillic
1430 0x141a: "bs_BA", # Bosnian - Latin
Georg Brandlb709c2c2006-01-20 09:07:35 +00001431 0x047e: "br_FR", # Breton - France
1432 0x0402: "bg_BG", # Bulgarian
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001433# 0x0455: "my_MM", # Burmese - Not supported
Georg Brandlb709c2c2006-01-20 09:07:35 +00001434 0x0403: "ca_ES", # Catalan
1435 0x0004: "zh_CHS",# Chinese - Simplified
1436 0x0404: "zh_TW", # Chinese - Taiwan
1437 0x0804: "zh_CN", # Chinese - PRC
1438 0x0c04: "zh_HK", # Chinese - Hong Kong S.A.R.
1439 0x1004: "zh_SG", # Chinese - Singapore
1440 0x1404: "zh_MO", # Chinese - Macao S.A.R.
1441 0x7c04: "zh_CHT",# Chinese - Traditional
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001442 0x0483: "co_FR", # Corsican - France
Georg Brandlb709c2c2006-01-20 09:07:35 +00001443 0x041a: "hr_HR", # Croatian
1444 0x101a: "hr_BA", # Croatian - Bosnia
1445 0x0405: "cs_CZ", # Czech
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001446 0x0406: "da_DK", # Danish
Georg Brandlb709c2c2006-01-20 09:07:35 +00001447 0x048c: "gbz_AF",# Dari - Afghanistan
1448 0x0465: "div_MV",# Divehi - Maldives
1449 0x0413: "nl_NL", # Dutch - The Netherlands
1450 0x0813: "nl_BE", # Dutch - Belgium
1451 0x0409: "en_US", # English - United States
1452 0x0809: "en_GB", # English - United Kingdom
1453 0x0c09: "en_AU", # English - Australia
1454 0x1009: "en_CA", # English - Canada
1455 0x1409: "en_NZ", # English - New Zealand
1456 0x1809: "en_IE", # English - Ireland
1457 0x1c09: "en_ZA", # English - South Africa
1458 0x2009: "en_JA", # English - Jamaica
1459 0x2409: "en_CB", # English - Carribbean
1460 0x2809: "en_BZ", # English - Belize
1461 0x2c09: "en_TT", # English - Trinidad
1462 0x3009: "en_ZW", # English - Zimbabwe
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001463 0x3409: "en_PH", # English - Philippines
1464 0x4009: "en_IN", # English - India
1465 0x4409: "en_MY", # English - Malaysia
1466 0x4809: "en_IN", # English - Singapore
Georg Brandlb709c2c2006-01-20 09:07:35 +00001467 0x0425: "et_EE", # Estonian
1468 0x0438: "fo_FO", # Faroese
1469 0x0464: "fil_PH",# Filipino
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001470 0x040b: "fi_FI", # Finnish
Georg Brandlb709c2c2006-01-20 09:07:35 +00001471 0x040c: "fr_FR", # French - France
1472 0x080c: "fr_BE", # French - Belgium
1473 0x0c0c: "fr_CA", # French - Canada
1474 0x100c: "fr_CH", # French - Switzerland
1475 0x140c: "fr_LU", # French - Luxembourg
1476 0x180c: "fr_MC", # French - Monaco
1477 0x0462: "fy_NL", # Frisian - Netherlands
1478 0x0456: "gl_ES", # Galician
1479 0x0437: "ka_GE", # Georgian
1480 0x0407: "de_DE", # German - Germany
1481 0x0807: "de_CH", # German - Switzerland
1482 0x0c07: "de_AT", # German - Austria
1483 0x1007: "de_LU", # German - Luxembourg
1484 0x1407: "de_LI", # German - Liechtenstein
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001485 0x0408: "el_GR", # Greek
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001486 0x046f: "kl_GL", # Greenlandic - Greenland
Georg Brandlb709c2c2006-01-20 09:07:35 +00001487 0x0447: "gu_IN", # Gujarati
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001488 0x0468: "ha_NG", # Hausa - Latin
Georg Brandlb709c2c2006-01-20 09:07:35 +00001489 0x040d: "he_IL", # Hebrew
1490 0x0439: "hi_IN", # Hindi
1491 0x040e: "hu_HU", # Hungarian
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001492 0x040f: "is_IS", # Icelandic
Georg Brandlb709c2c2006-01-20 09:07:35 +00001493 0x0421: "id_ID", # Indonesian
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001494 0x045d: "iu_CA", # Inuktitut - Syllabics
Georg Brandlb709c2c2006-01-20 09:07:35 +00001495 0x085d: "iu_CA", # Inuktitut - Latin
1496 0x083c: "ga_IE", # Irish - Ireland
Georg Brandlb709c2c2006-01-20 09:07:35 +00001497 0x0410: "it_IT", # Italian - Italy
1498 0x0810: "it_CH", # Italian - Switzerland
1499 0x0411: "ja_JP", # Japanese
1500 0x044b: "kn_IN", # Kannada - India
1501 0x043f: "kk_KZ", # Kazakh
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001502 0x0453: "kh_KH", # Khmer - Cambodia
1503 0x0486: "qut_GT",# K'iche - Guatemala
1504 0x0487: "rw_RW", # Kinyarwanda - Rwanda
Georg Brandlb709c2c2006-01-20 09:07:35 +00001505 0x0457: "kok_IN",# Konkani
1506 0x0412: "ko_KR", # Korean
1507 0x0440: "ky_KG", # Kyrgyz
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001508 0x0454: "lo_LA", # Lao - Lao PDR
Georg Brandlb709c2c2006-01-20 09:07:35 +00001509 0x0426: "lv_LV", # Latvian
1510 0x0427: "lt_LT", # Lithuanian
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001511 0x082e: "dsb_DE",# Lower Sorbian - Germany
Georg Brandlb709c2c2006-01-20 09:07:35 +00001512 0x046e: "lb_LU", # Luxembourgish
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001513 0x042f: "mk_MK", # FYROM Macedonian
Georg Brandlb709c2c2006-01-20 09:07:35 +00001514 0x043e: "ms_MY", # Malay - Malaysia
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001515 0x083e: "ms_BN", # Malay - Brunei Darussalam
Georg Brandlb709c2c2006-01-20 09:07:35 +00001516 0x044c: "ml_IN", # Malayalam - India
1517 0x043a: "mt_MT", # Maltese
1518 0x0481: "mi_NZ", # Maori
1519 0x047a: "arn_CL",# Mapudungun
1520 0x044e: "mr_IN", # Marathi
1521 0x047c: "moh_CA",# Mohawk - Canada
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001522 0x0450: "mn_MN", # Mongolian - Cyrillic
1523 0x0850: "mn_CN", # Mongolian - PRC
Georg Brandlb709c2c2006-01-20 09:07:35 +00001524 0x0461: "ne_NP", # Nepali
1525 0x0414: "nb_NO", # Norwegian - Bokmal
1526 0x0814: "nn_NO", # Norwegian - Nynorsk
1527 0x0482: "oc_FR", # Occitan - France
1528 0x0448: "or_IN", # Oriya - India
1529 0x0463: "ps_AF", # Pashto - Afghanistan
1530 0x0429: "fa_IR", # Persian
1531 0x0415: "pl_PL", # Polish
1532 0x0416: "pt_BR", # Portuguese - Brazil
1533 0x0816: "pt_PT", # Portuguese - Portugal
1534 0x0446: "pa_IN", # Punjabi
1535 0x046b: "quz_BO",# Quechua (Bolivia)
1536 0x086b: "quz_EC",# Quechua (Ecuador)
1537 0x0c6b: "quz_PE",# Quechua (Peru)
1538 0x0418: "ro_RO", # Romanian - Romania
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001539 0x0417: "rm_CH", # Romansh
Georg Brandlb709c2c2006-01-20 09:07:35 +00001540 0x0419: "ru_RU", # Russian
1541 0x243b: "smn_FI",# Sami Finland
1542 0x103b: "smj_NO",# Sami Norway
1543 0x143b: "smj_SE",# Sami Sweden
1544 0x043b: "se_NO", # Sami Northern Norway
1545 0x083b: "se_SE", # Sami Northern Sweden
1546 0x0c3b: "se_FI", # Sami Northern Finland
1547 0x203b: "sms_FI",# Sami Skolt
1548 0x183b: "sma_NO",# Sami Southern Norway
1549 0x1c3b: "sma_SE",# Sami Southern Sweden
1550 0x044f: "sa_IN", # Sanskrit
1551 0x0c1a: "sr_SP", # Serbian - Cyrillic
1552 0x1c1a: "sr_BA", # Serbian - Bosnia Cyrillic
1553 0x081a: "sr_SP", # Serbian - Latin
1554 0x181a: "sr_BA", # Serbian - Bosnia Latin
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001555 0x045b: "si_LK", # Sinhala - Sri Lanka
Georg Brandlb709c2c2006-01-20 09:07:35 +00001556 0x046c: "ns_ZA", # Northern Sotho
1557 0x0432: "tn_ZA", # Setswana - Southern Africa
1558 0x041b: "sk_SK", # Slovak
1559 0x0424: "sl_SI", # Slovenian
1560 0x040a: "es_ES", # Spanish - Spain
1561 0x080a: "es_MX", # Spanish - Mexico
1562 0x0c0a: "es_ES", # Spanish - Spain (Modern)
1563 0x100a: "es_GT", # Spanish - Guatemala
1564 0x140a: "es_CR", # Spanish - Costa Rica
1565 0x180a: "es_PA", # Spanish - Panama
1566 0x1c0a: "es_DO", # Spanish - Dominican Republic
1567 0x200a: "es_VE", # Spanish - Venezuela
1568 0x240a: "es_CO", # Spanish - Colombia
1569 0x280a: "es_PE", # Spanish - Peru
1570 0x2c0a: "es_AR", # Spanish - Argentina
1571 0x300a: "es_EC", # Spanish - Ecuador
1572 0x340a: "es_CL", # Spanish - Chile
1573 0x380a: "es_UR", # Spanish - Uruguay
1574 0x3c0a: "es_PY", # Spanish - Paraguay
1575 0x400a: "es_BO", # Spanish - Bolivia
1576 0x440a: "es_SV", # Spanish - El Salvador
1577 0x480a: "es_HN", # Spanish - Honduras
1578 0x4c0a: "es_NI", # Spanish - Nicaragua
1579 0x500a: "es_PR", # Spanish - Puerto Rico
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001580 0x540a: "es_US", # Spanish - United States
1581# 0x0430: "", # Sutu - Not supported
Georg Brandlb709c2c2006-01-20 09:07:35 +00001582 0x0441: "sw_KE", # Swahili
1583 0x041d: "sv_SE", # Swedish - Sweden
1584 0x081d: "sv_FI", # Swedish - Finland
1585 0x045a: "syr_SY",# Syriac
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001586 0x0428: "tg_TJ", # Tajik - Cyrillic
1587 0x085f: "tmz_DZ",# Tamazight - Latin
Georg Brandlb709c2c2006-01-20 09:07:35 +00001588 0x0449: "ta_IN", # Tamil
1589 0x0444: "tt_RU", # Tatar
1590 0x044a: "te_IN", # Telugu
1591 0x041e: "th_TH", # Thai
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001592 0x0851: "bo_BT", # Tibetan - Bhutan
1593 0x0451: "bo_CN", # Tibetan - PRC
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001594 0x041f: "tr_TR", # Turkish
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001595 0x0442: "tk_TM", # Turkmen - Cyrillic
1596 0x0480: "ug_CN", # Uighur - Arabic
Georg Brandlb709c2c2006-01-20 09:07:35 +00001597 0x0422: "uk_UA", # Ukrainian
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001598 0x042e: "wen_DE",# Upper Sorbian - Germany
Georg Brandlb709c2c2006-01-20 09:07:35 +00001599 0x0420: "ur_PK", # Urdu
1600 0x0820: "ur_IN", # Urdu - India
1601 0x0443: "uz_UZ", # Uzbek - Latin
1602 0x0843: "uz_UZ", # Uzbek - Cyrillic
1603 0x042a: "vi_VN", # Vietnamese
1604 0x0452: "cy_GB", # Welsh
Jeroen Ruigrok van der Werven0a866942009-05-08 14:18:00 +00001605 0x0488: "wo_SN", # Wolof - Senegal
1606 0x0434: "xh_ZA", # Xhosa - South Africa
1607 0x0485: "sah_RU",# Yakut - Cyrillic
1608 0x0478: "ii_CN", # Yi - PRC
1609 0x046a: "yo_NG", # Yoruba - Nigeria
1610 0x0435: "zu_ZA", # Zulu
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001611}
1612
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001613def _print_locale():
1614
1615 """ Test function.
1616 """
1617 categories = {}
1618 def _init_categories(categories=categories):
1619 for k,v in globals().items():
1620 if k[:3] == 'LC_':
1621 categories[k] = v
1622 _init_categories()
1623 del categories['LC_ALL']
1624
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001625 print('Locale defaults as determined by getdefaultlocale():')
1626 print('-'*72)
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001627 lang, enc = getdefaultlocale()
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001628 print('Language: ', lang or '(undefined)')
1629 print('Encoding: ', enc or '(undefined)')
1630 print()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001631
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001632 print('Locale settings on startup:')
1633 print('-'*72)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001634 for name,category in categories.items():
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001635 print(name, '...')
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001636 lang, enc = getlocale(category)
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001637 print(' Language: ', lang or '(undefined)')
1638 print(' Encoding: ', enc or '(undefined)')
1639 print()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001640
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001641 print()
1642 print('Locale settings after calling resetlocale():')
1643 print('-'*72)
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001644 resetlocale()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001645 for name,category in categories.items():
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001646 print(name, '...')
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001647 lang, enc = getlocale(category)
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001648 print(' Language: ', lang or '(undefined)')
1649 print(' Encoding: ', enc or '(undefined)')
1650 print()
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001651
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001652 try:
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001653 setlocale(LC_ALL, "")
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001654 except:
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001655 print('NOTE:')
1656 print('setlocale(LC_ALL, "") does not support the default locale')
1657 print('given in the OS environment variables.')
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001658 else:
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001659 print()
1660 print('Locale settings after calling setlocale(LC_ALL, ""):')
1661 print('-'*72)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001662 for name,category in categories.items():
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001663 print(name, '...')
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001664 lang, enc = getlocale(category)
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001665 print(' Language: ', lang or '(undefined)')
1666 print(' Encoding: ', enc or '(undefined)')
1667 print()
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001668
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001669###
Guido van Rossumeef1d4e1997-11-19 19:01:43 +00001670
Tim Peters1baf8292001-01-24 10:13:46 +00001671try:
1672 LC_MESSAGES
Skip Montanaro0897f0c2002-03-25 21:40:36 +00001673except NameError:
Tim Peters1baf8292001-01-24 10:13:46 +00001674 pass
1675else:
1676 __all__.append("LC_MESSAGES")
1677
Guido van Rossumeef1d4e1997-11-19 19:01:43 +00001678if __name__=='__main__':
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001679 print('Locale aliasing:')
1680 print()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001681 _print_locale()
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001682 print()
1683 print('Number formatting:')
1684 print()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001685 _test()