blob: 4441e6d4d022b8690712e0c06ab0f01956449a13 [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):
124 for interval in grouping:
125 # if grouping is -1, we are done
126 if interval == CHAR_MAX:
127 return
128 # 0: re-use last group ad infinitum
129 if interval == 0:
130 while True:
131 yield last_interval
132 yield interval
133 last_interval = interval
134
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000135#perform the grouping from right to left
Thomas Wouters477c8d52006-05-27 19:21:47 +0000136def _group(s, monetary=False):
137 conv = localeconv()
138 thousands_sep = conv[monetary and 'mon_thousands_sep' or 'thousands_sep']
139 grouping = conv[monetary and 'mon_grouping' or 'grouping']
140 if not grouping:
141 return (s, 0)
142 result = ""
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000143 seps = 0
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000144 if s[-1] == ' ':
Antoine Pitrou350370c2009-03-14 00:13:13 +0000145 stripped = s.rstrip()
146 right_spaces = s[len(stripped):]
147 s = stripped
148 else:
149 right_spaces = ''
150 left_spaces = ''
151 groups = []
152 for interval in _grouping_intervals(grouping):
153 if not s or s[-1] not in "0123456789":
154 # only non-digit characters remain (sign, spaces)
155 left_spaces = s
156 s = ''
Guido van Rossum45e2fbc1998-03-26 21:13:24 +0000157 break
Antoine Pitrou350370c2009-03-14 00:13:13 +0000158 groups.append(s[-interval:])
159 s = s[:-interval]
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000160 if s:
Antoine Pitrou350370c2009-03-14 00:13:13 +0000161 groups.append(s)
162 groups.reverse()
163 return (
164 left_spaces + thousands_sep.join(groups) + right_spaces,
Antoine Pitrou6cf17aa2009-03-18 20:26:42 +0000165 len(thousands_sep) * (len(groups) - 1)
Antoine Pitrou350370c2009-03-14 00:13:13 +0000166 )
167
168# Strip a given amount of excess padding from the given string
169def _strip_padding(s, amount):
170 lpos = 0
171 while amount and s[lpos] == ' ':
172 lpos += 1
173 amount -= 1
174 rpos = len(s) - 1
175 while amount and s[rpos] == ' ':
176 rpos -= 1
177 amount -= 1
178 return s[lpos:rpos+1]
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000179
R. David Murraye59482e2009-04-01 03:42:00 +0000180_percent_re = re.compile(r'%(?:\((?P<key>.*?)\))?'
181 r'(?P<modifiers>[-#0-9 +*.hlL]*?)[eEfFgGdiouxXcrs%]')
182
Thomas Wouters477c8d52006-05-27 19:21:47 +0000183def format(percent, value, grouping=False, monetary=False, *additional):
184 """Returns the locale-aware substitution of a %? specifier
185 (percent).
186
187 additional is for format strings which contain one or more
188 '*' modifiers."""
189 # this is only for one-percent-specifier strings and this should be checked
R. David Murraye59482e2009-04-01 03:42:00 +0000190 match = _percent_re.match(percent)
191 if not match or len(match.group())!= len(percent):
192 raise ValueError(("format() must be given exactly one %%char "
193 "format specifier, %s not valid") % repr(percent))
194 return _format(percent, value, grouping, monetary, *additional)
195
196def _format(percent, value, grouping=False, monetary=False, *additional):
Thomas Wouters477c8d52006-05-27 19:21:47 +0000197 if additional:
198 formatted = percent % ((value,) + additional)
199 else:
200 formatted = percent % value
201 # floats and decimal ints need special action!
202 if percent[-1] in 'eEfFgG':
203 seps = 0
204 parts = formatted.split('.')
205 if grouping:
206 parts[0], seps = _group(parts[0], monetary=monetary)
207 decimal_point = localeconv()[monetary and 'mon_decimal_point'
208 or 'decimal_point']
209 formatted = decimal_point.join(parts)
Antoine Pitrou350370c2009-03-14 00:13:13 +0000210 if seps:
211 formatted = _strip_padding(formatted, seps)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000212 elif percent[-1] in 'diu':
Antoine Pitrou350370c2009-03-14 00:13:13 +0000213 seps = 0
Thomas Wouters477c8d52006-05-27 19:21:47 +0000214 if grouping:
Antoine Pitrou350370c2009-03-14 00:13:13 +0000215 formatted, seps = _group(formatted, monetary=monetary)
216 if seps:
217 formatted = _strip_padding(formatted, seps)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000218 return formatted
219
Thomas Wouters477c8d52006-05-27 19:21:47 +0000220def format_string(f, val, grouping=False):
221 """Formats a string in the same way that the % formatting would use,
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000222 but takes the current locale into account.
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000223 Grouping is applied if the third parameter is true."""
Thomas Wouters477c8d52006-05-27 19:21:47 +0000224 percents = list(_percent_re.finditer(f))
225 new_f = _percent_re.sub('%s', f)
226
227 if isinstance(val, tuple):
228 new_val = list(val)
229 i = 0
230 for perc in percents:
231 starcount = perc.group('modifiers').count('*')
232 new_val[i] = format(perc.group(), new_val[i], grouping, False, *new_val[i+1:i+1+starcount])
233 del new_val[i+1:i+1+starcount]
234 i += (1 + starcount)
235 val = tuple(new_val)
Raymond Hettinger89e12962009-01-26 02:09:03 +0000236 elif isinstance(val, collections.Mapping):
Thomas Wouters477c8d52006-05-27 19:21:47 +0000237 for perc in percents:
238 key = perc.group("key")
239 val[key] = format(perc.group(), val[key], grouping)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000240 else:
Thomas Wouters477c8d52006-05-27 19:21:47 +0000241 # val is a single value
242 val = format(percents[0].group(), val, grouping)
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000243
Thomas Wouters477c8d52006-05-27 19:21:47 +0000244 return new_f % val
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000245
Thomas Wouters477c8d52006-05-27 19:21:47 +0000246def currency(val, symbol=True, grouping=False, international=False):
247 """Formats val according to the currency settings
248 in the current locale."""
249 conv = localeconv()
250
251 # check for illegal values
252 digits = conv[international and 'int_frac_digits' or 'frac_digits']
253 if digits == 127:
254 raise ValueError("Currency formatting is not possible using "
255 "the 'C' locale.")
256
257 s = format('%%.%if' % digits, abs(val), grouping, monetary=True)
258 # '<' and '>' are markers if the sign must be inserted between symbol and value
259 s = '<' + s + '>'
260
261 if symbol:
262 smb = conv[international and 'int_curr_symbol' or 'currency_symbol']
263 precedes = conv[val<0 and 'n_cs_precedes' or 'p_cs_precedes']
264 separated = conv[val<0 and 'n_sep_by_space' or 'p_sep_by_space']
265
266 if precedes:
267 s = smb + (separated and ' ' or '') + s
268 else:
269 s = s + (separated and ' ' or '') + smb
270
271 sign_pos = conv[val<0 and 'n_sign_posn' or 'p_sign_posn']
272 sign = conv[val<0 and 'negative_sign' or 'positive_sign']
273
274 if sign_pos == 0:
275 s = '(' + s + ')'
276 elif sign_pos == 1:
277 s = sign + s
278 elif sign_pos == 2:
279 s = s + sign
280 elif sign_pos == 3:
281 s = s.replace('<', sign)
282 elif sign_pos == 4:
283 s = s.replace('>', sign)
284 else:
285 # the default if nothing specified;
286 # this should be the most fitting sign position
287 s = sign + s
288
289 return s.replace('<', '').replace('>', '')
Martin v. Löwisdb786872001-01-21 18:52:33 +0000290
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000291def str(val):
292 """Convert float to integer, taking the locale into account."""
Thomas Wouters477c8d52006-05-27 19:21:47 +0000293 return format("%.12g", val)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000294
Thomas Wouters477c8d52006-05-27 19:21:47 +0000295def atof(string, func=float):
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000296 "Parses a string as a float according to the locale settings."
297 #First, get rid of the grouping
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000298 ts = localeconv()['thousands_sep']
299 if ts:
Skip Montanaro249369c2004-04-10 16:39:32 +0000300 string = string.replace(ts, '')
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000301 #next, replace the decimal point with a dot
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000302 dd = localeconv()['decimal_point']
303 if dd:
Skip Montanaro249369c2004-04-10 16:39:32 +0000304 string = string.replace(dd, '.')
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000305 #finally, parse the string
Skip Montanaro249369c2004-04-10 16:39:32 +0000306 return func(string)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000307
308def atoi(str):
309 "Converts a string to an integer according to the locale settings."
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000310 return atof(str, int)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000311
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000312def _test():
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000313 setlocale(LC_ALL, "")
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000314 #do grouping
Thomas Wouters477c8d52006-05-27 19:21:47 +0000315 s1 = format("%d", 123456789,1)
Guido van Rossumbe19ed72007-02-09 05:37:30 +0000316 print(s1, "is", atoi(s1))
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000317 #standard formatting
Thomas Wouters477c8d52006-05-27 19:21:47 +0000318 s1 = str(3.14)
Guido van Rossumbe19ed72007-02-09 05:37:30 +0000319 print(s1, "is", atof(s1))
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000320
321### Locale name aliasing engine
322
323# Author: Marc-Andre Lemburg, mal@lemburg.com
Fredrik Lundh37a09822002-10-19 20:19:10 +0000324# Various tweaks by Fredrik Lundh <fredrik@pythonware.com>
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000325
326# store away the low-level version of setlocale (it's
327# overridden below)
328_setlocale = setlocale
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000329
330def normalize(localename):
331
332 """ Returns a normalized locale code for the given locale
333 name.
334
335 The returned locale code is formatted for use with
336 setlocale().
337
338 If normalization fails, the original name is returned
339 unchanged.
340
341 If the given encoding is not known, the function defaults to
342 the default encoding for the locale code just like setlocale()
343 does.
344
345 """
346 # Normalize the locale name and extract the encoding
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000347 fullname = localename.lower()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000348 if ':' in fullname:
349 # ':' is sometimes used as encoding delimiter.
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000350 fullname = fullname.replace(':', '.')
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000351 if '.' in fullname:
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000352 langname, encoding = fullname.split('.')[:2]
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000353 fullname = langname + '.' + encoding
354 else:
355 langname = fullname
356 encoding = ''
357
358 # First lookup: fullname (possibly with encoding)
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000359 norm_encoding = encoding.replace('-', '')
360 norm_encoding = norm_encoding.replace('_', '')
361 lookup_name = langname + '.' + encoding
362 code = locale_alias.get(lookup_name, None)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000363 if code is not None:
364 return code
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000365 #print 'first lookup failed'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000366
367 # Second try: langname (without encoding)
368 code = locale_alias.get(langname, None)
369 if code is not None:
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000370 #print 'langname lookup succeeded'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000371 if '.' in code:
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000372 langname, defenc = code.split('.')
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000373 else:
374 langname = code
375 defenc = ''
376 if encoding:
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000377 # Convert the encoding to a C lib compatible encoding string
378 norm_encoding = encodings.normalize_encoding(encoding)
379 #print 'norm encoding: %r' % norm_encoding
380 norm_encoding = encodings.aliases.aliases.get(norm_encoding,
381 norm_encoding)
382 #print 'aliased encoding: %r' % norm_encoding
383 encoding = locale_encoding_alias.get(norm_encoding,
384 norm_encoding)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000385 else:
386 encoding = defenc
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000387 #print 'found encoding %r' % encoding
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000388 if encoding:
389 return langname + '.' + encoding
390 else:
391 return langname
392
393 else:
394 return localename
395
396def _parse_localename(localename):
397
398 """ Parses the locale code for localename and returns the
399 result as tuple (language code, encoding).
400
401 The localename is normalized and passed through the locale
402 alias engine. A ValueError is raised in case the locale name
403 cannot be parsed.
404
405 The language code corresponds to RFC 1766. code and encoding
406 can be None in case the values cannot be determined or are
Jeremy Hyltona05e2932000-06-28 14:48:01 +0000407 unknown to this implementation.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000408
409 """
410 code = normalize(localename)
Georg Brandlb709c2c2006-01-20 09:07:35 +0000411 if '@' in code:
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000412 # Deal with locale modifiers
413 code, modifier = code.split('@')
414 if modifier == 'euro' and '.' not in code:
415 # Assume Latin-9 for @euro locales. This is bogus,
416 # since some systems may use other encodings for these
417 # locales. Also, we ignore other modifiers.
418 return code, 'iso-8859-15'
Tim Peters230a60c2002-11-09 05:08:07 +0000419
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000420 if '.' in code:
Raymond Hettinger346e67f2005-01-01 06:10:26 +0000421 return tuple(code.split('.')[:2])
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000422 elif code == 'C':
423 return None, None
Collin Winterce36ad82007-08-30 01:19:48 +0000424 raise ValueError('unknown locale: %s' % localename)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000425
426def _build_localename(localetuple):
427
428 """ Builds a locale code from the given tuple (language code,
429 encoding).
430
431 No aliasing or normalizing takes place.
432
433 """
434 language, encoding = localetuple
435 if language is None:
436 language = 'C'
437 if encoding is None:
438 return language
439 else:
440 return language + '.' + encoding
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000441
Matthias Klosef3f231f2005-09-20 07:02:49 +0000442def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000443
444 """ Tries to determine the default locale settings and returns
445 them as tuple (language code, encoding).
446
447 According to POSIX, a program which has not called
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000448 setlocale(LC_ALL, "") runs using the portable 'C' locale.
449 Calling setlocale(LC_ALL, "") lets it use the default locale as
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000450 defined by the LANG variable. Since we don't want to interfere
Thomas Wouters7e474022000-07-16 12:04:32 +0000451 with the current locale setting we thus emulate the behavior
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000452 in the way described above.
453
454 To maintain compatibility with other platforms, not only the
455 LANG variable is tested, but a list of variables given as
456 envvars parameter. The first found to be defined will be
457 used. envvars defaults to the search path used in GNU gettext;
458 it must always contain the variable name 'LANG'.
459
460 Except for the code 'C', the language code corresponds to RFC
461 1766. code and encoding can be None in case the values cannot
462 be determined.
463
464 """
Fredrik Lundh04661322000-07-09 23:16:10 +0000465
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000466 try:
467 # check if it's supported by the _locale module
468 import _locale
469 code, encoding = _locale._getdefaultlocale()
Fredrik Lundh04661322000-07-09 23:16:10 +0000470 except (ImportError, AttributeError):
471 pass
472 else:
Fredrik Lundh663809e2000-07-10 19:32:19 +0000473 # make sure the code/encoding values are valid
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000474 if sys.platform == "win32" and code and code[:2] == "0x":
475 # map windows language identifier to language name
476 code = windows_locale.get(int(code, 0))
Fredrik Lundh663809e2000-07-10 19:32:19 +0000477 # ...add other platform-specific processing here, if
478 # necessary...
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000479 return code, encoding
Fredrik Lundh04661322000-07-09 23:16:10 +0000480
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000481 # fall back on POSIX behaviour
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000482 import os
483 lookup = os.environ.get
484 for variable in envvars:
485 localename = lookup(variable,None)
Martin v. Löwisc8ae31d2004-07-26 12:45:18 +0000486 if localename:
Matthias Klosef3f231f2005-09-20 07:02:49 +0000487 if variable == 'LANGUAGE':
488 localename = localename.split(':')[0]
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000489 break
490 else:
491 localename = 'C'
492 return _parse_localename(localename)
493
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000494
495def getlocale(category=LC_CTYPE):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000496
497 """ Returns the current setting for the given locale category as
498 tuple (language code, encoding).
499
500 category may be one of the LC_* value except LC_ALL. It
501 defaults to LC_CTYPE.
502
503 Except for the code 'C', the language code corresponds to RFC
504 1766. code and encoding can be None in case the values cannot
505 be determined.
506
507 """
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000508 localename = _setlocale(category)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000509 if category == LC_ALL and ';' in localename:
Collin Winterce36ad82007-08-30 01:19:48 +0000510 raise TypeError('category LC_ALL is not supported')
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000511 return _parse_localename(localename)
512
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000513def setlocale(category, locale=None):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000514
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000515 """ Set the locale for the given category. The locale can be
516 a string, a locale tuple (language code, encoding), or None.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000517
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000518 Locale tuples are converted to strings the locale aliasing
519 engine. Locale strings are passed directly to the C lib.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000520
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000521 category may be given as one of the LC_* values.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000522
523 """
Guido van Rossum3172c5d2007-10-16 18:12:55 +0000524 if locale and not isinstance(locale, _builtin_str):
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000525 # convert to string
526 locale = normalize(_build_localename(locale))
527 return _setlocale(category, locale)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000528
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000529def resetlocale(category=LC_ALL):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000530
531 """ Sets the locale for category to the default setting.
532
533 The default setting is determined by calling
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000534 getdefaultlocale(). category defaults to LC_ALL.
535
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000536 """
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000537 _setlocale(category, _build_localename(getdefaultlocale()))
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000538
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000539if sys.platform in ('win32', 'darwin', 'mac'):
540 # On Win32, this will return the ANSI code page
541 # On the Mac, it should return the system encoding;
542 # it might return "ascii" instead
543 def getpreferredencoding(do_setlocale = True):
544 """Return the charset that the user is likely using."""
545 import _locale
Tim Petersa326f472002-11-05 03:49:09 +0000546 return _locale._getdefaultlocale()[1]
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000547else:
548 # On Unix, if CODESET is available, use that.
549 try:
550 CODESET
551 except NameError:
552 # Fall back to parsing environment variables :-(
553 def getpreferredencoding(do_setlocale = True):
554 """Return the charset that the user is likely using,
555 by looking at environment variables."""
Martin v. Löwis071ef772008-03-08 11:24:24 +0000556 res = getdefaultlocale()[1]
557 if res is None:
558 # LANG not set, default conservatively to ASCII
559 res = 'ascii'
560 return res
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000561 else:
562 def getpreferredencoding(do_setlocale = True):
563 """Return the charset that the user is likely using,
564 according to the system configuration."""
565 if do_setlocale:
566 oldloc = setlocale(LC_CTYPE)
Jeroen Ruigrok van der Wervenbcf85062009-05-06 05:33:24 +0000567 try:
568 setlocale(LC_CTYPE, "")
Jeroen Ruigrok van der Werven6ca2e0a2009-05-06 13:18:35 +0000569 except Error:
Jeroen Ruigrok van der Wervenbcf85062009-05-06 05:33:24 +0000570 pass
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000571 result = nl_langinfo(CODESET)
572 setlocale(LC_CTYPE, oldloc)
573 return result
574 else:
575 return nl_langinfo(CODESET)
Tim Peters230a60c2002-11-09 05:08:07 +0000576
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000577
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000578### Database
579#
580# The following data was extracted from the locale.alias file which
581# comes with X11 and then hand edited removing the explicit encoding
582# definitions and adding some more aliases. The file is usually
583# available as /usr/lib/X11/locale/locale.alias.
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000584#
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000585
586#
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000587# The local_encoding_alias table maps lowercase encoding alias names
588# to C locale encoding names (case-sensitive). Note that normalize()
589# first looks up the encoding in the encodings.aliases dictionary and
590# then applies this mapping to find the correct C lib name for the
591# encoding.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000592#
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000593locale_encoding_alias = {
594
595 # Mappings for non-standard encoding names used in locale names
596 '437': 'C',
597 'c': 'C',
598 'en': 'ISO8859-1',
599 'jis': 'JIS7',
600 'jis7': 'JIS7',
601 'ajec': 'eucJP',
602
603 # Mappings from Python codec names to C lib encoding names
604 'ascii': 'ISO8859-1',
605 'latin_1': 'ISO8859-1',
606 'iso8859_1': 'ISO8859-1',
607 'iso8859_10': 'ISO8859-10',
608 'iso8859_11': 'ISO8859-11',
609 'iso8859_13': 'ISO8859-13',
610 'iso8859_14': 'ISO8859-14',
611 'iso8859_15': 'ISO8859-15',
612 'iso8859_2': 'ISO8859-2',
613 'iso8859_3': 'ISO8859-3',
614 'iso8859_4': 'ISO8859-4',
615 'iso8859_5': 'ISO8859-5',
616 'iso8859_6': 'ISO8859-6',
617 'iso8859_7': 'ISO8859-7',
618 'iso8859_8': 'ISO8859-8',
619 'iso8859_9': 'ISO8859-9',
620 'iso2022_jp': 'JIS7',
621 'shift_jis': 'SJIS',
622 'tactis': 'TACTIS',
623 'euc_jp': 'eucJP',
624 'euc_kr': 'eucKR',
Marc-André Lemburgb4cebd42004-12-13 19:56:01 +0000625 'utf_8': 'UTF8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000626 'koi8_r': 'KOI8-R',
627 'koi8_u': 'KOI8-U',
628 # XXX This list is still incomplete. If you know more
629 # mappings, please file a bug report. Thanks.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000630}
631
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000632#
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000633# The locale_alias table maps lowercase alias names to C locale names
634# (case-sensitive). Encodings are always separated from the locale
635# name using a dot ('.'); they should only be given in case the
636# language name is needed to interpret the given encoding alias
637# correctly (CJK codes often have this need).
638#
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000639# Note that the normalize() function which uses this tables
640# removes '_' and '-' characters from the encoding part of the
641# locale name before doing the lookup. This saves a lot of
642# space in the table.
643#
644# MAL 2004-12-10:
645# Updated alias mapping to most recent locale.alias file
646# from X.org distribution using makelocalealias.py.
647#
648# These are the differences compared to the old mapping (Python 2.4
649# and older):
650#
651# updated 'bg' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
652# updated 'bg_bg' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
653# updated 'bulgarian' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
654# updated 'cz' -> 'cz_CZ.ISO8859-2' to 'cs_CZ.ISO8859-2'
655# updated 'cz_cz' -> 'cz_CZ.ISO8859-2' to 'cs_CZ.ISO8859-2'
656# updated 'czech' -> 'cs_CS.ISO8859-2' to 'cs_CZ.ISO8859-2'
657# updated 'dutch' -> 'nl_BE.ISO8859-1' to 'nl_NL.ISO8859-1'
658# updated 'et' -> 'et_EE.ISO8859-4' to 'et_EE.ISO8859-15'
659# updated 'et_ee' -> 'et_EE.ISO8859-4' to 'et_EE.ISO8859-15'
660# updated 'fi' -> 'fi_FI.ISO8859-1' to 'fi_FI.ISO8859-15'
661# updated 'fi_fi' -> 'fi_FI.ISO8859-1' to 'fi_FI.ISO8859-15'
662# updated 'iw' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
663# updated 'iw_il' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
664# updated 'japanese' -> 'ja_JP.SJIS' to 'ja_JP.eucJP'
665# updated 'lt' -> 'lt_LT.ISO8859-4' to 'lt_LT.ISO8859-13'
666# updated 'lv' -> 'lv_LV.ISO8859-4' to 'lv_LV.ISO8859-13'
667# updated 'sl' -> 'sl_CS.ISO8859-2' to 'sl_SI.ISO8859-2'
668# updated 'slovene' -> 'sl_CS.ISO8859-2' to 'sl_SI.ISO8859-2'
669# updated 'th_th' -> 'th_TH.TACTIS' to 'th_TH.ISO8859-11'
670# updated 'zh_cn' -> 'zh_CN.eucCN' to 'zh_CN.gb2312'
671# updated 'zh_cn.big5' -> 'zh_TW.eucTW' to 'zh_TW.big5'
672# updated 'zh_tw' -> 'zh_TW.eucTW' to 'zh_TW.big5'
673#
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000674# MAL 2008-05-30:
675# Updated alias mapping to most recent locale.alias file
676# from X.org distribution using makelocalealias.py.
677#
678# These are the differences compared to the old mapping (Python 2.5
679# and older):
680#
681# updated 'cs_cs.iso88592' -> 'cs_CZ.ISO8859-2' to 'cs_CS.ISO8859-2'
682# updated 'serbocroatian' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
683# updated 'sh' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
684# updated 'sh_hr.iso88592' -> 'sh_HR.ISO8859-2' to 'hr_HR.ISO8859-2'
685# updated 'sh_sp' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
686# updated 'sh_yu' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
687# updated 'sp' -> 'sp_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
688# updated 'sp_yu' -> 'sp_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
689# updated 'sr' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
690# updated 'sr@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
691# updated 'sr_sp' -> 'sr_SP.ISO8859-2' to 'sr_CS.ISO8859-2'
692# updated 'sr_yu' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
693# updated 'sr_yu.cp1251@cyrillic' -> 'sr_YU.CP1251' to 'sr_CS.CP1251'
694# updated 'sr_yu.iso88592' -> 'sr_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
695# updated 'sr_yu.iso88595' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
696# updated 'sr_yu.iso88595@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
697# updated 'sr_yu.microsoftcp1251@cyrillic' -> 'sr_YU.CP1251' to 'sr_CS.CP1251'
698# updated 'sr_yu.utf8@cyrillic' -> 'sr_YU.UTF-8' to 'sr_CS.UTF-8'
699# updated 'sr_yu@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
700
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000701locale_alias = {
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000702 'a3': 'a3_AZ.KOI8-C',
703 'a3_az': 'a3_AZ.KOI8-C',
704 'a3_az.koi8c': 'a3_AZ.KOI8-C',
705 'af': 'af_ZA.ISO8859-1',
706 'af_za': 'af_ZA.ISO8859-1',
707 'af_za.iso88591': 'af_ZA.ISO8859-1',
708 'am': 'am_ET.UTF-8',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000709 'am_et': 'am_ET.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000710 'american': 'en_US.ISO8859-1',
711 'american.iso88591': 'en_US.ISO8859-1',
712 'ar': 'ar_AA.ISO8859-6',
713 'ar_aa': 'ar_AA.ISO8859-6',
714 'ar_aa.iso88596': 'ar_AA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000715 'ar_ae': 'ar_AE.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000716 'ar_ae.iso88596': 'ar_AE.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000717 'ar_bh': 'ar_BH.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000718 'ar_bh.iso88596': 'ar_BH.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000719 'ar_dz': 'ar_DZ.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000720 'ar_dz.iso88596': 'ar_DZ.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000721 'ar_eg': 'ar_EG.ISO8859-6',
722 'ar_eg.iso88596': 'ar_EG.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000723 'ar_iq': 'ar_IQ.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000724 'ar_iq.iso88596': 'ar_IQ.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000725 'ar_jo': 'ar_JO.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000726 'ar_jo.iso88596': 'ar_JO.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000727 'ar_kw': 'ar_KW.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000728 'ar_kw.iso88596': 'ar_KW.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000729 'ar_lb': 'ar_LB.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000730 'ar_lb.iso88596': 'ar_LB.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000731 'ar_ly': 'ar_LY.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000732 'ar_ly.iso88596': 'ar_LY.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000733 'ar_ma': 'ar_MA.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000734 'ar_ma.iso88596': 'ar_MA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000735 'ar_om': 'ar_OM.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000736 'ar_om.iso88596': 'ar_OM.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000737 'ar_qa': 'ar_QA.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000738 'ar_qa.iso88596': 'ar_QA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000739 'ar_sa': 'ar_SA.ISO8859-6',
740 'ar_sa.iso88596': 'ar_SA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000741 'ar_sd': 'ar_SD.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000742 'ar_sd.iso88596': 'ar_SD.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000743 'ar_sy': 'ar_SY.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000744 'ar_sy.iso88596': 'ar_SY.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000745 'ar_tn': 'ar_TN.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000746 'ar_tn.iso88596': 'ar_TN.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000747 'ar_ye': 'ar_YE.ISO8859-6',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000748 'ar_ye.iso88596': 'ar_YE.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000749 'arabic': 'ar_AA.ISO8859-6',
750 'arabic.iso88596': 'ar_AA.ISO8859-6',
751 'az': 'az_AZ.ISO8859-9E',
752 'az_az': 'az_AZ.ISO8859-9E',
753 'az_az.iso88599e': 'az_AZ.ISO8859-9E',
754 'be': 'be_BY.CP1251',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000755 'be_by': 'be_BY.CP1251',
756 'be_by.cp1251': 'be_BY.CP1251',
757 'be_by.microsoftcp1251': 'be_BY.CP1251',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000758 'bg': 'bg_BG.CP1251',
759 'bg_bg': 'bg_BG.CP1251',
760 'bg_bg.cp1251': 'bg_BG.CP1251',
761 'bg_bg.iso88595': 'bg_BG.ISO8859-5',
762 'bg_bg.koi8r': 'bg_BG.KOI8-R',
763 'bg_bg.microsoftcp1251': 'bg_BG.CP1251',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000764 'bn_in': 'bn_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000765 'bokmal': 'nb_NO.ISO8859-1',
766 'bokm\xe5l': 'nb_NO.ISO8859-1',
767 'br': 'br_FR.ISO8859-1',
768 'br_fr': 'br_FR.ISO8859-1',
769 'br_fr.iso88591': 'br_FR.ISO8859-1',
770 'br_fr.iso885914': 'br_FR.ISO8859-14',
771 'br_fr.iso885915': 'br_FR.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000772 'br_fr.iso885915@euro': 'br_FR.ISO8859-15',
773 'br_fr.utf8@euro': 'br_FR.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000774 'br_fr@euro': 'br_FR.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000775 'bs': 'bs_BA.ISO8859-2',
776 'bs_ba': 'bs_BA.ISO8859-2',
777 'bs_ba.iso88592': 'bs_BA.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000778 'bulgarian': 'bg_BG.CP1251',
779 'c': 'C',
780 'c-french': 'fr_CA.ISO8859-1',
781 'c-french.iso88591': 'fr_CA.ISO8859-1',
782 'c.en': 'C',
783 'c.iso88591': 'en_US.ISO8859-1',
784 'c_c': 'C',
785 'c_c.c': 'C',
786 'ca': 'ca_ES.ISO8859-1',
787 'ca_es': 'ca_ES.ISO8859-1',
788 'ca_es.iso88591': 'ca_ES.ISO8859-1',
789 'ca_es.iso885915': 'ca_ES.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000790 'ca_es.iso885915@euro': 'ca_ES.ISO8859-15',
791 'ca_es.utf8@euro': 'ca_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000792 'ca_es@euro': 'ca_ES.ISO8859-15',
793 'catalan': 'ca_ES.ISO8859-1',
794 'cextend': 'en_US.ISO8859-1',
795 'cextend.en': 'en_US.ISO8859-1',
796 'chinese-s': 'zh_CN.eucCN',
797 'chinese-t': 'zh_TW.eucTW',
798 'croatian': 'hr_HR.ISO8859-2',
799 'cs': 'cs_CZ.ISO8859-2',
800 'cs_cs': 'cs_CZ.ISO8859-2',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000801 'cs_cs.iso88592': 'cs_CS.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000802 'cs_cz': 'cs_CZ.ISO8859-2',
803 'cs_cz.iso88592': 'cs_CZ.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000804 'cy': 'cy_GB.ISO8859-1',
805 'cy_gb': 'cy_GB.ISO8859-1',
806 'cy_gb.iso88591': 'cy_GB.ISO8859-1',
807 'cy_gb.iso885914': 'cy_GB.ISO8859-14',
808 'cy_gb.iso885915': 'cy_GB.ISO8859-15',
809 'cy_gb@euro': 'cy_GB.ISO8859-15',
810 'cz': 'cs_CZ.ISO8859-2',
811 'cz_cz': 'cs_CZ.ISO8859-2',
812 'czech': 'cs_CZ.ISO8859-2',
813 'da': 'da_DK.ISO8859-1',
814 'da_dk': 'da_DK.ISO8859-1',
815 'da_dk.88591': 'da_DK.ISO8859-1',
816 'da_dk.885915': 'da_DK.ISO8859-15',
817 'da_dk.iso88591': 'da_DK.ISO8859-1',
818 'da_dk.iso885915': 'da_DK.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000819 'da_dk@euro': 'da_DK.ISO8859-15',
820 'danish': 'da_DK.ISO8859-1',
821 'danish.iso88591': 'da_DK.ISO8859-1',
822 'dansk': 'da_DK.ISO8859-1',
823 'de': 'de_DE.ISO8859-1',
824 'de_at': 'de_AT.ISO8859-1',
825 'de_at.iso88591': 'de_AT.ISO8859-1',
826 'de_at.iso885915': 'de_AT.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000827 'de_at.iso885915@euro': 'de_AT.ISO8859-15',
828 'de_at.utf8@euro': 'de_AT.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000829 'de_at@euro': 'de_AT.ISO8859-15',
830 'de_be': 'de_BE.ISO8859-1',
831 'de_be.iso88591': 'de_BE.ISO8859-1',
832 'de_be.iso885915': 'de_BE.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000833 'de_be.iso885915@euro': 'de_BE.ISO8859-15',
834 'de_be.utf8@euro': 'de_BE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000835 'de_be@euro': 'de_BE.ISO8859-15',
836 'de_ch': 'de_CH.ISO8859-1',
837 'de_ch.iso88591': 'de_CH.ISO8859-1',
838 'de_ch.iso885915': 'de_CH.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000839 'de_ch@euro': 'de_CH.ISO8859-15',
840 'de_de': 'de_DE.ISO8859-1',
841 'de_de.88591': 'de_DE.ISO8859-1',
842 'de_de.885915': 'de_DE.ISO8859-15',
843 'de_de.885915@euro': 'de_DE.ISO8859-15',
844 'de_de.iso88591': 'de_DE.ISO8859-1',
845 'de_de.iso885915': 'de_DE.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000846 'de_de.iso885915@euro': 'de_DE.ISO8859-15',
847 'de_de.utf8@euro': 'de_DE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000848 'de_de@euro': 'de_DE.ISO8859-15',
849 'de_lu': 'de_LU.ISO8859-1',
850 'de_lu.iso88591': 'de_LU.ISO8859-1',
851 'de_lu.iso885915': 'de_LU.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000852 'de_lu.iso885915@euro': 'de_LU.ISO8859-15',
853 'de_lu.utf8@euro': 'de_LU.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000854 'de_lu@euro': 'de_LU.ISO8859-15',
855 'deutsch': 'de_DE.ISO8859-1',
856 'dutch': 'nl_NL.ISO8859-1',
857 'dutch.iso88591': 'nl_BE.ISO8859-1',
858 'ee': 'ee_EE.ISO8859-4',
859 'ee_ee': 'ee_EE.ISO8859-4',
860 'ee_ee.iso88594': 'ee_EE.ISO8859-4',
861 'eesti': 'et_EE.ISO8859-1',
862 'el': 'el_GR.ISO8859-7',
863 'el_gr': 'el_GR.ISO8859-7',
864 'el_gr.iso88597': 'el_GR.ISO8859-7',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000865 'el_gr@euro': 'el_GR.ISO8859-15',
866 'en': 'en_US.ISO8859-1',
867 'en.iso88591': 'en_US.ISO8859-1',
868 'en_au': 'en_AU.ISO8859-1',
869 'en_au.iso88591': 'en_AU.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000870 'en_be': 'en_BE.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000871 'en_be@euro': 'en_BE.ISO8859-15',
872 'en_bw': 'en_BW.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000873 'en_bw.iso88591': 'en_BW.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000874 'en_ca': 'en_CA.ISO8859-1',
875 'en_ca.iso88591': 'en_CA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000876 'en_gb': 'en_GB.ISO8859-1',
877 'en_gb.88591': 'en_GB.ISO8859-1',
878 'en_gb.iso88591': 'en_GB.ISO8859-1',
879 'en_gb.iso885915': 'en_GB.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000880 'en_gb@euro': 'en_GB.ISO8859-15',
881 'en_hk': 'en_HK.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000882 'en_hk.iso88591': 'en_HK.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000883 'en_ie': 'en_IE.ISO8859-1',
884 'en_ie.iso88591': 'en_IE.ISO8859-1',
885 'en_ie.iso885915': 'en_IE.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000886 'en_ie.iso885915@euro': 'en_IE.ISO8859-15',
887 'en_ie.utf8@euro': 'en_IE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000888 'en_ie@euro': 'en_IE.ISO8859-15',
889 'en_in': 'en_IN.ISO8859-1',
890 'en_nz': 'en_NZ.ISO8859-1',
891 'en_nz.iso88591': 'en_NZ.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000892 'en_ph': 'en_PH.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000893 'en_ph.iso88591': 'en_PH.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000894 'en_sg': 'en_SG.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000895 'en_sg.iso88591': 'en_SG.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000896 'en_uk': 'en_GB.ISO8859-1',
897 'en_us': 'en_US.ISO8859-1',
898 'en_us.88591': 'en_US.ISO8859-1',
899 'en_us.885915': 'en_US.ISO8859-15',
900 'en_us.iso88591': 'en_US.ISO8859-1',
901 'en_us.iso885915': 'en_US.ISO8859-15',
902 'en_us.iso885915@euro': 'en_US.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000903 'en_us@euro': 'en_US.ISO8859-15',
904 'en_us@euro@euro': 'en_US.ISO8859-15',
905 'en_za': 'en_ZA.ISO8859-1',
906 'en_za.88591': 'en_ZA.ISO8859-1',
907 'en_za.iso88591': 'en_ZA.ISO8859-1',
908 'en_za.iso885915': 'en_ZA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000909 'en_za@euro': 'en_ZA.ISO8859-15',
910 'en_zw': 'en_ZW.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000911 'en_zw.iso88591': 'en_ZW.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000912 'eng_gb': 'en_GB.ISO8859-1',
913 'eng_gb.8859': 'en_GB.ISO8859-1',
914 'english': 'en_EN.ISO8859-1',
915 'english.iso88591': 'en_EN.ISO8859-1',
916 'english_uk': 'en_GB.ISO8859-1',
917 'english_uk.8859': 'en_GB.ISO8859-1',
918 'english_united-states': 'en_US.ISO8859-1',
919 'english_united-states.437': 'C',
920 'english_us': 'en_US.ISO8859-1',
921 'english_us.8859': 'en_US.ISO8859-1',
922 'english_us.ascii': 'en_US.ISO8859-1',
923 'eo': 'eo_XX.ISO8859-3',
924 'eo_eo': 'eo_EO.ISO8859-3',
925 'eo_eo.iso88593': 'eo_EO.ISO8859-3',
926 'eo_xx': 'eo_XX.ISO8859-3',
927 'eo_xx.iso88593': 'eo_XX.ISO8859-3',
928 'es': 'es_ES.ISO8859-1',
929 'es_ar': 'es_AR.ISO8859-1',
930 'es_ar.iso88591': 'es_AR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000931 'es_bo': 'es_BO.ISO8859-1',
932 'es_bo.iso88591': 'es_BO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000933 'es_cl': 'es_CL.ISO8859-1',
934 'es_cl.iso88591': 'es_CL.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000935 'es_co': 'es_CO.ISO8859-1',
936 'es_co.iso88591': 'es_CO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000937 'es_cr': 'es_CR.ISO8859-1',
938 'es_cr.iso88591': 'es_CR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000939 'es_do': 'es_DO.ISO8859-1',
940 'es_do.iso88591': 'es_DO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000941 'es_ec': 'es_EC.ISO8859-1',
942 'es_ec.iso88591': 'es_EC.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000943 'es_es': 'es_ES.ISO8859-1',
944 'es_es.88591': 'es_ES.ISO8859-1',
945 'es_es.iso88591': 'es_ES.ISO8859-1',
946 'es_es.iso885915': 'es_ES.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000947 'es_es.iso885915@euro': 'es_ES.ISO8859-15',
948 'es_es.utf8@euro': 'es_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000949 'es_es@euro': 'es_ES.ISO8859-15',
950 'es_gt': 'es_GT.ISO8859-1',
951 'es_gt.iso88591': 'es_GT.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000952 'es_hn': 'es_HN.ISO8859-1',
953 'es_hn.iso88591': 'es_HN.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000954 'es_mx': 'es_MX.ISO8859-1',
955 'es_mx.iso88591': 'es_MX.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000956 'es_ni': 'es_NI.ISO8859-1',
957 'es_ni.iso88591': 'es_NI.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000958 'es_pa': 'es_PA.ISO8859-1',
959 'es_pa.iso88591': 'es_PA.ISO8859-1',
960 'es_pa.iso885915': 'es_PA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000961 'es_pa@euro': 'es_PA.ISO8859-15',
962 'es_pe': 'es_PE.ISO8859-1',
963 'es_pe.iso88591': 'es_PE.ISO8859-1',
964 'es_pe.iso885915': 'es_PE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000965 'es_pe@euro': 'es_PE.ISO8859-15',
966 'es_pr': 'es_PR.ISO8859-1',
967 'es_pr.iso88591': 'es_PR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000968 'es_py': 'es_PY.ISO8859-1',
969 'es_py.iso88591': 'es_PY.ISO8859-1',
970 'es_py.iso885915': 'es_PY.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000971 'es_py@euro': 'es_PY.ISO8859-15',
972 'es_sv': 'es_SV.ISO8859-1',
973 'es_sv.iso88591': 'es_SV.ISO8859-1',
974 'es_sv.iso885915': 'es_SV.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000975 'es_sv@euro': 'es_SV.ISO8859-15',
976 'es_us': 'es_US.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000977 'es_us.iso88591': 'es_US.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000978 'es_uy': 'es_UY.ISO8859-1',
979 'es_uy.iso88591': 'es_UY.ISO8859-1',
980 'es_uy.iso885915': 'es_UY.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000981 'es_uy@euro': 'es_UY.ISO8859-15',
982 'es_ve': 'es_VE.ISO8859-1',
983 'es_ve.iso88591': 'es_VE.ISO8859-1',
984 'es_ve.iso885915': 'es_VE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000985 'es_ve@euro': 'es_VE.ISO8859-15',
986 'estonian': 'et_EE.ISO8859-1',
987 'et': 'et_EE.ISO8859-15',
988 'et_ee': 'et_EE.ISO8859-15',
989 'et_ee.iso88591': 'et_EE.ISO8859-1',
990 'et_ee.iso885913': 'et_EE.ISO8859-13',
991 'et_ee.iso885915': 'et_EE.ISO8859-15',
992 'et_ee.iso88594': 'et_EE.ISO8859-4',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000993 'et_ee@euro': 'et_EE.ISO8859-15',
994 'eu': 'eu_ES.ISO8859-1',
995 'eu_es': 'eu_ES.ISO8859-1',
996 'eu_es.iso88591': 'eu_ES.ISO8859-1',
997 'eu_es.iso885915': 'eu_ES.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +0000998 'eu_es.iso885915@euro': 'eu_ES.ISO8859-15',
999 'eu_es.utf8@euro': 'eu_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001000 'eu_es@euro': 'eu_ES.ISO8859-15',
1001 'fa': 'fa_IR.UTF-8',
1002 'fa_ir': 'fa_IR.UTF-8',
1003 'fa_ir.isiri3342': 'fa_IR.ISIRI-3342',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001004 'fi': 'fi_FI.ISO8859-15',
1005 'fi_fi': 'fi_FI.ISO8859-15',
1006 'fi_fi.88591': 'fi_FI.ISO8859-1',
1007 'fi_fi.iso88591': 'fi_FI.ISO8859-1',
1008 'fi_fi.iso885915': 'fi_FI.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001009 'fi_fi.iso885915@euro': 'fi_FI.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001010 'fi_fi.utf8@euro': 'fi_FI.UTF-8',
1011 'fi_fi@euro': 'fi_FI.ISO8859-15',
1012 'finnish': 'fi_FI.ISO8859-1',
1013 'finnish.iso88591': 'fi_FI.ISO8859-1',
1014 'fo': 'fo_FO.ISO8859-1',
1015 'fo_fo': 'fo_FO.ISO8859-1',
1016 'fo_fo.iso88591': 'fo_FO.ISO8859-1',
1017 'fo_fo.iso885915': 'fo_FO.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001018 'fo_fo@euro': 'fo_FO.ISO8859-15',
1019 'fr': 'fr_FR.ISO8859-1',
1020 'fr_be': 'fr_BE.ISO8859-1',
1021 'fr_be.88591': 'fr_BE.ISO8859-1',
1022 'fr_be.iso88591': 'fr_BE.ISO8859-1',
1023 'fr_be.iso885915': 'fr_BE.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001024 'fr_be.iso885915@euro': 'fr_BE.ISO8859-15',
1025 'fr_be.utf8@euro': 'fr_BE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001026 'fr_be@euro': 'fr_BE.ISO8859-15',
1027 'fr_ca': 'fr_CA.ISO8859-1',
1028 'fr_ca.88591': 'fr_CA.ISO8859-1',
1029 'fr_ca.iso88591': 'fr_CA.ISO8859-1',
1030 'fr_ca.iso885915': 'fr_CA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001031 'fr_ca@euro': 'fr_CA.ISO8859-15',
1032 'fr_ch': 'fr_CH.ISO8859-1',
1033 'fr_ch.88591': 'fr_CH.ISO8859-1',
1034 'fr_ch.iso88591': 'fr_CH.ISO8859-1',
1035 'fr_ch.iso885915': 'fr_CH.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001036 'fr_ch@euro': 'fr_CH.ISO8859-15',
1037 'fr_fr': 'fr_FR.ISO8859-1',
1038 'fr_fr.88591': 'fr_FR.ISO8859-1',
1039 'fr_fr.iso88591': 'fr_FR.ISO8859-1',
1040 'fr_fr.iso885915': 'fr_FR.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001041 'fr_fr.iso885915@euro': 'fr_FR.ISO8859-15',
1042 'fr_fr.utf8@euro': 'fr_FR.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001043 'fr_fr@euro': 'fr_FR.ISO8859-15',
1044 'fr_lu': 'fr_LU.ISO8859-1',
1045 'fr_lu.88591': 'fr_LU.ISO8859-1',
1046 'fr_lu.iso88591': 'fr_LU.ISO8859-1',
1047 'fr_lu.iso885915': 'fr_LU.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001048 'fr_lu.iso885915@euro': 'fr_LU.ISO8859-15',
1049 'fr_lu.utf8@euro': 'fr_LU.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001050 'fr_lu@euro': 'fr_LU.ISO8859-15',
1051 'fran\xe7ais': 'fr_FR.ISO8859-1',
1052 'fre_fr': 'fr_FR.ISO8859-1',
1053 'fre_fr.8859': 'fr_FR.ISO8859-1',
1054 'french': 'fr_FR.ISO8859-1',
1055 'french.iso88591': 'fr_CH.ISO8859-1',
1056 'french_france': 'fr_FR.ISO8859-1',
1057 'french_france.8859': 'fr_FR.ISO8859-1',
1058 'ga': 'ga_IE.ISO8859-1',
1059 'ga_ie': 'ga_IE.ISO8859-1',
1060 'ga_ie.iso88591': 'ga_IE.ISO8859-1',
1061 'ga_ie.iso885914': 'ga_IE.ISO8859-14',
1062 'ga_ie.iso885915': 'ga_IE.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001063 'ga_ie.iso885915@euro': 'ga_IE.ISO8859-15',
1064 'ga_ie.utf8@euro': 'ga_IE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001065 'ga_ie@euro': 'ga_IE.ISO8859-15',
1066 'galego': 'gl_ES.ISO8859-1',
1067 'galician': 'gl_ES.ISO8859-1',
1068 'gd': 'gd_GB.ISO8859-1',
1069 'gd_gb': 'gd_GB.ISO8859-1',
1070 'gd_gb.iso88591': 'gd_GB.ISO8859-1',
1071 'gd_gb.iso885914': 'gd_GB.ISO8859-14',
1072 'gd_gb.iso885915': 'gd_GB.ISO8859-15',
1073 'gd_gb@euro': 'gd_GB.ISO8859-15',
1074 'ger_de': 'de_DE.ISO8859-1',
1075 'ger_de.8859': 'de_DE.ISO8859-1',
1076 'german': 'de_DE.ISO8859-1',
1077 'german.iso88591': 'de_CH.ISO8859-1',
1078 'german_germany': 'de_DE.ISO8859-1',
1079 'german_germany.8859': 'de_DE.ISO8859-1',
1080 'gl': 'gl_ES.ISO8859-1',
1081 'gl_es': 'gl_ES.ISO8859-1',
1082 'gl_es.iso88591': 'gl_ES.ISO8859-1',
1083 'gl_es.iso885915': 'gl_ES.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001084 'gl_es.iso885915@euro': 'gl_ES.ISO8859-15',
1085 'gl_es.utf8@euro': 'gl_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001086 'gl_es@euro': 'gl_ES.ISO8859-15',
1087 'greek': 'el_GR.ISO8859-7',
1088 'greek.iso88597': 'el_GR.ISO8859-7',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001089 'gu_in': 'gu_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001090 'gv': 'gv_GB.ISO8859-1',
1091 'gv_gb': 'gv_GB.ISO8859-1',
1092 'gv_gb.iso88591': 'gv_GB.ISO8859-1',
1093 'gv_gb.iso885914': 'gv_GB.ISO8859-14',
1094 'gv_gb.iso885915': 'gv_GB.ISO8859-15',
1095 'gv_gb@euro': 'gv_GB.ISO8859-15',
1096 'he': 'he_IL.ISO8859-8',
1097 'he_il': 'he_IL.ISO8859-8',
1098 'he_il.cp1255': 'he_IL.CP1255',
1099 'he_il.iso88598': 'he_IL.ISO8859-8',
1100 'he_il.microsoftcp1255': 'he_IL.CP1255',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001101 'hebrew': 'iw_IL.ISO8859-8',
1102 'hebrew.iso88598': 'iw_IL.ISO8859-8',
1103 'hi': 'hi_IN.ISCII-DEV',
1104 'hi_in': 'hi_IN.ISCII-DEV',
1105 'hi_in.isciidev': 'hi_IN.ISCII-DEV',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001106 'hr': 'hr_HR.ISO8859-2',
1107 'hr_hr': 'hr_HR.ISO8859-2',
1108 'hr_hr.iso88592': 'hr_HR.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001109 'hrvatski': 'hr_HR.ISO8859-2',
1110 'hu': 'hu_HU.ISO8859-2',
1111 'hu_hu': 'hu_HU.ISO8859-2',
1112 'hu_hu.iso88592': 'hu_HU.ISO8859-2',
1113 'hungarian': 'hu_HU.ISO8859-2',
1114 'icelandic': 'is_IS.ISO8859-1',
1115 'icelandic.iso88591': 'is_IS.ISO8859-1',
1116 'id': 'id_ID.ISO8859-1',
1117 'id_id': 'id_ID.ISO8859-1',
1118 'in': 'id_ID.ISO8859-1',
1119 'in_id': 'id_ID.ISO8859-1',
1120 'is': 'is_IS.ISO8859-1',
1121 'is_is': 'is_IS.ISO8859-1',
1122 'is_is.iso88591': 'is_IS.ISO8859-1',
1123 'is_is.iso885915': 'is_IS.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001124 'is_is@euro': 'is_IS.ISO8859-15',
1125 'iso-8859-1': 'en_US.ISO8859-1',
1126 'iso-8859-15': 'en_US.ISO8859-15',
1127 'iso8859-1': 'en_US.ISO8859-1',
1128 'iso8859-15': 'en_US.ISO8859-15',
1129 'iso_8859_1': 'en_US.ISO8859-1',
1130 'iso_8859_15': 'en_US.ISO8859-15',
1131 'it': 'it_IT.ISO8859-1',
1132 'it_ch': 'it_CH.ISO8859-1',
1133 'it_ch.iso88591': 'it_CH.ISO8859-1',
1134 'it_ch.iso885915': 'it_CH.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001135 'it_ch@euro': 'it_CH.ISO8859-15',
1136 'it_it': 'it_IT.ISO8859-1',
1137 'it_it.88591': 'it_IT.ISO8859-1',
1138 'it_it.iso88591': 'it_IT.ISO8859-1',
1139 'it_it.iso885915': 'it_IT.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001140 'it_it.iso885915@euro': 'it_IT.ISO8859-15',
1141 'it_it.utf8@euro': 'it_IT.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001142 'it_it@euro': 'it_IT.ISO8859-15',
1143 'italian': 'it_IT.ISO8859-1',
1144 'italian.iso88591': 'it_IT.ISO8859-1',
1145 'iu': 'iu_CA.NUNACOM-8',
1146 'iu_ca': 'iu_CA.NUNACOM-8',
1147 'iu_ca.nunacom8': 'iu_CA.NUNACOM-8',
1148 'iw': 'he_IL.ISO8859-8',
1149 'iw_il': 'he_IL.ISO8859-8',
1150 'iw_il.iso88598': 'he_IL.ISO8859-8',
1151 'ja': 'ja_JP.eucJP',
1152 'ja.jis': 'ja_JP.JIS7',
1153 'ja.sjis': 'ja_JP.SJIS',
1154 'ja_jp': 'ja_JP.eucJP',
1155 'ja_jp.ajec': 'ja_JP.eucJP',
1156 'ja_jp.euc': 'ja_JP.eucJP',
1157 'ja_jp.eucjp': 'ja_JP.eucJP',
1158 'ja_jp.iso-2022-jp': 'ja_JP.JIS7',
1159 'ja_jp.iso2022jp': 'ja_JP.JIS7',
1160 'ja_jp.jis': 'ja_JP.JIS7',
1161 'ja_jp.jis7': 'ja_JP.JIS7',
1162 'ja_jp.mscode': 'ja_JP.SJIS',
1163 'ja_jp.sjis': 'ja_JP.SJIS',
1164 'ja_jp.ujis': 'ja_JP.eucJP',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001165 'japan': 'ja_JP.eucJP',
1166 'japanese': 'ja_JP.eucJP',
1167 'japanese-euc': 'ja_JP.eucJP',
1168 'japanese.euc': 'ja_JP.eucJP',
1169 'japanese.sjis': 'ja_JP.SJIS',
1170 'jp_jp': 'ja_JP.eucJP',
1171 'ka': 'ka_GE.GEORGIAN-ACADEMY',
1172 'ka_ge': 'ka_GE.GEORGIAN-ACADEMY',
1173 'ka_ge.georgianacademy': 'ka_GE.GEORGIAN-ACADEMY',
1174 'ka_ge.georgianps': 'ka_GE.GEORGIAN-PS',
1175 'ka_ge.georgianrs': 'ka_GE.GEORGIAN-ACADEMY',
1176 'kl': 'kl_GL.ISO8859-1',
1177 'kl_gl': 'kl_GL.ISO8859-1',
1178 'kl_gl.iso88591': 'kl_GL.ISO8859-1',
1179 'kl_gl.iso885915': 'kl_GL.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001180 'kl_gl@euro': 'kl_GL.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001181 'km_kh': 'km_KH.UTF-8',
1182 'kn_in': 'kn_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001183 'ko': 'ko_KR.eucKR',
1184 'ko_kr': 'ko_KR.eucKR',
1185 'ko_kr.euc': 'ko_KR.eucKR',
1186 'ko_kr.euckr': 'ko_KR.eucKR',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001187 'korean': 'ko_KR.eucKR',
1188 'korean.euc': 'ko_KR.eucKR',
1189 'kw': 'kw_GB.ISO8859-1',
1190 'kw_gb': 'kw_GB.ISO8859-1',
1191 'kw_gb.iso88591': 'kw_GB.ISO8859-1',
1192 'kw_gb.iso885914': 'kw_GB.ISO8859-14',
1193 'kw_gb.iso885915': 'kw_GB.ISO8859-15',
1194 'kw_gb@euro': 'kw_GB.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001195 'ky': 'ky_KG.UTF-8',
1196 'ky_kg': 'ky_KG.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001197 'lithuanian': 'lt_LT.ISO8859-13',
1198 'lo': 'lo_LA.MULELAO-1',
1199 'lo_la': 'lo_LA.MULELAO-1',
1200 'lo_la.cp1133': 'lo_LA.IBM-CP1133',
1201 'lo_la.ibmcp1133': 'lo_LA.IBM-CP1133',
1202 'lo_la.mulelao1': 'lo_LA.MULELAO-1',
1203 'lt': 'lt_LT.ISO8859-13',
1204 'lt_lt': 'lt_LT.ISO8859-13',
1205 'lt_lt.iso885913': 'lt_LT.ISO8859-13',
1206 'lt_lt.iso88594': 'lt_LT.ISO8859-4',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001207 'lv': 'lv_LV.ISO8859-13',
1208 'lv_lv': 'lv_LV.ISO8859-13',
1209 'lv_lv.iso885913': 'lv_LV.ISO8859-13',
1210 'lv_lv.iso88594': 'lv_LV.ISO8859-4',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001211 'mi': 'mi_NZ.ISO8859-1',
1212 'mi_nz': 'mi_NZ.ISO8859-1',
1213 'mi_nz.iso88591': 'mi_NZ.ISO8859-1',
1214 'mk': 'mk_MK.ISO8859-5',
1215 'mk_mk': 'mk_MK.ISO8859-5',
1216 'mk_mk.cp1251': 'mk_MK.CP1251',
1217 'mk_mk.iso88595': 'mk_MK.ISO8859-5',
1218 'mk_mk.microsoftcp1251': 'mk_MK.CP1251',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001219 'mr_in': 'mr_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001220 'ms': 'ms_MY.ISO8859-1',
1221 'ms_my': 'ms_MY.ISO8859-1',
1222 'ms_my.iso88591': 'ms_MY.ISO8859-1',
1223 'mt': 'mt_MT.ISO8859-3',
1224 'mt_mt': 'mt_MT.ISO8859-3',
1225 'mt_mt.iso88593': 'mt_MT.ISO8859-3',
1226 'nb': 'nb_NO.ISO8859-1',
1227 'nb_no': 'nb_NO.ISO8859-1',
1228 'nb_no.88591': 'nb_NO.ISO8859-1',
1229 'nb_no.iso88591': 'nb_NO.ISO8859-1',
1230 'nb_no.iso885915': 'nb_NO.ISO8859-15',
1231 'nb_no@euro': 'nb_NO.ISO8859-15',
1232 'nl': 'nl_NL.ISO8859-1',
1233 'nl_be': 'nl_BE.ISO8859-1',
1234 'nl_be.88591': 'nl_BE.ISO8859-1',
1235 'nl_be.iso88591': 'nl_BE.ISO8859-1',
1236 'nl_be.iso885915': 'nl_BE.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001237 'nl_be.iso885915@euro': 'nl_BE.ISO8859-15',
1238 'nl_be.utf8@euro': 'nl_BE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001239 'nl_be@euro': 'nl_BE.ISO8859-15',
1240 'nl_nl': 'nl_NL.ISO8859-1',
1241 'nl_nl.88591': 'nl_NL.ISO8859-1',
1242 'nl_nl.iso88591': 'nl_NL.ISO8859-1',
1243 'nl_nl.iso885915': 'nl_NL.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001244 'nl_nl.iso885915@euro': 'nl_NL.ISO8859-15',
1245 'nl_nl.utf8@euro': 'nl_NL.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001246 'nl_nl@euro': 'nl_NL.ISO8859-15',
1247 'nn': 'nn_NO.ISO8859-1',
1248 'nn_no': 'nn_NO.ISO8859-1',
1249 'nn_no.88591': 'nn_NO.ISO8859-1',
1250 'nn_no.iso88591': 'nn_NO.ISO8859-1',
1251 'nn_no.iso885915': 'nn_NO.ISO8859-15',
1252 'nn_no@euro': 'nn_NO.ISO8859-15',
1253 'no': 'no_NO.ISO8859-1',
1254 'no@nynorsk': 'ny_NO.ISO8859-1',
1255 'no_no': 'no_NO.ISO8859-1',
1256 'no_no.88591': 'no_NO.ISO8859-1',
1257 'no_no.iso88591': 'no_NO.ISO8859-1',
1258 'no_no.iso885915': 'no_NO.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001259 'no_no@euro': 'no_NO.ISO8859-15',
1260 'norwegian': 'no_NO.ISO8859-1',
1261 'norwegian.iso88591': 'no_NO.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001262 'nr': 'nr_ZA.ISO8859-1',
1263 'nr_za': 'nr_ZA.ISO8859-1',
1264 'nr_za.iso88591': 'nr_ZA.ISO8859-1',
1265 'nso': 'nso_ZA.ISO8859-15',
1266 'nso_za': 'nso_ZA.ISO8859-15',
1267 'nso_za.iso885915': 'nso_ZA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001268 'ny': 'ny_NO.ISO8859-1',
1269 'ny_no': 'ny_NO.ISO8859-1',
1270 'ny_no.88591': 'ny_NO.ISO8859-1',
1271 'ny_no.iso88591': 'ny_NO.ISO8859-1',
1272 'ny_no.iso885915': 'ny_NO.ISO8859-15',
1273 'ny_no@euro': 'ny_NO.ISO8859-15',
1274 'nynorsk': 'nn_NO.ISO8859-1',
1275 'oc': 'oc_FR.ISO8859-1',
1276 'oc_fr': 'oc_FR.ISO8859-1',
1277 'oc_fr.iso88591': 'oc_FR.ISO8859-1',
1278 'oc_fr.iso885915': 'oc_FR.ISO8859-15',
1279 'oc_fr@euro': 'oc_FR.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001280 'pa_in': 'pa_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001281 'pd': 'pd_US.ISO8859-1',
1282 'pd_de': 'pd_DE.ISO8859-1',
1283 'pd_de.iso88591': 'pd_DE.ISO8859-1',
1284 'pd_de.iso885915': 'pd_DE.ISO8859-15',
1285 'pd_de@euro': 'pd_DE.ISO8859-15',
1286 'pd_us': 'pd_US.ISO8859-1',
1287 'pd_us.iso88591': 'pd_US.ISO8859-1',
1288 'pd_us.iso885915': 'pd_US.ISO8859-15',
1289 'pd_us@euro': 'pd_US.ISO8859-15',
1290 'ph': 'ph_PH.ISO8859-1',
1291 'ph_ph': 'ph_PH.ISO8859-1',
1292 'ph_ph.iso88591': 'ph_PH.ISO8859-1',
1293 'pl': 'pl_PL.ISO8859-2',
1294 'pl_pl': 'pl_PL.ISO8859-2',
1295 'pl_pl.iso88592': 'pl_PL.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001296 'polish': 'pl_PL.ISO8859-2',
1297 'portuguese': 'pt_PT.ISO8859-1',
1298 'portuguese.iso88591': 'pt_PT.ISO8859-1',
1299 'portuguese_brazil': 'pt_BR.ISO8859-1',
1300 'portuguese_brazil.8859': 'pt_BR.ISO8859-1',
1301 'posix': 'C',
1302 'posix-utf2': 'C',
1303 'pp': 'pp_AN.ISO8859-1',
1304 'pp_an': 'pp_AN.ISO8859-1',
1305 'pp_an.iso88591': 'pp_AN.ISO8859-1',
1306 'pt': 'pt_PT.ISO8859-1',
1307 'pt_br': 'pt_BR.ISO8859-1',
1308 'pt_br.88591': 'pt_BR.ISO8859-1',
1309 'pt_br.iso88591': 'pt_BR.ISO8859-1',
1310 'pt_br.iso885915': 'pt_BR.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001311 'pt_br@euro': 'pt_BR.ISO8859-15',
1312 'pt_pt': 'pt_PT.ISO8859-1',
1313 'pt_pt.88591': 'pt_PT.ISO8859-1',
1314 'pt_pt.iso88591': 'pt_PT.ISO8859-1',
1315 'pt_pt.iso885915': 'pt_PT.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001316 'pt_pt.iso885915@euro': 'pt_PT.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001317 'pt_pt.utf8@euro': 'pt_PT.UTF-8',
1318 'pt_pt@euro': 'pt_PT.ISO8859-15',
1319 'ro': 'ro_RO.ISO8859-2',
1320 'ro_ro': 'ro_RO.ISO8859-2',
1321 'ro_ro.iso88592': 'ro_RO.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001322 'romanian': 'ro_RO.ISO8859-2',
1323 'ru': 'ru_RU.ISO8859-5',
1324 'ru_ru': 'ru_RU.ISO8859-5',
1325 'ru_ru.cp1251': 'ru_RU.CP1251',
1326 'ru_ru.iso88595': 'ru_RU.ISO8859-5',
1327 'ru_ru.koi8r': 'ru_RU.KOI8-R',
1328 'ru_ru.microsoftcp1251': 'ru_RU.CP1251',
1329 'ru_ua': 'ru_UA.KOI8-U',
1330 'ru_ua.cp1251': 'ru_UA.CP1251',
1331 'ru_ua.koi8u': 'ru_UA.KOI8-U',
1332 'ru_ua.microsoftcp1251': 'ru_UA.CP1251',
1333 'rumanian': 'ro_RO.ISO8859-2',
1334 'russian': 'ru_RU.ISO8859-5',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001335 'rw': 'rw_RW.ISO8859-1',
1336 'rw_rw': 'rw_RW.ISO8859-1',
1337 'rw_rw.iso88591': 'rw_RW.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001338 'se_no': 'se_NO.UTF-8',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001339 'serbocroatian': 'sr_CS.ISO8859-2',
1340 'sh': 'sr_CS.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001341 'sh_hr': 'sh_HR.ISO8859-2',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001342 'sh_hr.iso88592': 'hr_HR.ISO8859-2',
1343 'sh_sp': 'sr_CS.ISO8859-2',
1344 'sh_yu': 'sr_CS.ISO8859-2',
1345 'si': 'si_LK.UTF-8',
1346 'si_lk': 'si_LK.UTF-8',
1347 'sinhala': 'si_LK.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001348 'sk': 'sk_SK.ISO8859-2',
1349 'sk_sk': 'sk_SK.ISO8859-2',
1350 'sk_sk.iso88592': 'sk_SK.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001351 'sl': 'sl_SI.ISO8859-2',
1352 'sl_cs': 'sl_CS.ISO8859-2',
1353 'sl_si': 'sl_SI.ISO8859-2',
1354 'sl_si.iso88592': 'sl_SI.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001355 'slovak': 'sk_SK.ISO8859-2',
1356 'slovene': 'sl_SI.ISO8859-2',
1357 'slovenian': 'sl_SI.ISO8859-2',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001358 'sp': 'sr_CS.ISO8859-5',
1359 'sp_yu': 'sr_CS.ISO8859-5',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001360 'spanish': 'es_ES.ISO8859-1',
1361 'spanish.iso88591': 'es_ES.ISO8859-1',
1362 'spanish_spain': 'es_ES.ISO8859-1',
1363 'spanish_spain.8859': 'es_ES.ISO8859-1',
1364 'sq': 'sq_AL.ISO8859-2',
1365 'sq_al': 'sq_AL.ISO8859-2',
1366 'sq_al.iso88592': 'sq_AL.ISO8859-2',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001367 'sr': 'sr_CS.ISO8859-5',
1368 'sr@cyrillic': 'sr_CS.ISO8859-5',
1369 'sr@latn': 'sr_CS.ISO8859-2',
1370 'sr_cs.iso88592': 'sr_CS.ISO8859-2',
1371 'sr_cs.iso88592@latn': 'sr_CS.ISO8859-2',
1372 'sr_cs.iso88595': 'sr_CS.ISO8859-5',
1373 'sr_cs.utf8@latn': 'sr_CS.UTF-8',
1374 'sr_cs@latn': 'sr_CS.ISO8859-2',
1375 'sr_sp': 'sr_CS.ISO8859-2',
1376 'sr_yu': 'sr_CS.ISO8859-5',
1377 'sr_yu.cp1251@cyrillic': 'sr_CS.CP1251',
1378 'sr_yu.iso88592': 'sr_CS.ISO8859-2',
1379 'sr_yu.iso88595': 'sr_CS.ISO8859-5',
1380 'sr_yu.iso88595@cyrillic': 'sr_CS.ISO8859-5',
1381 'sr_yu.microsoftcp1251@cyrillic': 'sr_CS.CP1251',
1382 'sr_yu.utf8@cyrillic': 'sr_CS.UTF-8',
1383 'sr_yu@cyrillic': 'sr_CS.ISO8859-5',
1384 'ss': 'ss_ZA.ISO8859-1',
1385 'ss_za': 'ss_ZA.ISO8859-1',
1386 'ss_za.iso88591': 'ss_ZA.ISO8859-1',
1387 'st': 'st_ZA.ISO8859-1',
1388 'st_za': 'st_ZA.ISO8859-1',
1389 'st_za.iso88591': 'st_ZA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001390 'sv': 'sv_SE.ISO8859-1',
1391 'sv_fi': 'sv_FI.ISO8859-1',
1392 'sv_fi.iso88591': 'sv_FI.ISO8859-1',
1393 'sv_fi.iso885915': 'sv_FI.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001394 'sv_fi.iso885915@euro': 'sv_FI.ISO8859-15',
1395 'sv_fi.utf8@euro': 'sv_FI.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001396 'sv_fi@euro': 'sv_FI.ISO8859-15',
1397 'sv_se': 'sv_SE.ISO8859-1',
1398 'sv_se.88591': 'sv_SE.ISO8859-1',
1399 'sv_se.iso88591': 'sv_SE.ISO8859-1',
1400 'sv_se.iso885915': 'sv_SE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001401 'sv_se@euro': 'sv_SE.ISO8859-15',
1402 'swedish': 'sv_SE.ISO8859-1',
1403 'swedish.iso88591': 'sv_SE.ISO8859-1',
1404 'ta': 'ta_IN.TSCII-0',
1405 'ta_in': 'ta_IN.TSCII-0',
1406 'ta_in.tscii': 'ta_IN.TSCII-0',
1407 'ta_in.tscii0': 'ta_IN.TSCII-0',
1408 'tg': 'tg_TJ.KOI8-C',
1409 'tg_tj': 'tg_TJ.KOI8-C',
1410 'tg_tj.koi8c': 'tg_TJ.KOI8-C',
1411 'th': 'th_TH.ISO8859-11',
1412 'th_th': 'th_TH.ISO8859-11',
1413 'th_th.iso885911': 'th_TH.ISO8859-11',
1414 'th_th.tactis': 'th_TH.TIS620',
1415 'th_th.tis620': 'th_TH.TIS620',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001416 'thai': 'th_TH.ISO8859-11',
1417 'tl': 'tl_PH.ISO8859-1',
1418 'tl_ph': 'tl_PH.ISO8859-1',
1419 'tl_ph.iso88591': 'tl_PH.ISO8859-1',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001420 'tn': 'tn_ZA.ISO8859-15',
1421 'tn_za': 'tn_ZA.ISO8859-15',
1422 'tn_za.iso885915': 'tn_ZA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001423 'tr': 'tr_TR.ISO8859-9',
1424 'tr_tr': 'tr_TR.ISO8859-9',
1425 'tr_tr.iso88599': 'tr_TR.ISO8859-9',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001426 'ts': 'ts_ZA.ISO8859-1',
1427 'ts_za': 'ts_ZA.ISO8859-1',
1428 'ts_za.iso88591': 'ts_ZA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001429 'tt': 'tt_RU.TATAR-CYR',
1430 'tt_ru': 'tt_RU.TATAR-CYR',
1431 'tt_ru.koi8c': 'tt_RU.KOI8-C',
1432 'tt_ru.tatarcyr': 'tt_RU.TATAR-CYR',
1433 'turkish': 'tr_TR.ISO8859-9',
1434 'turkish.iso88599': 'tr_TR.ISO8859-9',
1435 'uk': 'uk_UA.KOI8-U',
1436 'uk_ua': 'uk_UA.KOI8-U',
1437 'uk_ua.cp1251': 'uk_UA.CP1251',
1438 'uk_ua.iso88595': 'uk_UA.ISO8859-5',
1439 'uk_ua.koi8u': 'uk_UA.KOI8-U',
1440 'uk_ua.microsoftcp1251': 'uk_UA.CP1251',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001441 'univ': 'en_US.utf',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001442 'universal': 'en_US.utf',
1443 'universal.utf8@ucs4': 'en_US.UTF-8',
1444 'ur': 'ur_PK.CP1256',
1445 'ur_pk': 'ur_PK.CP1256',
1446 'ur_pk.cp1256': 'ur_PK.CP1256',
1447 'ur_pk.microsoftcp1256': 'ur_PK.CP1256',
1448 'uz': 'uz_UZ.UTF-8',
1449 'uz_uz': 'uz_UZ.UTF-8',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001450 'uz_uz.iso88591': 'uz_UZ.ISO8859-1',
1451 'uz_uz.utf8@cyrillic': 'uz_UZ.UTF-8',
1452 'uz_uz@cyrillic': 'uz_UZ.UTF-8',
1453 've': 've_ZA.UTF-8',
1454 've_za': 've_ZA.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001455 'vi': 'vi_VN.TCVN',
1456 'vi_vn': 'vi_VN.TCVN',
1457 'vi_vn.tcvn': 'vi_VN.TCVN',
1458 'vi_vn.tcvn5712': 'vi_VN.TCVN',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001459 'vi_vn.viscii': 'vi_VN.VISCII',
1460 'vi_vn.viscii111': 'vi_VN.VISCII',
1461 'wa': 'wa_BE.ISO8859-1',
1462 'wa_be': 'wa_BE.ISO8859-1',
1463 'wa_be.iso88591': 'wa_BE.ISO8859-1',
1464 'wa_be.iso885915': 'wa_BE.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001465 'wa_be.iso885915@euro': 'wa_BE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001466 'wa_be@euro': 'wa_BE.ISO8859-15',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001467 'xh': 'xh_ZA.ISO8859-1',
1468 'xh_za': 'xh_ZA.ISO8859-1',
1469 'xh_za.iso88591': 'xh_ZA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001470 'yi': 'yi_US.CP1255',
1471 'yi_us': 'yi_US.CP1255',
1472 'yi_us.cp1255': 'yi_US.CP1255',
1473 'yi_us.microsoftcp1255': 'yi_US.CP1255',
1474 'zh': 'zh_CN.eucCN',
1475 'zh_cn': 'zh_CN.gb2312',
1476 'zh_cn.big5': 'zh_TW.big5',
1477 'zh_cn.euc': 'zh_CN.eucCN',
1478 'zh_cn.gb18030': 'zh_CN.gb18030',
1479 'zh_cn.gb2312': 'zh_CN.gb2312',
1480 'zh_cn.gbk': 'zh_CN.gbk',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001481 'zh_hk': 'zh_HK.big5hkscs',
1482 'zh_hk.big5': 'zh_HK.big5',
1483 'zh_hk.big5hkscs': 'zh_HK.big5hkscs',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001484 'zh_tw': 'zh_TW.big5',
1485 'zh_tw.big5': 'zh_TW.big5',
1486 'zh_tw.euc': 'zh_TW.eucTW',
Georg Brandlf08a9dd2008-06-10 16:57:31 +00001487 'zh_tw.euctw': 'zh_TW.eucTW',
1488 'zu': 'zu_ZA.ISO8859-1',
1489 'zu_za': 'zu_ZA.ISO8859-1',
1490 'zu_za.iso88591': 'zu_ZA.ISO8859-1',
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001491}
1492
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001493#
Georg Brandlb709c2c2006-01-20 09:07:35 +00001494# This maps Windows language identifiers to locale strings.
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001495#
Tim Peters777f1082006-01-20 20:03:24 +00001496# This list has been updated from
Georg Brandlb709c2c2006-01-20 09:07:35 +00001497# http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nls_238z.asp
1498# to include every locale up to Windows XP.
Fredrik Lundh37a09822002-10-19 20:19:10 +00001499#
Georg Brandl5035c1c2006-01-20 13:38:26 +00001500# NOTE: this mapping is incomplete. If your language is missing, please
1501# submit a bug report to Python bug manager, which you can find via:
1502# http://www.python.org/dev/
1503# Make sure you include the missing language identifier and the suggested
1504# locale code.
1505#
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001506
1507windows_locale = {
Georg Brandlb709c2c2006-01-20 09:07:35 +00001508 0x0436: "af_ZA", # Afrikaans
1509 0x041c: "sq_AL", # Albanian
1510 0x0401: "ar_SA", # Arabic - Saudi Arabia
1511 0x0801: "ar_IQ", # Arabic - Iraq
1512 0x0c01: "ar_EG", # Arabic - Egypt
1513 0x1001: "ar_LY", # Arabic - Libya
1514 0x1401: "ar_DZ", # Arabic - Algeria
1515 0x1801: "ar_MA", # Arabic - Morocco
1516 0x1c01: "ar_TN", # Arabic - Tunisia
1517 0x2001: "ar_OM", # Arabic - Oman
1518 0x2401: "ar_YE", # Arabic - Yemen
1519 0x2801: "ar_SY", # Arabic - Syria
1520 0x2c01: "ar_JO", # Arabic - Jordan
1521 0x3001: "ar_LB", # Arabic - Lebanon
1522 0x3401: "ar_KW", # Arabic - Kuwait
1523 0x3801: "ar_AE", # Arabic - United Arab Emirates
1524 0x3c01: "ar_BH", # Arabic - Bahrain
1525 0x4001: "ar_QA", # Arabic - Qatar
1526 0x042b: "hy_AM", # Armenian
1527 0x042c: "az_AZ", # Azeri Latin
1528 0x082c: "az_AZ", # Azeri - Cyrillic
1529 0x042d: "eu_ES", # Basque
1530 0x0423: "be_BY", # Belarusian
1531 0x0445: "bn_IN", # Begali
1532 0x201a: "bs_BA", # Bosnian
1533 0x141a: "bs_BA", # Bosnian - Cyrillic
1534 0x047e: "br_FR", # Breton - France
1535 0x0402: "bg_BG", # Bulgarian
1536 0x0403: "ca_ES", # Catalan
1537 0x0004: "zh_CHS",# Chinese - Simplified
1538 0x0404: "zh_TW", # Chinese - Taiwan
1539 0x0804: "zh_CN", # Chinese - PRC
1540 0x0c04: "zh_HK", # Chinese - Hong Kong S.A.R.
1541 0x1004: "zh_SG", # Chinese - Singapore
1542 0x1404: "zh_MO", # Chinese - Macao S.A.R.
1543 0x7c04: "zh_CHT",# Chinese - Traditional
1544 0x041a: "hr_HR", # Croatian
1545 0x101a: "hr_BA", # Croatian - Bosnia
1546 0x0405: "cs_CZ", # Czech
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001547 0x0406: "da_DK", # Danish
Georg Brandlb709c2c2006-01-20 09:07:35 +00001548 0x048c: "gbz_AF",# Dari - Afghanistan
1549 0x0465: "div_MV",# Divehi - Maldives
1550 0x0413: "nl_NL", # Dutch - The Netherlands
1551 0x0813: "nl_BE", # Dutch - Belgium
1552 0x0409: "en_US", # English - United States
1553 0x0809: "en_GB", # English - United Kingdom
1554 0x0c09: "en_AU", # English - Australia
1555 0x1009: "en_CA", # English - Canada
1556 0x1409: "en_NZ", # English - New Zealand
1557 0x1809: "en_IE", # English - Ireland
1558 0x1c09: "en_ZA", # English - South Africa
1559 0x2009: "en_JA", # English - Jamaica
1560 0x2409: "en_CB", # English - Carribbean
1561 0x2809: "en_BZ", # English - Belize
1562 0x2c09: "en_TT", # English - Trinidad
1563 0x3009: "en_ZW", # English - Zimbabwe
1564 0x3409: "en_PH", # English - Phillippines
1565 0x0425: "et_EE", # Estonian
1566 0x0438: "fo_FO", # Faroese
1567 0x0464: "fil_PH",# Filipino
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001568 0x040b: "fi_FI", # Finnish
Georg Brandlb709c2c2006-01-20 09:07:35 +00001569 0x040c: "fr_FR", # French - France
1570 0x080c: "fr_BE", # French - Belgium
1571 0x0c0c: "fr_CA", # French - Canada
1572 0x100c: "fr_CH", # French - Switzerland
1573 0x140c: "fr_LU", # French - Luxembourg
1574 0x180c: "fr_MC", # French - Monaco
1575 0x0462: "fy_NL", # Frisian - Netherlands
1576 0x0456: "gl_ES", # Galician
1577 0x0437: "ka_GE", # Georgian
1578 0x0407: "de_DE", # German - Germany
1579 0x0807: "de_CH", # German - Switzerland
1580 0x0c07: "de_AT", # German - Austria
1581 0x1007: "de_LU", # German - Luxembourg
1582 0x1407: "de_LI", # German - Liechtenstein
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001583 0x0408: "el_GR", # Greek
Georg Brandlb709c2c2006-01-20 09:07:35 +00001584 0x0447: "gu_IN", # Gujarati
1585 0x040d: "he_IL", # Hebrew
1586 0x0439: "hi_IN", # Hindi
1587 0x040e: "hu_HU", # Hungarian
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001588 0x040f: "is_IS", # Icelandic
Georg Brandlb709c2c2006-01-20 09:07:35 +00001589 0x0421: "id_ID", # Indonesian
1590 0x045d: "iu_CA", # Inuktitut
1591 0x085d: "iu_CA", # Inuktitut - Latin
1592 0x083c: "ga_IE", # Irish - Ireland
1593 0x0434: "xh_ZA", # Xhosa - South Africa
1594 0x0435: "zu_ZA", # Zulu
1595 0x0410: "it_IT", # Italian - Italy
1596 0x0810: "it_CH", # Italian - Switzerland
1597 0x0411: "ja_JP", # Japanese
1598 0x044b: "kn_IN", # Kannada - India
1599 0x043f: "kk_KZ", # Kazakh
1600 0x0457: "kok_IN",# Konkani
1601 0x0412: "ko_KR", # Korean
1602 0x0440: "ky_KG", # Kyrgyz
1603 0x0426: "lv_LV", # Latvian
1604 0x0427: "lt_LT", # Lithuanian
1605 0x046e: "lb_LU", # Luxembourgish
1606 0x042f: "mk_MK", # FYRO Macedonian
1607 0x043e: "ms_MY", # Malay - Malaysia
1608 0x083e: "ms_BN", # Malay - Brunei
1609 0x044c: "ml_IN", # Malayalam - India
1610 0x043a: "mt_MT", # Maltese
1611 0x0481: "mi_NZ", # Maori
1612 0x047a: "arn_CL",# Mapudungun
1613 0x044e: "mr_IN", # Marathi
1614 0x047c: "moh_CA",# Mohawk - Canada
1615 0x0450: "mn_MN", # Mongolian
1616 0x0461: "ne_NP", # Nepali
1617 0x0414: "nb_NO", # Norwegian - Bokmal
1618 0x0814: "nn_NO", # Norwegian - Nynorsk
1619 0x0482: "oc_FR", # Occitan - France
1620 0x0448: "or_IN", # Oriya - India
1621 0x0463: "ps_AF", # Pashto - Afghanistan
1622 0x0429: "fa_IR", # Persian
1623 0x0415: "pl_PL", # Polish
1624 0x0416: "pt_BR", # Portuguese - Brazil
1625 0x0816: "pt_PT", # Portuguese - Portugal
1626 0x0446: "pa_IN", # Punjabi
1627 0x046b: "quz_BO",# Quechua (Bolivia)
1628 0x086b: "quz_EC",# Quechua (Ecuador)
1629 0x0c6b: "quz_PE",# Quechua (Peru)
1630 0x0418: "ro_RO", # Romanian - Romania
1631 0x0417: "rm_CH", # Raeto-Romanese
1632 0x0419: "ru_RU", # Russian
1633 0x243b: "smn_FI",# Sami Finland
1634 0x103b: "smj_NO",# Sami Norway
1635 0x143b: "smj_SE",# Sami Sweden
1636 0x043b: "se_NO", # Sami Northern Norway
1637 0x083b: "se_SE", # Sami Northern Sweden
1638 0x0c3b: "se_FI", # Sami Northern Finland
1639 0x203b: "sms_FI",# Sami Skolt
1640 0x183b: "sma_NO",# Sami Southern Norway
1641 0x1c3b: "sma_SE",# Sami Southern Sweden
1642 0x044f: "sa_IN", # Sanskrit
1643 0x0c1a: "sr_SP", # Serbian - Cyrillic
1644 0x1c1a: "sr_BA", # Serbian - Bosnia Cyrillic
1645 0x081a: "sr_SP", # Serbian - Latin
1646 0x181a: "sr_BA", # Serbian - Bosnia Latin
1647 0x046c: "ns_ZA", # Northern Sotho
1648 0x0432: "tn_ZA", # Setswana - Southern Africa
1649 0x041b: "sk_SK", # Slovak
1650 0x0424: "sl_SI", # Slovenian
1651 0x040a: "es_ES", # Spanish - Spain
1652 0x080a: "es_MX", # Spanish - Mexico
1653 0x0c0a: "es_ES", # Spanish - Spain (Modern)
1654 0x100a: "es_GT", # Spanish - Guatemala
1655 0x140a: "es_CR", # Spanish - Costa Rica
1656 0x180a: "es_PA", # Spanish - Panama
1657 0x1c0a: "es_DO", # Spanish - Dominican Republic
1658 0x200a: "es_VE", # Spanish - Venezuela
1659 0x240a: "es_CO", # Spanish - Colombia
1660 0x280a: "es_PE", # Spanish - Peru
1661 0x2c0a: "es_AR", # Spanish - Argentina
1662 0x300a: "es_EC", # Spanish - Ecuador
1663 0x340a: "es_CL", # Spanish - Chile
1664 0x380a: "es_UR", # Spanish - Uruguay
1665 0x3c0a: "es_PY", # Spanish - Paraguay
1666 0x400a: "es_BO", # Spanish - Bolivia
1667 0x440a: "es_SV", # Spanish - El Salvador
1668 0x480a: "es_HN", # Spanish - Honduras
1669 0x4c0a: "es_NI", # Spanish - Nicaragua
1670 0x500a: "es_PR", # Spanish - Puerto Rico
1671 0x0441: "sw_KE", # Swahili
1672 0x041d: "sv_SE", # Swedish - Sweden
1673 0x081d: "sv_FI", # Swedish - Finland
1674 0x045a: "syr_SY",# Syriac
1675 0x0449: "ta_IN", # Tamil
1676 0x0444: "tt_RU", # Tatar
1677 0x044a: "te_IN", # Telugu
1678 0x041e: "th_TH", # Thai
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001679 0x041f: "tr_TR", # Turkish
Georg Brandlb709c2c2006-01-20 09:07:35 +00001680 0x0422: "uk_UA", # Ukrainian
1681 0x0420: "ur_PK", # Urdu
1682 0x0820: "ur_IN", # Urdu - India
1683 0x0443: "uz_UZ", # Uzbek - Latin
1684 0x0843: "uz_UZ", # Uzbek - Cyrillic
1685 0x042a: "vi_VN", # Vietnamese
1686 0x0452: "cy_GB", # Welsh
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001687}
1688
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001689def _print_locale():
1690
1691 """ Test function.
1692 """
1693 categories = {}
1694 def _init_categories(categories=categories):
1695 for k,v in globals().items():
1696 if k[:3] == 'LC_':
1697 categories[k] = v
1698 _init_categories()
1699 del categories['LC_ALL']
1700
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001701 print('Locale defaults as determined by getdefaultlocale():')
1702 print('-'*72)
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001703 lang, enc = getdefaultlocale()
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001704 print('Language: ', lang or '(undefined)')
1705 print('Encoding: ', enc or '(undefined)')
1706 print()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001707
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001708 print('Locale settings on startup:')
1709 print('-'*72)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001710 for name,category in categories.items():
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001711 print(name, '...')
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001712 lang, enc = getlocale(category)
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001713 print(' Language: ', lang or '(undefined)')
1714 print(' Encoding: ', enc or '(undefined)')
1715 print()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001716
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001717 print()
1718 print('Locale settings after calling resetlocale():')
1719 print('-'*72)
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001720 resetlocale()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001721 for name,category in categories.items():
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001722 print(name, '...')
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001723 lang, enc = getlocale(category)
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001724 print(' Language: ', lang or '(undefined)')
1725 print(' Encoding: ', enc or '(undefined)')
1726 print()
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001727
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001728 try:
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001729 setlocale(LC_ALL, "")
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001730 except:
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001731 print('NOTE:')
1732 print('setlocale(LC_ALL, "") does not support the default locale')
1733 print('given in the OS environment variables.')
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001734 else:
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001735 print()
1736 print('Locale settings after calling setlocale(LC_ALL, ""):')
1737 print('-'*72)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001738 for name,category in categories.items():
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001739 print(name, '...')
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001740 lang, enc = getlocale(category)
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001741 print(' Language: ', lang or '(undefined)')
1742 print(' Encoding: ', enc or '(undefined)')
1743 print()
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001744
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001745###
Guido van Rossumeef1d4e1997-11-19 19:01:43 +00001746
Tim Peters1baf8292001-01-24 10:13:46 +00001747try:
1748 LC_MESSAGES
Skip Montanaro0897f0c2002-03-25 21:40:36 +00001749except NameError:
Tim Peters1baf8292001-01-24 10:13:46 +00001750 pass
1751else:
1752 __all__.append("LC_MESSAGES")
1753
Guido van Rossumeef1d4e1997-11-19 19:01:43 +00001754if __name__=='__main__':
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001755 print('Locale aliasing:')
1756 print()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001757 _print_locale()
Guido van Rossumbe19ed72007-02-09 05:37:30 +00001758 print()
1759 print('Number formatting:')
1760 print()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001761 _test()