blob: cb77b94d97510660229a7691a1f2506ca23381fd [file] [log] [blame]
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001""" Locale support.
Guido van Rossum4b8c6ea2000-02-04 15:39:30 +00002
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00003 The module provides low-level access to the C lib's locale APIs
4 and adds high level number formatting APIs as well as a locale
5 aliasing engine to complement these.
6
7 The aliasing engine includes support for many commonly used locale
8 names and maps them to values suitable for passing to the C lib's
9 setlocale() function. It also includes default encodings for all
10 supported locale names.
11
12"""
13
R. David Murraya83da352009-04-01 03:21:43 +000014import sys
15import encodings
16import encodings.aliases
17import re
18import operator
Antoine Pitrouba54eda2008-07-25 20:40:19 +000019import functools
Marc-André Lemburg5431bc32000-06-07 09:11:40 +000020
Fredrik Lundh6c86b992000-07-09 17:12:58 +000021# Try importing the _locale module.
22#
23# If this fails, fall back on a basic 'C' locale emulation.
Guido van Rossumeef1d4e1997-11-19 19:01:43 +000024
Tim Peters1baf8292001-01-24 10:13:46 +000025# Yuck: LC_MESSAGES is non-standard: can't tell whether it exists before
26# trying the import. So __all__ is also fiddled at the end of the file.
Georg Brandl09728b72007-05-01 06:08:15 +000027__all__ = ["getlocale", "getdefaultlocale", "getpreferredencoding", "Error",
28 "setlocale", "resetlocale", "localeconv", "strcoll", "strxfrm",
29 "str", "atof", "atoi", "format", "format_string", "currency",
30 "normalize", "LC_CTYPE", "LC_COLLATE", "LC_TIME", "LC_MONETARY",
31 "LC_NUMERIC", "LC_ALL", "CHAR_MAX"]
Skip Montanaro17ab1232001-01-24 06:27:27 +000032
Marc-André Lemburg23481142000-06-08 17:49:41 +000033try:
Fredrik Lundh6c86b992000-07-09 17:12:58 +000034
Marc-André Lemburg23481142000-06-08 17:49:41 +000035 from _locale import *
36
37except ImportError:
38
Fredrik Lundh6c86b992000-07-09 17:12:58 +000039 # Locale emulation
40
Marc-André Lemburg23481142000-06-08 17:49:41 +000041 CHAR_MAX = 127
42 LC_ALL = 6
43 LC_COLLATE = 3
44 LC_CTYPE = 0
45 LC_MESSAGES = 5
46 LC_MONETARY = 4
47 LC_NUMERIC = 1
48 LC_TIME = 2
49 Error = ValueError
50
51 def localeconv():
Fredrik Lundh6c86b992000-07-09 17:12:58 +000052 """ localeconv() -> dict.
Marc-André Lemburg23481142000-06-08 17:49:41 +000053 Returns numeric and monetary locale-specific parameters.
54 """
55 # 'C' locale default values
56 return {'grouping': [127],
57 'currency_symbol': '',
58 'n_sign_posn': 127,
Fredrik Lundh6c86b992000-07-09 17:12:58 +000059 'p_cs_precedes': 127,
60 'n_cs_precedes': 127,
61 'mon_grouping': [],
Marc-André Lemburg23481142000-06-08 17:49:41 +000062 'n_sep_by_space': 127,
63 'decimal_point': '.',
64 'negative_sign': '',
65 'positive_sign': '',
Fredrik Lundh6c86b992000-07-09 17:12:58 +000066 'p_sep_by_space': 127,
Marc-André Lemburg23481142000-06-08 17:49:41 +000067 'int_curr_symbol': '',
Fredrik Lundh6c86b992000-07-09 17:12:58 +000068 'p_sign_posn': 127,
Marc-André Lemburg23481142000-06-08 17:49:41 +000069 'thousands_sep': '',
Fredrik Lundh6c86b992000-07-09 17:12:58 +000070 'mon_thousands_sep': '',
71 'frac_digits': 127,
Marc-André Lemburg23481142000-06-08 17:49:41 +000072 'mon_decimal_point': '',
73 'int_frac_digits': 127}
Fredrik Lundh6c86b992000-07-09 17:12:58 +000074
Marc-André Lemburg23481142000-06-08 17:49:41 +000075 def setlocale(category, value=None):
Fredrik Lundh6c86b992000-07-09 17:12:58 +000076 """ setlocale(integer,string=None) -> string.
Marc-André Lemburg23481142000-06-08 17:49:41 +000077 Activates/queries locale processing.
78 """
Martin v. Löwis103d6e72003-03-30 15:42:13 +000079 if value not in (None, '', 'C'):
Fredrik Lundh6c86b992000-07-09 17:12:58 +000080 raise Error, '_locale emulation only supports "C" locale'
Marc-André Lemburg23481142000-06-08 17:49:41 +000081 return 'C'
82
83 def strcoll(a,b):
Fredrik Lundh6c86b992000-07-09 17:12:58 +000084 """ strcoll(string,string) -> int.
Marc-André Lemburg23481142000-06-08 17:49:41 +000085 Compares two strings according to the locale.
86 """
87 return cmp(a,b)
88
89 def strxfrm(s):
Fredrik Lundh6c86b992000-07-09 17:12:58 +000090 """ strxfrm(string) -> string.
Marc-André Lemburg23481142000-06-08 17:49:41 +000091 Returns a string that behaves for cmp locale-aware.
92 """
93 return s
Marc-André Lemburg5431bc32000-06-07 09:11:40 +000094
Antoine Pitrouba54eda2008-07-25 20:40:19 +000095
96_localeconv = localeconv
97
98# With this dict, you can override some items of localeconv's return value.
99# This is useful for testing purposes.
100_override_localeconv = {}
101
102@functools.wraps(_localeconv)
103def localeconv():
104 d = _localeconv()
105 if _override_localeconv:
106 d.update(_override_localeconv)
107 return d
108
109
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000110### Number formatting APIs
111
112# Author: Martin von Loewis
Georg Brandlb89316f2006-05-17 15:51:16 +0000113# improved by Georg Brandl
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000114
Antoine Pitroufeeafff2009-03-14 00:07:21 +0000115# Iterate over grouping intervals
116def _grouping_intervals(grouping):
117 for interval in grouping:
118 # if grouping is -1, we are done
119 if interval == CHAR_MAX:
120 return
121 # 0: re-use last group ad infinitum
122 if interval == 0:
123 while True:
124 yield last_interval
125 yield interval
126 last_interval = interval
127
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000128#perform the grouping from right to left
Georg Brandlb89316f2006-05-17 15:51:16 +0000129def _group(s, monetary=False):
130 conv = localeconv()
131 thousands_sep = conv[monetary and 'mon_thousands_sep' or 'thousands_sep']
132 grouping = conv[monetary and 'mon_grouping' or 'grouping']
133 if not grouping:
134 return (s, 0)
135 result = ""
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000136 seps = 0
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000137 if s[-1] == ' ':
Antoine Pitroufeeafff2009-03-14 00:07:21 +0000138 stripped = s.rstrip()
139 right_spaces = s[len(stripped):]
140 s = stripped
141 else:
142 right_spaces = ''
143 left_spaces = ''
144 groups = []
145 for interval in _grouping_intervals(grouping):
146 if not s or s[-1] not in "0123456789":
147 # only non-digit characters remain (sign, spaces)
148 left_spaces = s
149 s = ''
Guido van Rossum45e2fbc1998-03-26 21:13:24 +0000150 break
Antoine Pitroufeeafff2009-03-14 00:07:21 +0000151 groups.append(s[-interval:])
152 s = s[:-interval]
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000153 if s:
Antoine Pitroufeeafff2009-03-14 00:07:21 +0000154 groups.append(s)
155 groups.reverse()
156 return (
157 left_spaces + thousands_sep.join(groups) + right_spaces,
Antoine Pitrou7c33bd52009-03-18 17:10:04 +0000158 len(thousands_sep) * (len(groups) - 1)
Antoine Pitroufeeafff2009-03-14 00:07:21 +0000159 )
160
161# Strip a given amount of excess padding from the given string
162def _strip_padding(s, amount):
163 lpos = 0
164 while amount and s[lpos] == ' ':
165 lpos += 1
166 amount -= 1
167 rpos = len(s) - 1
168 while amount and s[rpos] == ' ':
169 rpos -= 1
170 amount -= 1
171 return s[lpos:rpos+1]
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000172
R. David Murraya83da352009-04-01 03:21:43 +0000173_percent_re = re.compile(r'%(?:\((?P<key>.*?)\))?'
174 r'(?P<modifiers>[-#0-9 +*.hlL]*?)[eEfFgGdiouxXcrs%]')
175
Georg Brandlb89316f2006-05-17 15:51:16 +0000176def format(percent, value, grouping=False, monetary=False, *additional):
177 """Returns the locale-aware substitution of a %? specifier
178 (percent).
Tim Petersfd4c4192006-05-18 02:06:40 +0000179
Georg Brandlb89316f2006-05-17 15:51:16 +0000180 additional is for format strings which contain one or more
181 '*' modifiers."""
182 # this is only for one-percent-specifier strings and this should be checked
R. David Murraya83da352009-04-01 03:21:43 +0000183 match = _percent_re.match(percent)
184 if not match or len(match.group())!= len(percent):
185 raise ValueError(("format() must be given exactly one %%char "
186 "format specifier, %s not valid") % repr(percent))
187 return _format(percent, value, grouping, monetary, *additional)
188
189def _format(percent, value, grouping=False, monetary=False, *additional):
Georg Brandlb89316f2006-05-17 15:51:16 +0000190 if additional:
191 formatted = percent % ((value,) + additional)
192 else:
193 formatted = percent % value
194 # floats and decimal ints need special action!
195 if percent[-1] in 'eEfFgG':
196 seps = 0
197 parts = formatted.split('.')
198 if grouping:
199 parts[0], seps = _group(parts[0], monetary=monetary)
200 decimal_point = localeconv()[monetary and 'mon_decimal_point'
201 or 'decimal_point']
202 formatted = decimal_point.join(parts)
Antoine Pitroufeeafff2009-03-14 00:07:21 +0000203 if seps:
204 formatted = _strip_padding(formatted, seps)
Georg Brandlb89316f2006-05-17 15:51:16 +0000205 elif percent[-1] in 'diu':
Antoine Pitroufeeafff2009-03-14 00:07:21 +0000206 seps = 0
Georg Brandlb89316f2006-05-17 15:51:16 +0000207 if grouping:
Antoine Pitroufeeafff2009-03-14 00:07:21 +0000208 formatted, seps = _group(formatted, monetary=monetary)
209 if seps:
210 formatted = _strip_padding(formatted, seps)
Georg Brandlb89316f2006-05-17 15:51:16 +0000211 return formatted
212
Georg Brandlb89316f2006-05-17 15:51:16 +0000213def format_string(f, val, grouping=False):
214 """Formats a string in the same way that the % formatting would use,
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000215 but takes the current locale into account.
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000216 Grouping is applied if the third parameter is true."""
Georg Brandlb89316f2006-05-17 15:51:16 +0000217 percents = list(_percent_re.finditer(f))
218 new_f = _percent_re.sub('%s', f)
219
220 if isinstance(val, tuple):
221 new_val = list(val)
222 i = 0
223 for perc in percents:
224 starcount = perc.group('modifiers').count('*')
225 new_val[i] = format(perc.group(), new_val[i], grouping, False, *new_val[i+1:i+1+starcount])
226 del new_val[i+1:i+1+starcount]
227 i += (1 + starcount)
228 val = tuple(new_val)
229 elif operator.isMappingType(val):
230 for perc in percents:
231 key = perc.group("key")
232 val[key] = format(perc.group(), val[key], grouping)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000233 else:
Georg Brandlb89316f2006-05-17 15:51:16 +0000234 # val is a single value
235 val = format(percents[0].group(), val, grouping)
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000236
Georg Brandlb89316f2006-05-17 15:51:16 +0000237 return new_f % val
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000238
Georg Brandlb89316f2006-05-17 15:51:16 +0000239def currency(val, symbol=True, grouping=False, international=False):
240 """Formats val according to the currency settings
241 in the current locale."""
242 conv = localeconv()
243
244 # check for illegal values
245 digits = conv[international and 'int_frac_digits' or 'frac_digits']
246 if digits == 127:
247 raise ValueError("Currency formatting is not possible using "
248 "the 'C' locale.")
249
250 s = format('%%.%if' % digits, abs(val), grouping, monetary=True)
251 # '<' and '>' are markers if the sign must be inserted between symbol and value
252 s = '<' + s + '>'
253
254 if symbol:
255 smb = conv[international and 'int_curr_symbol' or 'currency_symbol']
256 precedes = conv[val<0 and 'n_cs_precedes' or 'p_cs_precedes']
257 separated = conv[val<0 and 'n_sep_by_space' or 'p_sep_by_space']
258
259 if precedes:
260 s = smb + (separated and ' ' or '') + s
261 else:
262 s = s + (separated and ' ' or '') + smb
263
264 sign_pos = conv[val<0 and 'n_sign_posn' or 'p_sign_posn']
265 sign = conv[val<0 and 'negative_sign' or 'positive_sign']
266
267 if sign_pos == 0:
268 s = '(' + s + ')'
269 elif sign_pos == 1:
270 s = sign + s
271 elif sign_pos == 2:
272 s = s + sign
273 elif sign_pos == 3:
274 s = s.replace('<', sign)
275 elif sign_pos == 4:
276 s = s.replace('>', sign)
277 else:
278 # the default if nothing specified;
279 # this should be the most fitting sign position
280 s = sign + s
281
282 return s.replace('<', '').replace('>', '')
Martin v. Löwisdb786872001-01-21 18:52:33 +0000283
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000284def str(val):
285 """Convert float to integer, taking the locale into account."""
Georg Brandlb89316f2006-05-17 15:51:16 +0000286 return format("%.12g", val)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000287
Georg Brandlb89316f2006-05-17 15:51:16 +0000288def atof(string, func=float):
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000289 "Parses a string as a float according to the locale settings."
290 #First, get rid of the grouping
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000291 ts = localeconv()['thousands_sep']
292 if ts:
Skip Montanaro249369c2004-04-10 16:39:32 +0000293 string = string.replace(ts, '')
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000294 #next, replace the decimal point with a dot
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000295 dd = localeconv()['decimal_point']
296 if dd:
Skip Montanaro249369c2004-04-10 16:39:32 +0000297 string = string.replace(dd, '.')
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000298 #finally, parse the string
Skip Montanaro249369c2004-04-10 16:39:32 +0000299 return func(string)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000300
301def atoi(str):
302 "Converts a string to an integer according to the locale settings."
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000303 return atof(str, int)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000304
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000305def _test():
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000306 setlocale(LC_ALL, "")
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000307 #do grouping
Georg Brandlb89316f2006-05-17 15:51:16 +0000308 s1 = format("%d", 123456789,1)
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000309 print s1, "is", atoi(s1)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000310 #standard formatting
Georg Brandlb89316f2006-05-17 15:51:16 +0000311 s1 = str(3.14)
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000312 print s1, "is", atof(s1)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000313
314### Locale name aliasing engine
315
316# Author: Marc-Andre Lemburg, mal@lemburg.com
Fredrik Lundh37a09822002-10-19 20:19:10 +0000317# Various tweaks by Fredrik Lundh <fredrik@pythonware.com>
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000318
319# store away the low-level version of setlocale (it's
320# overridden below)
321_setlocale = setlocale
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000322
323def normalize(localename):
324
325 """ Returns a normalized locale code for the given locale
326 name.
327
328 The returned locale code is formatted for use with
329 setlocale().
330
331 If normalization fails, the original name is returned
332 unchanged.
333
334 If the given encoding is not known, the function defaults to
335 the default encoding for the locale code just like setlocale()
336 does.
337
338 """
339 # Normalize the locale name and extract the encoding
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000340 fullname = localename.lower()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000341 if ':' in fullname:
342 # ':' is sometimes used as encoding delimiter.
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000343 fullname = fullname.replace(':', '.')
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000344 if '.' in fullname:
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000345 langname, encoding = fullname.split('.')[:2]
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000346 fullname = langname + '.' + encoding
347 else:
348 langname = fullname
349 encoding = ''
350
351 # First lookup: fullname (possibly with encoding)
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000352 norm_encoding = encoding.replace('-', '')
353 norm_encoding = norm_encoding.replace('_', '')
354 lookup_name = langname + '.' + encoding
355 code = locale_alias.get(lookup_name, None)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000356 if code is not None:
357 return code
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000358 #print 'first lookup failed'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000359
360 # Second try: langname (without encoding)
361 code = locale_alias.get(langname, None)
362 if code is not None:
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000363 #print 'langname lookup succeeded'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000364 if '.' in code:
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000365 langname, defenc = code.split('.')
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000366 else:
367 langname = code
368 defenc = ''
369 if encoding:
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000370 # Convert the encoding to a C lib compatible encoding string
371 norm_encoding = encodings.normalize_encoding(encoding)
372 #print 'norm encoding: %r' % norm_encoding
373 norm_encoding = encodings.aliases.aliases.get(norm_encoding,
374 norm_encoding)
375 #print 'aliased encoding: %r' % norm_encoding
376 encoding = locale_encoding_alias.get(norm_encoding,
377 norm_encoding)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000378 else:
379 encoding = defenc
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000380 #print 'found encoding %r' % encoding
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000381 if encoding:
382 return langname + '.' + encoding
383 else:
384 return langname
385
386 else:
387 return localename
388
389def _parse_localename(localename):
390
391 """ Parses the locale code for localename and returns the
392 result as tuple (language code, encoding).
393
394 The localename is normalized and passed through the locale
395 alias engine. A ValueError is raised in case the locale name
396 cannot be parsed.
397
398 The language code corresponds to RFC 1766. code and encoding
399 can be None in case the values cannot be determined or are
Jeremy Hyltona05e2932000-06-28 14:48:01 +0000400 unknown to this implementation.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000401
402 """
403 code = normalize(localename)
Georg Brandlb709c2c2006-01-20 09:07:35 +0000404 if '@' in code:
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000405 # Deal with locale modifiers
406 code, modifier = code.split('@')
407 if modifier == 'euro' and '.' not in code:
408 # Assume Latin-9 for @euro locales. This is bogus,
409 # since some systems may use other encodings for these
410 # locales. Also, we ignore other modifiers.
411 return code, 'iso-8859-15'
Tim Peters230a60c2002-11-09 05:08:07 +0000412
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000413 if '.' in code:
Raymond Hettinger346e67f2005-01-01 06:10:26 +0000414 return tuple(code.split('.')[:2])
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000415 elif code == 'C':
416 return None, None
Andrew M. Kuchling1f877ef2001-08-13 14:50:44 +0000417 raise ValueError, 'unknown locale: %s' % localename
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000418
419def _build_localename(localetuple):
420
421 """ Builds a locale code from the given tuple (language code,
422 encoding).
423
424 No aliasing or normalizing takes place.
425
426 """
427 language, encoding = localetuple
428 if language is None:
429 language = 'C'
430 if encoding is None:
431 return language
432 else:
433 return language + '.' + encoding
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000434
Matthias Klosef3f231f2005-09-20 07:02:49 +0000435def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000436
437 """ Tries to determine the default locale settings and returns
438 them as tuple (language code, encoding).
439
440 According to POSIX, a program which has not called
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000441 setlocale(LC_ALL, "") runs using the portable 'C' locale.
442 Calling setlocale(LC_ALL, "") lets it use the default locale as
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000443 defined by the LANG variable. Since we don't want to interfere
Thomas Wouters7e474022000-07-16 12:04:32 +0000444 with the current locale setting we thus emulate the behavior
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000445 in the way described above.
446
447 To maintain compatibility with other platforms, not only the
448 LANG variable is tested, but a list of variables given as
449 envvars parameter. The first found to be defined will be
450 used. envvars defaults to the search path used in GNU gettext;
451 it must always contain the variable name 'LANG'.
452
453 Except for the code 'C', the language code corresponds to RFC
454 1766. code and encoding can be None in case the values cannot
455 be determined.
456
457 """
Fredrik Lundh04661322000-07-09 23:16:10 +0000458
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000459 try:
460 # check if it's supported by the _locale module
461 import _locale
462 code, encoding = _locale._getdefaultlocale()
Fredrik Lundh04661322000-07-09 23:16:10 +0000463 except (ImportError, AttributeError):
464 pass
465 else:
Fredrik Lundh663809e2000-07-10 19:32:19 +0000466 # make sure the code/encoding values are valid
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000467 if sys.platform == "win32" and code and code[:2] == "0x":
468 # map windows language identifier to language name
469 code = windows_locale.get(int(code, 0))
Fredrik Lundh663809e2000-07-10 19:32:19 +0000470 # ...add other platform-specific processing here, if
471 # necessary...
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000472 return code, encoding
Fredrik Lundh04661322000-07-09 23:16:10 +0000473
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000474 # fall back on POSIX behaviour
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000475 import os
476 lookup = os.environ.get
477 for variable in envvars:
478 localename = lookup(variable,None)
Martin v. Löwisc8ae31d2004-07-26 12:45:18 +0000479 if localename:
Matthias Klosef3f231f2005-09-20 07:02:49 +0000480 if variable == 'LANGUAGE':
481 localename = localename.split(':')[0]
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000482 break
483 else:
484 localename = 'C'
485 return _parse_localename(localename)
486
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000487
488def getlocale(category=LC_CTYPE):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000489
490 """ Returns the current setting for the given locale category as
491 tuple (language code, encoding).
492
493 category may be one of the LC_* value except LC_ALL. It
494 defaults to LC_CTYPE.
495
496 Except for the code 'C', the language code corresponds to RFC
497 1766. code and encoding can be None in case the values cannot
498 be determined.
499
500 """
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000501 localename = _setlocale(category)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000502 if category == LC_ALL and ';' in localename:
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000503 raise TypeError, 'category LC_ALL is not supported'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000504 return _parse_localename(localename)
505
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000506def setlocale(category, locale=None):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000507
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000508 """ Set the locale for the given category. The locale can be
509 a string, a locale tuple (language code, encoding), or None.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000510
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000511 Locale tuples are converted to strings the locale aliasing
512 engine. Locale strings are passed directly to the C lib.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000513
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000514 category may be given as one of the LC_* values.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000515
516 """
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000517 if locale and type(locale) is not type(""):
518 # convert to string
519 locale = normalize(_build_localename(locale))
520 return _setlocale(category, locale)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000521
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000522def resetlocale(category=LC_ALL):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000523
524 """ Sets the locale for category to the default setting.
525
526 The default setting is determined by calling
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000527 getdefaultlocale(). category defaults to LC_ALL.
528
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000529 """
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000530 _setlocale(category, _build_localename(getdefaultlocale()))
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000531
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000532if sys.platform in ('win32', 'darwin', 'mac'):
533 # On Win32, this will return the ANSI code page
534 # On the Mac, it should return the system encoding;
535 # it might return "ascii" instead
536 def getpreferredencoding(do_setlocale = True):
537 """Return the charset that the user is likely using."""
538 import _locale
Tim Petersa326f472002-11-05 03:49:09 +0000539 return _locale._getdefaultlocale()[1]
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000540else:
541 # On Unix, if CODESET is available, use that.
542 try:
543 CODESET
544 except NameError:
545 # Fall back to parsing environment variables :-(
546 def getpreferredencoding(do_setlocale = True):
547 """Return the charset that the user is likely using,
548 by looking at environment variables."""
549 return getdefaultlocale()[1]
550 else:
551 def getpreferredencoding(do_setlocale = True):
552 """Return the charset that the user is likely using,
553 according to the system configuration."""
554 if do_setlocale:
555 oldloc = setlocale(LC_CTYPE)
Jeroen Ruigrok van der Werven041f4652009-05-06 05:25:42 +0000556 try:
557 setlocale(LC_CTYPE, "")
Jeroen Ruigrok van der Wervenc924b3d2009-05-06 13:16:36 +0000558 except Error:
Jeroen Ruigrok van der Werven041f4652009-05-06 05:25:42 +0000559 pass
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000560 result = nl_langinfo(CODESET)
561 setlocale(LC_CTYPE, oldloc)
562 return result
563 else:
564 return nl_langinfo(CODESET)
Tim Peters230a60c2002-11-09 05:08:07 +0000565
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000566
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000567### Database
568#
569# The following data was extracted from the locale.alias file which
570# comes with X11 and then hand edited removing the explicit encoding
571# definitions and adding some more aliases. The file is usually
572# available as /usr/lib/X11/locale/locale.alias.
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000573#
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000574
575#
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000576# The local_encoding_alias table maps lowercase encoding alias names
577# to C locale encoding names (case-sensitive). Note that normalize()
578# first looks up the encoding in the encodings.aliases dictionary and
579# then applies this mapping to find the correct C lib name for the
580# encoding.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000581#
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000582locale_encoding_alias = {
583
584 # Mappings for non-standard encoding names used in locale names
585 '437': 'C',
586 'c': 'C',
587 'en': 'ISO8859-1',
588 'jis': 'JIS7',
589 'jis7': 'JIS7',
590 'ajec': 'eucJP',
591
592 # Mappings from Python codec names to C lib encoding names
593 'ascii': 'ISO8859-1',
594 'latin_1': 'ISO8859-1',
595 'iso8859_1': 'ISO8859-1',
596 'iso8859_10': 'ISO8859-10',
597 'iso8859_11': 'ISO8859-11',
598 'iso8859_13': 'ISO8859-13',
599 'iso8859_14': 'ISO8859-14',
600 'iso8859_15': 'ISO8859-15',
Jeroen Ruigrok van der Werven51133d42009-05-08 13:07:39 +0000601 'iso8859_16': 'ISO8859-16',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000602 'iso8859_2': 'ISO8859-2',
603 'iso8859_3': 'ISO8859-3',
604 'iso8859_4': 'ISO8859-4',
605 'iso8859_5': 'ISO8859-5',
606 'iso8859_6': 'ISO8859-6',
607 'iso8859_7': 'ISO8859-7',
608 'iso8859_8': 'ISO8859-8',
609 'iso8859_9': 'ISO8859-9',
610 'iso2022_jp': 'JIS7',
611 'shift_jis': 'SJIS',
612 'tactis': 'TACTIS',
613 'euc_jp': 'eucJP',
614 'euc_kr': 'eucKR',
Marc-André Lemburgb4cebd42004-12-13 19:56:01 +0000615 'utf_8': 'UTF8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000616 'koi8_r': 'KOI8-R',
617 'koi8_u': 'KOI8-U',
618 # XXX This list is still incomplete. If you know more
619 # mappings, please file a bug report. Thanks.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000620}
621
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000622#
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000623# The locale_alias table maps lowercase alias names to C locale names
624# (case-sensitive). Encodings are always separated from the locale
625# name using a dot ('.'); they should only be given in case the
626# language name is needed to interpret the given encoding alias
627# correctly (CJK codes often have this need).
628#
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000629# Note that the normalize() function which uses this tables
630# removes '_' and '-' characters from the encoding part of the
631# locale name before doing the lookup. This saves a lot of
632# space in the table.
633#
634# MAL 2004-12-10:
635# Updated alias mapping to most recent locale.alias file
636# from X.org distribution using makelocalealias.py.
637#
638# These are the differences compared to the old mapping (Python 2.4
639# and older):
640#
641# updated 'bg' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
642# updated 'bg_bg' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
643# updated 'bulgarian' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
644# updated 'cz' -> 'cz_CZ.ISO8859-2' to 'cs_CZ.ISO8859-2'
645# updated 'cz_cz' -> 'cz_CZ.ISO8859-2' to 'cs_CZ.ISO8859-2'
646# updated 'czech' -> 'cs_CS.ISO8859-2' to 'cs_CZ.ISO8859-2'
647# updated 'dutch' -> 'nl_BE.ISO8859-1' to 'nl_NL.ISO8859-1'
648# updated 'et' -> 'et_EE.ISO8859-4' to 'et_EE.ISO8859-15'
649# updated 'et_ee' -> 'et_EE.ISO8859-4' to 'et_EE.ISO8859-15'
650# updated 'fi' -> 'fi_FI.ISO8859-1' to 'fi_FI.ISO8859-15'
651# updated 'fi_fi' -> 'fi_FI.ISO8859-1' to 'fi_FI.ISO8859-15'
652# updated 'iw' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
653# updated 'iw_il' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
654# updated 'japanese' -> 'ja_JP.SJIS' to 'ja_JP.eucJP'
655# updated 'lt' -> 'lt_LT.ISO8859-4' to 'lt_LT.ISO8859-13'
656# updated 'lv' -> 'lv_LV.ISO8859-4' to 'lv_LV.ISO8859-13'
657# updated 'sl' -> 'sl_CS.ISO8859-2' to 'sl_SI.ISO8859-2'
658# updated 'slovene' -> 'sl_CS.ISO8859-2' to 'sl_SI.ISO8859-2'
659# updated 'th_th' -> 'th_TH.TACTIS' to 'th_TH.ISO8859-11'
660# updated 'zh_cn' -> 'zh_CN.eucCN' to 'zh_CN.gb2312'
661# updated 'zh_cn.big5' -> 'zh_TW.eucTW' to 'zh_TW.big5'
662# updated 'zh_tw' -> 'zh_TW.eucTW' to 'zh_TW.big5'
663#
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000664# MAL 2008-05-30:
665# Updated alias mapping to most recent locale.alias file
666# from X.org distribution using makelocalealias.py.
667#
668# These are the differences compared to the old mapping (Python 2.5
669# and older):
670#
671# updated 'cs_cs.iso88592' -> 'cs_CZ.ISO8859-2' to 'cs_CS.ISO8859-2'
672# updated 'serbocroatian' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
673# updated 'sh' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
674# updated 'sh_hr.iso88592' -> 'sh_HR.ISO8859-2' to 'hr_HR.ISO8859-2'
675# updated 'sh_sp' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
676# updated 'sh_yu' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
677# updated 'sp' -> 'sp_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
678# updated 'sp_yu' -> 'sp_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
679# updated 'sr' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
680# updated 'sr@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
681# updated 'sr_sp' -> 'sr_SP.ISO8859-2' to 'sr_CS.ISO8859-2'
682# updated 'sr_yu' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
683# updated 'sr_yu.cp1251@cyrillic' -> 'sr_YU.CP1251' to 'sr_CS.CP1251'
684# updated 'sr_yu.iso88592' -> 'sr_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
685# updated 'sr_yu.iso88595' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
686# updated 'sr_yu.iso88595@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
687# updated 'sr_yu.microsoftcp1251@cyrillic' -> 'sr_YU.CP1251' to 'sr_CS.CP1251'
688# updated 'sr_yu.utf8@cyrillic' -> 'sr_YU.UTF-8' to 'sr_CS.UTF-8'
689# updated 'sr_yu@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
690
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000691locale_alias = {
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000692 'a3': 'a3_AZ.KOI8-C',
693 'a3_az': 'a3_AZ.KOI8-C',
694 'a3_az.koi8c': 'a3_AZ.KOI8-C',
695 'af': 'af_ZA.ISO8859-1',
696 'af_za': 'af_ZA.ISO8859-1',
697 'af_za.iso88591': 'af_ZA.ISO8859-1',
698 'am': 'am_ET.UTF-8',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000699 'am_et': 'am_ET.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000700 'american': 'en_US.ISO8859-1',
701 'american.iso88591': 'en_US.ISO8859-1',
702 'ar': 'ar_AA.ISO8859-6',
703 'ar_aa': 'ar_AA.ISO8859-6',
704 'ar_aa.iso88596': 'ar_AA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000705 'ar_ae': 'ar_AE.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000706 'ar_ae.iso88596': 'ar_AE.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000707 'ar_bh': 'ar_BH.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000708 'ar_bh.iso88596': 'ar_BH.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000709 'ar_dz': 'ar_DZ.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000710 'ar_dz.iso88596': 'ar_DZ.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000711 'ar_eg': 'ar_EG.ISO8859-6',
712 'ar_eg.iso88596': 'ar_EG.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000713 'ar_iq': 'ar_IQ.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000714 'ar_iq.iso88596': 'ar_IQ.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000715 'ar_jo': 'ar_JO.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000716 'ar_jo.iso88596': 'ar_JO.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000717 'ar_kw': 'ar_KW.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000718 'ar_kw.iso88596': 'ar_KW.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000719 'ar_lb': 'ar_LB.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000720 'ar_lb.iso88596': 'ar_LB.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000721 'ar_ly': 'ar_LY.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000722 'ar_ly.iso88596': 'ar_LY.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000723 'ar_ma': 'ar_MA.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000724 'ar_ma.iso88596': 'ar_MA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000725 'ar_om': 'ar_OM.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000726 'ar_om.iso88596': 'ar_OM.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000727 'ar_qa': 'ar_QA.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000728 'ar_qa.iso88596': 'ar_QA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000729 'ar_sa': 'ar_SA.ISO8859-6',
730 'ar_sa.iso88596': 'ar_SA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000731 'ar_sd': 'ar_SD.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000732 'ar_sd.iso88596': 'ar_SD.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000733 'ar_sy': 'ar_SY.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000734 'ar_sy.iso88596': 'ar_SY.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000735 'ar_tn': 'ar_TN.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000736 'ar_tn.iso88596': 'ar_TN.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000737 'ar_ye': 'ar_YE.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000738 'ar_ye.iso88596': 'ar_YE.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000739 'arabic': 'ar_AA.ISO8859-6',
740 'arabic.iso88596': 'ar_AA.ISO8859-6',
741 'az': 'az_AZ.ISO8859-9E',
742 'az_az': 'az_AZ.ISO8859-9E',
743 'az_az.iso88599e': 'az_AZ.ISO8859-9E',
744 'be': 'be_BY.CP1251',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000745 'be_by': 'be_BY.CP1251',
746 'be_by.cp1251': 'be_BY.CP1251',
747 'be_by.microsoftcp1251': 'be_BY.CP1251',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000748 'bg': 'bg_BG.CP1251',
749 'bg_bg': 'bg_BG.CP1251',
750 'bg_bg.cp1251': 'bg_BG.CP1251',
751 'bg_bg.iso88595': 'bg_BG.ISO8859-5',
752 'bg_bg.koi8r': 'bg_BG.KOI8-R',
753 'bg_bg.microsoftcp1251': 'bg_BG.CP1251',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000754 'bn_in': 'bn_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000755 'bokmal': 'nb_NO.ISO8859-1',
756 'bokm\xe5l': 'nb_NO.ISO8859-1',
757 'br': 'br_FR.ISO8859-1',
758 'br_fr': 'br_FR.ISO8859-1',
759 'br_fr.iso88591': 'br_FR.ISO8859-1',
760 'br_fr.iso885914': 'br_FR.ISO8859-14',
761 'br_fr.iso885915': 'br_FR.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000762 'br_fr.iso885915@euro': 'br_FR.ISO8859-15',
763 'br_fr.utf8@euro': 'br_FR.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000764 'br_fr@euro': 'br_FR.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000765 'bs': 'bs_BA.ISO8859-2',
766 'bs_ba': 'bs_BA.ISO8859-2',
767 'bs_ba.iso88592': 'bs_BA.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000768 'bulgarian': 'bg_BG.CP1251',
769 'c': 'C',
770 'c-french': 'fr_CA.ISO8859-1',
771 'c-french.iso88591': 'fr_CA.ISO8859-1',
772 'c.en': 'C',
773 'c.iso88591': 'en_US.ISO8859-1',
774 'c_c': 'C',
775 'c_c.c': 'C',
776 'ca': 'ca_ES.ISO8859-1',
777 'ca_es': 'ca_ES.ISO8859-1',
778 'ca_es.iso88591': 'ca_ES.ISO8859-1',
779 'ca_es.iso885915': 'ca_ES.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000780 'ca_es.iso885915@euro': 'ca_ES.ISO8859-15',
781 'ca_es.utf8@euro': 'ca_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000782 'ca_es@euro': 'ca_ES.ISO8859-15',
783 'catalan': 'ca_ES.ISO8859-1',
784 'cextend': 'en_US.ISO8859-1',
785 'cextend.en': 'en_US.ISO8859-1',
786 'chinese-s': 'zh_CN.eucCN',
787 'chinese-t': 'zh_TW.eucTW',
788 'croatian': 'hr_HR.ISO8859-2',
789 'cs': 'cs_CZ.ISO8859-2',
790 'cs_cs': 'cs_CZ.ISO8859-2',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000791 'cs_cs.iso88592': 'cs_CS.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000792 'cs_cz': 'cs_CZ.ISO8859-2',
793 'cs_cz.iso88592': 'cs_CZ.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000794 'cy': 'cy_GB.ISO8859-1',
795 'cy_gb': 'cy_GB.ISO8859-1',
796 'cy_gb.iso88591': 'cy_GB.ISO8859-1',
797 'cy_gb.iso885914': 'cy_GB.ISO8859-14',
798 'cy_gb.iso885915': 'cy_GB.ISO8859-15',
799 'cy_gb@euro': 'cy_GB.ISO8859-15',
800 'cz': 'cs_CZ.ISO8859-2',
801 'cz_cz': 'cs_CZ.ISO8859-2',
802 'czech': 'cs_CZ.ISO8859-2',
803 'da': 'da_DK.ISO8859-1',
804 'da_dk': 'da_DK.ISO8859-1',
805 'da_dk.88591': 'da_DK.ISO8859-1',
806 'da_dk.885915': 'da_DK.ISO8859-15',
807 'da_dk.iso88591': 'da_DK.ISO8859-1',
808 'da_dk.iso885915': 'da_DK.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000809 'da_dk@euro': 'da_DK.ISO8859-15',
810 'danish': 'da_DK.ISO8859-1',
811 'danish.iso88591': 'da_DK.ISO8859-1',
812 'dansk': 'da_DK.ISO8859-1',
813 'de': 'de_DE.ISO8859-1',
814 'de_at': 'de_AT.ISO8859-1',
815 'de_at.iso88591': 'de_AT.ISO8859-1',
816 'de_at.iso885915': 'de_AT.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000817 'de_at.iso885915@euro': 'de_AT.ISO8859-15',
818 'de_at.utf8@euro': 'de_AT.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000819 'de_at@euro': 'de_AT.ISO8859-15',
820 'de_be': 'de_BE.ISO8859-1',
821 'de_be.iso88591': 'de_BE.ISO8859-1',
822 'de_be.iso885915': 'de_BE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000823 'de_be.iso885915@euro': 'de_BE.ISO8859-15',
824 'de_be.utf8@euro': 'de_BE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000825 'de_be@euro': 'de_BE.ISO8859-15',
826 'de_ch': 'de_CH.ISO8859-1',
827 'de_ch.iso88591': 'de_CH.ISO8859-1',
828 'de_ch.iso885915': 'de_CH.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000829 'de_ch@euro': 'de_CH.ISO8859-15',
830 'de_de': 'de_DE.ISO8859-1',
831 'de_de.88591': 'de_DE.ISO8859-1',
832 'de_de.885915': 'de_DE.ISO8859-15',
833 'de_de.885915@euro': 'de_DE.ISO8859-15',
834 'de_de.iso88591': 'de_DE.ISO8859-1',
835 'de_de.iso885915': 'de_DE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000836 'de_de.iso885915@euro': 'de_DE.ISO8859-15',
837 'de_de.utf8@euro': 'de_DE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000838 'de_de@euro': 'de_DE.ISO8859-15',
839 'de_lu': 'de_LU.ISO8859-1',
840 'de_lu.iso88591': 'de_LU.ISO8859-1',
841 'de_lu.iso885915': 'de_LU.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000842 'de_lu.iso885915@euro': 'de_LU.ISO8859-15',
843 'de_lu.utf8@euro': 'de_LU.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000844 'de_lu@euro': 'de_LU.ISO8859-15',
845 'deutsch': 'de_DE.ISO8859-1',
846 'dutch': 'nl_NL.ISO8859-1',
847 'dutch.iso88591': 'nl_BE.ISO8859-1',
848 'ee': 'ee_EE.ISO8859-4',
849 'ee_ee': 'ee_EE.ISO8859-4',
850 'ee_ee.iso88594': 'ee_EE.ISO8859-4',
851 'eesti': 'et_EE.ISO8859-1',
852 'el': 'el_GR.ISO8859-7',
853 'el_gr': 'el_GR.ISO8859-7',
854 'el_gr.iso88597': 'el_GR.ISO8859-7',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000855 'el_gr@euro': 'el_GR.ISO8859-15',
856 'en': 'en_US.ISO8859-1',
857 'en.iso88591': 'en_US.ISO8859-1',
858 'en_au': 'en_AU.ISO8859-1',
859 'en_au.iso88591': 'en_AU.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000860 'en_be': 'en_BE.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000861 'en_be@euro': 'en_BE.ISO8859-15',
862 'en_bw': 'en_BW.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000863 'en_bw.iso88591': 'en_BW.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000864 'en_ca': 'en_CA.ISO8859-1',
865 'en_ca.iso88591': 'en_CA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000866 'en_gb': 'en_GB.ISO8859-1',
867 'en_gb.88591': 'en_GB.ISO8859-1',
868 'en_gb.iso88591': 'en_GB.ISO8859-1',
869 'en_gb.iso885915': 'en_GB.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000870 'en_gb@euro': 'en_GB.ISO8859-15',
871 'en_hk': 'en_HK.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000872 'en_hk.iso88591': 'en_HK.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000873 'en_ie': 'en_IE.ISO8859-1',
874 'en_ie.iso88591': 'en_IE.ISO8859-1',
875 'en_ie.iso885915': 'en_IE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000876 'en_ie.iso885915@euro': 'en_IE.ISO8859-15',
877 'en_ie.utf8@euro': 'en_IE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000878 'en_ie@euro': 'en_IE.ISO8859-15',
879 'en_in': 'en_IN.ISO8859-1',
880 'en_nz': 'en_NZ.ISO8859-1',
881 'en_nz.iso88591': 'en_NZ.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000882 'en_ph': 'en_PH.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000883 'en_ph.iso88591': 'en_PH.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000884 'en_sg': 'en_SG.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000885 'en_sg.iso88591': 'en_SG.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000886 'en_uk': 'en_GB.ISO8859-1',
887 'en_us': 'en_US.ISO8859-1',
888 'en_us.88591': 'en_US.ISO8859-1',
889 'en_us.885915': 'en_US.ISO8859-15',
890 'en_us.iso88591': 'en_US.ISO8859-1',
891 'en_us.iso885915': 'en_US.ISO8859-15',
892 'en_us.iso885915@euro': 'en_US.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000893 'en_us@euro': 'en_US.ISO8859-15',
894 'en_us@euro@euro': 'en_US.ISO8859-15',
895 'en_za': 'en_ZA.ISO8859-1',
896 'en_za.88591': 'en_ZA.ISO8859-1',
897 'en_za.iso88591': 'en_ZA.ISO8859-1',
898 'en_za.iso885915': 'en_ZA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000899 'en_za@euro': 'en_ZA.ISO8859-15',
900 'en_zw': 'en_ZW.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000901 'en_zw.iso88591': 'en_ZW.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000902 'eng_gb': 'en_GB.ISO8859-1',
903 'eng_gb.8859': 'en_GB.ISO8859-1',
904 'english': 'en_EN.ISO8859-1',
905 'english.iso88591': 'en_EN.ISO8859-1',
906 'english_uk': 'en_GB.ISO8859-1',
907 'english_uk.8859': 'en_GB.ISO8859-1',
908 'english_united-states': 'en_US.ISO8859-1',
909 'english_united-states.437': 'C',
910 'english_us': 'en_US.ISO8859-1',
911 'english_us.8859': 'en_US.ISO8859-1',
912 'english_us.ascii': 'en_US.ISO8859-1',
913 'eo': 'eo_XX.ISO8859-3',
914 'eo_eo': 'eo_EO.ISO8859-3',
915 'eo_eo.iso88593': 'eo_EO.ISO8859-3',
916 'eo_xx': 'eo_XX.ISO8859-3',
917 'eo_xx.iso88593': 'eo_XX.ISO8859-3',
918 'es': 'es_ES.ISO8859-1',
919 'es_ar': 'es_AR.ISO8859-1',
920 'es_ar.iso88591': 'es_AR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000921 'es_bo': 'es_BO.ISO8859-1',
922 'es_bo.iso88591': 'es_BO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000923 'es_cl': 'es_CL.ISO8859-1',
924 'es_cl.iso88591': 'es_CL.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000925 'es_co': 'es_CO.ISO8859-1',
926 'es_co.iso88591': 'es_CO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000927 'es_cr': 'es_CR.ISO8859-1',
928 'es_cr.iso88591': 'es_CR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000929 'es_do': 'es_DO.ISO8859-1',
930 'es_do.iso88591': 'es_DO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000931 'es_ec': 'es_EC.ISO8859-1',
932 'es_ec.iso88591': 'es_EC.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000933 'es_es': 'es_ES.ISO8859-1',
934 'es_es.88591': 'es_ES.ISO8859-1',
935 'es_es.iso88591': 'es_ES.ISO8859-1',
936 'es_es.iso885915': 'es_ES.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000937 'es_es.iso885915@euro': 'es_ES.ISO8859-15',
938 'es_es.utf8@euro': 'es_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000939 'es_es@euro': 'es_ES.ISO8859-15',
940 'es_gt': 'es_GT.ISO8859-1',
941 'es_gt.iso88591': 'es_GT.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000942 'es_hn': 'es_HN.ISO8859-1',
943 'es_hn.iso88591': 'es_HN.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000944 'es_mx': 'es_MX.ISO8859-1',
945 'es_mx.iso88591': 'es_MX.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000946 'es_ni': 'es_NI.ISO8859-1',
947 'es_ni.iso88591': 'es_NI.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000948 'es_pa': 'es_PA.ISO8859-1',
949 'es_pa.iso88591': 'es_PA.ISO8859-1',
950 'es_pa.iso885915': 'es_PA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000951 'es_pa@euro': 'es_PA.ISO8859-15',
952 'es_pe': 'es_PE.ISO8859-1',
953 'es_pe.iso88591': 'es_PE.ISO8859-1',
954 'es_pe.iso885915': 'es_PE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000955 'es_pe@euro': 'es_PE.ISO8859-15',
956 'es_pr': 'es_PR.ISO8859-1',
957 'es_pr.iso88591': 'es_PR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000958 'es_py': 'es_PY.ISO8859-1',
959 'es_py.iso88591': 'es_PY.ISO8859-1',
960 'es_py.iso885915': 'es_PY.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000961 'es_py@euro': 'es_PY.ISO8859-15',
962 'es_sv': 'es_SV.ISO8859-1',
963 'es_sv.iso88591': 'es_SV.ISO8859-1',
964 'es_sv.iso885915': 'es_SV.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000965 'es_sv@euro': 'es_SV.ISO8859-15',
966 'es_us': 'es_US.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000967 'es_us.iso88591': 'es_US.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000968 'es_uy': 'es_UY.ISO8859-1',
969 'es_uy.iso88591': 'es_UY.ISO8859-1',
970 'es_uy.iso885915': 'es_UY.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000971 'es_uy@euro': 'es_UY.ISO8859-15',
972 'es_ve': 'es_VE.ISO8859-1',
973 'es_ve.iso88591': 'es_VE.ISO8859-1',
974 'es_ve.iso885915': 'es_VE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000975 'es_ve@euro': 'es_VE.ISO8859-15',
976 'estonian': 'et_EE.ISO8859-1',
977 'et': 'et_EE.ISO8859-15',
978 'et_ee': 'et_EE.ISO8859-15',
979 'et_ee.iso88591': 'et_EE.ISO8859-1',
980 'et_ee.iso885913': 'et_EE.ISO8859-13',
981 'et_ee.iso885915': 'et_EE.ISO8859-15',
982 'et_ee.iso88594': 'et_EE.ISO8859-4',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000983 'et_ee@euro': 'et_EE.ISO8859-15',
984 'eu': 'eu_ES.ISO8859-1',
985 'eu_es': 'eu_ES.ISO8859-1',
986 'eu_es.iso88591': 'eu_ES.ISO8859-1',
987 'eu_es.iso885915': 'eu_ES.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000988 'eu_es.iso885915@euro': 'eu_ES.ISO8859-15',
989 'eu_es.utf8@euro': 'eu_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000990 'eu_es@euro': 'eu_ES.ISO8859-15',
991 'fa': 'fa_IR.UTF-8',
992 'fa_ir': 'fa_IR.UTF-8',
993 'fa_ir.isiri3342': 'fa_IR.ISIRI-3342',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000994 'fi': 'fi_FI.ISO8859-15',
995 'fi_fi': 'fi_FI.ISO8859-15',
996 'fi_fi.88591': 'fi_FI.ISO8859-1',
997 'fi_fi.iso88591': 'fi_FI.ISO8859-1',
998 'fi_fi.iso885915': 'fi_FI.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000999 'fi_fi.iso885915@euro': 'fi_FI.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001000 'fi_fi.utf8@euro': 'fi_FI.UTF-8',
1001 'fi_fi@euro': 'fi_FI.ISO8859-15',
1002 'finnish': 'fi_FI.ISO8859-1',
1003 'finnish.iso88591': 'fi_FI.ISO8859-1',
1004 'fo': 'fo_FO.ISO8859-1',
1005 'fo_fo': 'fo_FO.ISO8859-1',
1006 'fo_fo.iso88591': 'fo_FO.ISO8859-1',
1007 'fo_fo.iso885915': 'fo_FO.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001008 'fo_fo@euro': 'fo_FO.ISO8859-15',
1009 'fr': 'fr_FR.ISO8859-1',
1010 'fr_be': 'fr_BE.ISO8859-1',
1011 'fr_be.88591': 'fr_BE.ISO8859-1',
1012 'fr_be.iso88591': 'fr_BE.ISO8859-1',
1013 'fr_be.iso885915': 'fr_BE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001014 'fr_be.iso885915@euro': 'fr_BE.ISO8859-15',
1015 'fr_be.utf8@euro': 'fr_BE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001016 'fr_be@euro': 'fr_BE.ISO8859-15',
1017 'fr_ca': 'fr_CA.ISO8859-1',
1018 'fr_ca.88591': 'fr_CA.ISO8859-1',
1019 'fr_ca.iso88591': 'fr_CA.ISO8859-1',
1020 'fr_ca.iso885915': 'fr_CA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001021 'fr_ca@euro': 'fr_CA.ISO8859-15',
1022 'fr_ch': 'fr_CH.ISO8859-1',
1023 'fr_ch.88591': 'fr_CH.ISO8859-1',
1024 'fr_ch.iso88591': 'fr_CH.ISO8859-1',
1025 'fr_ch.iso885915': 'fr_CH.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001026 'fr_ch@euro': 'fr_CH.ISO8859-15',
1027 'fr_fr': 'fr_FR.ISO8859-1',
1028 'fr_fr.88591': 'fr_FR.ISO8859-1',
1029 'fr_fr.iso88591': 'fr_FR.ISO8859-1',
1030 'fr_fr.iso885915': 'fr_FR.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001031 'fr_fr.iso885915@euro': 'fr_FR.ISO8859-15',
1032 'fr_fr.utf8@euro': 'fr_FR.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001033 'fr_fr@euro': 'fr_FR.ISO8859-15',
1034 'fr_lu': 'fr_LU.ISO8859-1',
1035 'fr_lu.88591': 'fr_LU.ISO8859-1',
1036 'fr_lu.iso88591': 'fr_LU.ISO8859-1',
1037 'fr_lu.iso885915': 'fr_LU.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001038 'fr_lu.iso885915@euro': 'fr_LU.ISO8859-15',
1039 'fr_lu.utf8@euro': 'fr_LU.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001040 'fr_lu@euro': 'fr_LU.ISO8859-15',
1041 'fran\xe7ais': 'fr_FR.ISO8859-1',
1042 'fre_fr': 'fr_FR.ISO8859-1',
1043 'fre_fr.8859': 'fr_FR.ISO8859-1',
1044 'french': 'fr_FR.ISO8859-1',
1045 'french.iso88591': 'fr_CH.ISO8859-1',
1046 'french_france': 'fr_FR.ISO8859-1',
1047 'french_france.8859': 'fr_FR.ISO8859-1',
1048 'ga': 'ga_IE.ISO8859-1',
1049 'ga_ie': 'ga_IE.ISO8859-1',
1050 'ga_ie.iso88591': 'ga_IE.ISO8859-1',
1051 'ga_ie.iso885914': 'ga_IE.ISO8859-14',
1052 'ga_ie.iso885915': 'ga_IE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001053 'ga_ie.iso885915@euro': 'ga_IE.ISO8859-15',
1054 'ga_ie.utf8@euro': 'ga_IE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001055 'ga_ie@euro': 'ga_IE.ISO8859-15',
1056 'galego': 'gl_ES.ISO8859-1',
1057 'galician': 'gl_ES.ISO8859-1',
1058 'gd': 'gd_GB.ISO8859-1',
1059 'gd_gb': 'gd_GB.ISO8859-1',
1060 'gd_gb.iso88591': 'gd_GB.ISO8859-1',
1061 'gd_gb.iso885914': 'gd_GB.ISO8859-14',
1062 'gd_gb.iso885915': 'gd_GB.ISO8859-15',
1063 'gd_gb@euro': 'gd_GB.ISO8859-15',
1064 'ger_de': 'de_DE.ISO8859-1',
1065 'ger_de.8859': 'de_DE.ISO8859-1',
1066 'german': 'de_DE.ISO8859-1',
1067 'german.iso88591': 'de_CH.ISO8859-1',
1068 'german_germany': 'de_DE.ISO8859-1',
1069 'german_germany.8859': 'de_DE.ISO8859-1',
1070 'gl': 'gl_ES.ISO8859-1',
1071 'gl_es': 'gl_ES.ISO8859-1',
1072 'gl_es.iso88591': 'gl_ES.ISO8859-1',
1073 'gl_es.iso885915': 'gl_ES.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001074 'gl_es.iso885915@euro': 'gl_ES.ISO8859-15',
1075 'gl_es.utf8@euro': 'gl_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001076 'gl_es@euro': 'gl_ES.ISO8859-15',
1077 'greek': 'el_GR.ISO8859-7',
1078 'greek.iso88597': 'el_GR.ISO8859-7',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001079 'gu_in': 'gu_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001080 'gv': 'gv_GB.ISO8859-1',
1081 'gv_gb': 'gv_GB.ISO8859-1',
1082 'gv_gb.iso88591': 'gv_GB.ISO8859-1',
1083 'gv_gb.iso885914': 'gv_GB.ISO8859-14',
1084 'gv_gb.iso885915': 'gv_GB.ISO8859-15',
1085 'gv_gb@euro': 'gv_GB.ISO8859-15',
1086 'he': 'he_IL.ISO8859-8',
1087 'he_il': 'he_IL.ISO8859-8',
1088 'he_il.cp1255': 'he_IL.CP1255',
1089 'he_il.iso88598': 'he_IL.ISO8859-8',
1090 'he_il.microsoftcp1255': 'he_IL.CP1255',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001091 'hebrew': 'iw_IL.ISO8859-8',
1092 'hebrew.iso88598': 'iw_IL.ISO8859-8',
1093 'hi': 'hi_IN.ISCII-DEV',
1094 'hi_in': 'hi_IN.ISCII-DEV',
1095 'hi_in.isciidev': 'hi_IN.ISCII-DEV',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001096 'hr': 'hr_HR.ISO8859-2',
1097 'hr_hr': 'hr_HR.ISO8859-2',
1098 'hr_hr.iso88592': 'hr_HR.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001099 'hrvatski': 'hr_HR.ISO8859-2',
1100 'hu': 'hu_HU.ISO8859-2',
1101 'hu_hu': 'hu_HU.ISO8859-2',
1102 'hu_hu.iso88592': 'hu_HU.ISO8859-2',
1103 'hungarian': 'hu_HU.ISO8859-2',
1104 'icelandic': 'is_IS.ISO8859-1',
1105 'icelandic.iso88591': 'is_IS.ISO8859-1',
1106 'id': 'id_ID.ISO8859-1',
1107 'id_id': 'id_ID.ISO8859-1',
1108 'in': 'id_ID.ISO8859-1',
1109 'in_id': 'id_ID.ISO8859-1',
1110 'is': 'is_IS.ISO8859-1',
1111 'is_is': 'is_IS.ISO8859-1',
1112 'is_is.iso88591': 'is_IS.ISO8859-1',
1113 'is_is.iso885915': 'is_IS.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001114 'is_is@euro': 'is_IS.ISO8859-15',
1115 'iso-8859-1': 'en_US.ISO8859-1',
1116 'iso-8859-15': 'en_US.ISO8859-15',
1117 'iso8859-1': 'en_US.ISO8859-1',
1118 'iso8859-15': 'en_US.ISO8859-15',
1119 'iso_8859_1': 'en_US.ISO8859-1',
1120 'iso_8859_15': 'en_US.ISO8859-15',
1121 'it': 'it_IT.ISO8859-1',
1122 'it_ch': 'it_CH.ISO8859-1',
1123 'it_ch.iso88591': 'it_CH.ISO8859-1',
1124 'it_ch.iso885915': 'it_CH.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001125 'it_ch@euro': 'it_CH.ISO8859-15',
1126 'it_it': 'it_IT.ISO8859-1',
1127 'it_it.88591': 'it_IT.ISO8859-1',
1128 'it_it.iso88591': 'it_IT.ISO8859-1',
1129 'it_it.iso885915': 'it_IT.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001130 'it_it.iso885915@euro': 'it_IT.ISO8859-15',
1131 'it_it.utf8@euro': 'it_IT.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001132 'it_it@euro': 'it_IT.ISO8859-15',
1133 'italian': 'it_IT.ISO8859-1',
1134 'italian.iso88591': 'it_IT.ISO8859-1',
1135 'iu': 'iu_CA.NUNACOM-8',
1136 'iu_ca': 'iu_CA.NUNACOM-8',
1137 'iu_ca.nunacom8': 'iu_CA.NUNACOM-8',
1138 'iw': 'he_IL.ISO8859-8',
1139 'iw_il': 'he_IL.ISO8859-8',
1140 'iw_il.iso88598': 'he_IL.ISO8859-8',
1141 'ja': 'ja_JP.eucJP',
1142 'ja.jis': 'ja_JP.JIS7',
1143 'ja.sjis': 'ja_JP.SJIS',
1144 'ja_jp': 'ja_JP.eucJP',
1145 'ja_jp.ajec': 'ja_JP.eucJP',
1146 'ja_jp.euc': 'ja_JP.eucJP',
1147 'ja_jp.eucjp': 'ja_JP.eucJP',
1148 'ja_jp.iso-2022-jp': 'ja_JP.JIS7',
1149 'ja_jp.iso2022jp': 'ja_JP.JIS7',
1150 'ja_jp.jis': 'ja_JP.JIS7',
1151 'ja_jp.jis7': 'ja_JP.JIS7',
1152 'ja_jp.mscode': 'ja_JP.SJIS',
1153 'ja_jp.sjis': 'ja_JP.SJIS',
1154 'ja_jp.ujis': 'ja_JP.eucJP',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001155 'japan': 'ja_JP.eucJP',
1156 'japanese': 'ja_JP.eucJP',
1157 'japanese-euc': 'ja_JP.eucJP',
1158 'japanese.euc': 'ja_JP.eucJP',
1159 'japanese.sjis': 'ja_JP.SJIS',
1160 'jp_jp': 'ja_JP.eucJP',
1161 'ka': 'ka_GE.GEORGIAN-ACADEMY',
1162 'ka_ge': 'ka_GE.GEORGIAN-ACADEMY',
1163 'ka_ge.georgianacademy': 'ka_GE.GEORGIAN-ACADEMY',
1164 'ka_ge.georgianps': 'ka_GE.GEORGIAN-PS',
1165 'ka_ge.georgianrs': 'ka_GE.GEORGIAN-ACADEMY',
1166 'kl': 'kl_GL.ISO8859-1',
1167 'kl_gl': 'kl_GL.ISO8859-1',
1168 'kl_gl.iso88591': 'kl_GL.ISO8859-1',
1169 'kl_gl.iso885915': 'kl_GL.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001170 'kl_gl@euro': 'kl_GL.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001171 'km_kh': 'km_KH.UTF-8',
1172 'kn_in': 'kn_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001173 'ko': 'ko_KR.eucKR',
1174 'ko_kr': 'ko_KR.eucKR',
1175 'ko_kr.euc': 'ko_KR.eucKR',
1176 'ko_kr.euckr': 'ko_KR.eucKR',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001177 'korean': 'ko_KR.eucKR',
1178 'korean.euc': 'ko_KR.eucKR',
1179 'kw': 'kw_GB.ISO8859-1',
1180 'kw_gb': 'kw_GB.ISO8859-1',
1181 'kw_gb.iso88591': 'kw_GB.ISO8859-1',
1182 'kw_gb.iso885914': 'kw_GB.ISO8859-14',
1183 'kw_gb.iso885915': 'kw_GB.ISO8859-15',
1184 'kw_gb@euro': 'kw_GB.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001185 'ky': 'ky_KG.UTF-8',
1186 'ky_kg': 'ky_KG.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001187 'lithuanian': 'lt_LT.ISO8859-13',
1188 'lo': 'lo_LA.MULELAO-1',
1189 'lo_la': 'lo_LA.MULELAO-1',
1190 'lo_la.cp1133': 'lo_LA.IBM-CP1133',
1191 'lo_la.ibmcp1133': 'lo_LA.IBM-CP1133',
1192 'lo_la.mulelao1': 'lo_LA.MULELAO-1',
1193 'lt': 'lt_LT.ISO8859-13',
1194 'lt_lt': 'lt_LT.ISO8859-13',
1195 'lt_lt.iso885913': 'lt_LT.ISO8859-13',
1196 'lt_lt.iso88594': 'lt_LT.ISO8859-4',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001197 'lv': 'lv_LV.ISO8859-13',
1198 'lv_lv': 'lv_LV.ISO8859-13',
1199 'lv_lv.iso885913': 'lv_LV.ISO8859-13',
1200 'lv_lv.iso88594': 'lv_LV.ISO8859-4',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001201 'mi': 'mi_NZ.ISO8859-1',
1202 'mi_nz': 'mi_NZ.ISO8859-1',
1203 'mi_nz.iso88591': 'mi_NZ.ISO8859-1',
1204 'mk': 'mk_MK.ISO8859-5',
1205 'mk_mk': 'mk_MK.ISO8859-5',
1206 'mk_mk.cp1251': 'mk_MK.CP1251',
1207 'mk_mk.iso88595': 'mk_MK.ISO8859-5',
1208 'mk_mk.microsoftcp1251': 'mk_MK.CP1251',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001209 'mr_in': 'mr_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001210 'ms': 'ms_MY.ISO8859-1',
1211 'ms_my': 'ms_MY.ISO8859-1',
1212 'ms_my.iso88591': 'ms_MY.ISO8859-1',
1213 'mt': 'mt_MT.ISO8859-3',
1214 'mt_mt': 'mt_MT.ISO8859-3',
1215 'mt_mt.iso88593': 'mt_MT.ISO8859-3',
1216 'nb': 'nb_NO.ISO8859-1',
1217 'nb_no': 'nb_NO.ISO8859-1',
1218 'nb_no.88591': 'nb_NO.ISO8859-1',
1219 'nb_no.iso88591': 'nb_NO.ISO8859-1',
1220 'nb_no.iso885915': 'nb_NO.ISO8859-15',
1221 'nb_no@euro': 'nb_NO.ISO8859-15',
1222 'nl': 'nl_NL.ISO8859-1',
1223 'nl_be': 'nl_BE.ISO8859-1',
1224 'nl_be.88591': 'nl_BE.ISO8859-1',
1225 'nl_be.iso88591': 'nl_BE.ISO8859-1',
1226 'nl_be.iso885915': 'nl_BE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001227 'nl_be.iso885915@euro': 'nl_BE.ISO8859-15',
1228 'nl_be.utf8@euro': 'nl_BE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001229 'nl_be@euro': 'nl_BE.ISO8859-15',
1230 'nl_nl': 'nl_NL.ISO8859-1',
1231 'nl_nl.88591': 'nl_NL.ISO8859-1',
1232 'nl_nl.iso88591': 'nl_NL.ISO8859-1',
1233 'nl_nl.iso885915': 'nl_NL.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001234 'nl_nl.iso885915@euro': 'nl_NL.ISO8859-15',
1235 'nl_nl.utf8@euro': 'nl_NL.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001236 'nl_nl@euro': 'nl_NL.ISO8859-15',
1237 'nn': 'nn_NO.ISO8859-1',
1238 'nn_no': 'nn_NO.ISO8859-1',
1239 'nn_no.88591': 'nn_NO.ISO8859-1',
1240 'nn_no.iso88591': 'nn_NO.ISO8859-1',
1241 'nn_no.iso885915': 'nn_NO.ISO8859-15',
1242 'nn_no@euro': 'nn_NO.ISO8859-15',
1243 'no': 'no_NO.ISO8859-1',
1244 'no@nynorsk': 'ny_NO.ISO8859-1',
1245 'no_no': 'no_NO.ISO8859-1',
1246 'no_no.88591': 'no_NO.ISO8859-1',
1247 'no_no.iso88591': 'no_NO.ISO8859-1',
1248 'no_no.iso885915': 'no_NO.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001249 'no_no@euro': 'no_NO.ISO8859-15',
1250 'norwegian': 'no_NO.ISO8859-1',
1251 'norwegian.iso88591': 'no_NO.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001252 'nr': 'nr_ZA.ISO8859-1',
1253 'nr_za': 'nr_ZA.ISO8859-1',
1254 'nr_za.iso88591': 'nr_ZA.ISO8859-1',
1255 'nso': 'nso_ZA.ISO8859-15',
1256 'nso_za': 'nso_ZA.ISO8859-15',
1257 'nso_za.iso885915': 'nso_ZA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001258 'ny': 'ny_NO.ISO8859-1',
1259 'ny_no': 'ny_NO.ISO8859-1',
1260 'ny_no.88591': 'ny_NO.ISO8859-1',
1261 'ny_no.iso88591': 'ny_NO.ISO8859-1',
1262 'ny_no.iso885915': 'ny_NO.ISO8859-15',
1263 'ny_no@euro': 'ny_NO.ISO8859-15',
1264 'nynorsk': 'nn_NO.ISO8859-1',
1265 'oc': 'oc_FR.ISO8859-1',
1266 'oc_fr': 'oc_FR.ISO8859-1',
1267 'oc_fr.iso88591': 'oc_FR.ISO8859-1',
1268 'oc_fr.iso885915': 'oc_FR.ISO8859-15',
1269 'oc_fr@euro': 'oc_FR.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001270 'pa_in': 'pa_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001271 'pd': 'pd_US.ISO8859-1',
1272 'pd_de': 'pd_DE.ISO8859-1',
1273 'pd_de.iso88591': 'pd_DE.ISO8859-1',
1274 'pd_de.iso885915': 'pd_DE.ISO8859-15',
1275 'pd_de@euro': 'pd_DE.ISO8859-15',
1276 'pd_us': 'pd_US.ISO8859-1',
1277 'pd_us.iso88591': 'pd_US.ISO8859-1',
1278 'pd_us.iso885915': 'pd_US.ISO8859-15',
1279 'pd_us@euro': 'pd_US.ISO8859-15',
1280 'ph': 'ph_PH.ISO8859-1',
1281 'ph_ph': 'ph_PH.ISO8859-1',
1282 'ph_ph.iso88591': 'ph_PH.ISO8859-1',
1283 'pl': 'pl_PL.ISO8859-2',
1284 'pl_pl': 'pl_PL.ISO8859-2',
1285 'pl_pl.iso88592': 'pl_PL.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001286 'polish': 'pl_PL.ISO8859-2',
1287 'portuguese': 'pt_PT.ISO8859-1',
1288 'portuguese.iso88591': 'pt_PT.ISO8859-1',
1289 'portuguese_brazil': 'pt_BR.ISO8859-1',
1290 'portuguese_brazil.8859': 'pt_BR.ISO8859-1',
1291 'posix': 'C',
1292 'posix-utf2': 'C',
1293 'pp': 'pp_AN.ISO8859-1',
1294 'pp_an': 'pp_AN.ISO8859-1',
1295 'pp_an.iso88591': 'pp_AN.ISO8859-1',
1296 'pt': 'pt_PT.ISO8859-1',
1297 'pt_br': 'pt_BR.ISO8859-1',
1298 'pt_br.88591': 'pt_BR.ISO8859-1',
1299 'pt_br.iso88591': 'pt_BR.ISO8859-1',
1300 'pt_br.iso885915': 'pt_BR.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001301 'pt_br@euro': 'pt_BR.ISO8859-15',
1302 'pt_pt': 'pt_PT.ISO8859-1',
1303 'pt_pt.88591': 'pt_PT.ISO8859-1',
1304 'pt_pt.iso88591': 'pt_PT.ISO8859-1',
1305 'pt_pt.iso885915': 'pt_PT.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001306 'pt_pt.iso885915@euro': 'pt_PT.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001307 'pt_pt.utf8@euro': 'pt_PT.UTF-8',
1308 'pt_pt@euro': 'pt_PT.ISO8859-15',
1309 'ro': 'ro_RO.ISO8859-2',
1310 'ro_ro': 'ro_RO.ISO8859-2',
1311 'ro_ro.iso88592': 'ro_RO.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001312 'romanian': 'ro_RO.ISO8859-2',
1313 'ru': 'ru_RU.ISO8859-5',
1314 'ru_ru': 'ru_RU.ISO8859-5',
1315 'ru_ru.cp1251': 'ru_RU.CP1251',
1316 'ru_ru.iso88595': 'ru_RU.ISO8859-5',
1317 'ru_ru.koi8r': 'ru_RU.KOI8-R',
1318 'ru_ru.microsoftcp1251': 'ru_RU.CP1251',
1319 'ru_ua': 'ru_UA.KOI8-U',
1320 'ru_ua.cp1251': 'ru_UA.CP1251',
1321 'ru_ua.koi8u': 'ru_UA.KOI8-U',
1322 'ru_ua.microsoftcp1251': 'ru_UA.CP1251',
1323 'rumanian': 'ro_RO.ISO8859-2',
1324 'russian': 'ru_RU.ISO8859-5',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001325 'rw': 'rw_RW.ISO8859-1',
1326 'rw_rw': 'rw_RW.ISO8859-1',
1327 'rw_rw.iso88591': 'rw_RW.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001328 'se_no': 'se_NO.UTF-8',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001329 'serbocroatian': 'sr_CS.ISO8859-2',
1330 'sh': 'sr_CS.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001331 'sh_hr': 'sh_HR.ISO8859-2',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001332 'sh_hr.iso88592': 'hr_HR.ISO8859-2',
1333 'sh_sp': 'sr_CS.ISO8859-2',
1334 'sh_yu': 'sr_CS.ISO8859-2',
1335 'si': 'si_LK.UTF-8',
1336 'si_lk': 'si_LK.UTF-8',
1337 'sinhala': 'si_LK.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001338 'sk': 'sk_SK.ISO8859-2',
1339 'sk_sk': 'sk_SK.ISO8859-2',
1340 'sk_sk.iso88592': 'sk_SK.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001341 'sl': 'sl_SI.ISO8859-2',
1342 'sl_cs': 'sl_CS.ISO8859-2',
1343 'sl_si': 'sl_SI.ISO8859-2',
1344 'sl_si.iso88592': 'sl_SI.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001345 'slovak': 'sk_SK.ISO8859-2',
1346 'slovene': 'sl_SI.ISO8859-2',
1347 'slovenian': 'sl_SI.ISO8859-2',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001348 'sp': 'sr_CS.ISO8859-5',
1349 'sp_yu': 'sr_CS.ISO8859-5',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001350 'spanish': 'es_ES.ISO8859-1',
1351 'spanish.iso88591': 'es_ES.ISO8859-1',
1352 'spanish_spain': 'es_ES.ISO8859-1',
1353 'spanish_spain.8859': 'es_ES.ISO8859-1',
1354 'sq': 'sq_AL.ISO8859-2',
1355 'sq_al': 'sq_AL.ISO8859-2',
1356 'sq_al.iso88592': 'sq_AL.ISO8859-2',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001357 'sr': 'sr_CS.ISO8859-5',
1358 'sr@cyrillic': 'sr_CS.ISO8859-5',
1359 'sr@latn': 'sr_CS.ISO8859-2',
1360 'sr_cs.iso88592': 'sr_CS.ISO8859-2',
1361 'sr_cs.iso88592@latn': 'sr_CS.ISO8859-2',
1362 'sr_cs.iso88595': 'sr_CS.ISO8859-5',
1363 'sr_cs.utf8@latn': 'sr_CS.UTF-8',
1364 'sr_cs@latn': 'sr_CS.ISO8859-2',
1365 'sr_sp': 'sr_CS.ISO8859-2',
1366 'sr_yu': 'sr_CS.ISO8859-5',
1367 'sr_yu.cp1251@cyrillic': 'sr_CS.CP1251',
1368 'sr_yu.iso88592': 'sr_CS.ISO8859-2',
1369 'sr_yu.iso88595': 'sr_CS.ISO8859-5',
1370 'sr_yu.iso88595@cyrillic': 'sr_CS.ISO8859-5',
1371 'sr_yu.microsoftcp1251@cyrillic': 'sr_CS.CP1251',
1372 'sr_yu.utf8@cyrillic': 'sr_CS.UTF-8',
1373 'sr_yu@cyrillic': 'sr_CS.ISO8859-5',
1374 'ss': 'ss_ZA.ISO8859-1',
1375 'ss_za': 'ss_ZA.ISO8859-1',
1376 'ss_za.iso88591': 'ss_ZA.ISO8859-1',
1377 'st': 'st_ZA.ISO8859-1',
1378 'st_za': 'st_ZA.ISO8859-1',
1379 'st_za.iso88591': 'st_ZA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001380 'sv': 'sv_SE.ISO8859-1',
1381 'sv_fi': 'sv_FI.ISO8859-1',
1382 'sv_fi.iso88591': 'sv_FI.ISO8859-1',
1383 'sv_fi.iso885915': 'sv_FI.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001384 'sv_fi.iso885915@euro': 'sv_FI.ISO8859-15',
1385 'sv_fi.utf8@euro': 'sv_FI.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001386 'sv_fi@euro': 'sv_FI.ISO8859-15',
1387 'sv_se': 'sv_SE.ISO8859-1',
1388 'sv_se.88591': 'sv_SE.ISO8859-1',
1389 'sv_se.iso88591': 'sv_SE.ISO8859-1',
1390 'sv_se.iso885915': 'sv_SE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001391 'sv_se@euro': 'sv_SE.ISO8859-15',
1392 'swedish': 'sv_SE.ISO8859-1',
1393 'swedish.iso88591': 'sv_SE.ISO8859-1',
1394 'ta': 'ta_IN.TSCII-0',
1395 'ta_in': 'ta_IN.TSCII-0',
1396 'ta_in.tscii': 'ta_IN.TSCII-0',
1397 'ta_in.tscii0': 'ta_IN.TSCII-0',
1398 'tg': 'tg_TJ.KOI8-C',
1399 'tg_tj': 'tg_TJ.KOI8-C',
1400 'tg_tj.koi8c': 'tg_TJ.KOI8-C',
1401 'th': 'th_TH.ISO8859-11',
1402 'th_th': 'th_TH.ISO8859-11',
1403 'th_th.iso885911': 'th_TH.ISO8859-11',
1404 'th_th.tactis': 'th_TH.TIS620',
1405 'th_th.tis620': 'th_TH.TIS620',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001406 'thai': 'th_TH.ISO8859-11',
1407 'tl': 'tl_PH.ISO8859-1',
1408 'tl_ph': 'tl_PH.ISO8859-1',
1409 'tl_ph.iso88591': 'tl_PH.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001410 'tn': 'tn_ZA.ISO8859-15',
1411 'tn_za': 'tn_ZA.ISO8859-15',
1412 'tn_za.iso885915': 'tn_ZA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001413 'tr': 'tr_TR.ISO8859-9',
1414 'tr_tr': 'tr_TR.ISO8859-9',
1415 'tr_tr.iso88599': 'tr_TR.ISO8859-9',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001416 'ts': 'ts_ZA.ISO8859-1',
1417 'ts_za': 'ts_ZA.ISO8859-1',
1418 'ts_za.iso88591': 'ts_ZA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001419 'tt': 'tt_RU.TATAR-CYR',
1420 'tt_ru': 'tt_RU.TATAR-CYR',
1421 'tt_ru.koi8c': 'tt_RU.KOI8-C',
1422 'tt_ru.tatarcyr': 'tt_RU.TATAR-CYR',
1423 'turkish': 'tr_TR.ISO8859-9',
1424 'turkish.iso88599': 'tr_TR.ISO8859-9',
1425 'uk': 'uk_UA.KOI8-U',
1426 'uk_ua': 'uk_UA.KOI8-U',
1427 'uk_ua.cp1251': 'uk_UA.CP1251',
1428 'uk_ua.iso88595': 'uk_UA.ISO8859-5',
1429 'uk_ua.koi8u': 'uk_UA.KOI8-U',
1430 'uk_ua.microsoftcp1251': 'uk_UA.CP1251',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001431 'univ': 'en_US.utf',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001432 'universal': 'en_US.utf',
1433 'universal.utf8@ucs4': 'en_US.UTF-8',
1434 'ur': 'ur_PK.CP1256',
1435 'ur_pk': 'ur_PK.CP1256',
1436 'ur_pk.cp1256': 'ur_PK.CP1256',
1437 'ur_pk.microsoftcp1256': 'ur_PK.CP1256',
1438 'uz': 'uz_UZ.UTF-8',
1439 'uz_uz': 'uz_UZ.UTF-8',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001440 'uz_uz.iso88591': 'uz_UZ.ISO8859-1',
1441 'uz_uz.utf8@cyrillic': 'uz_UZ.UTF-8',
1442 'uz_uz@cyrillic': 'uz_UZ.UTF-8',
1443 've': 've_ZA.UTF-8',
1444 've_za': 've_ZA.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001445 'vi': 'vi_VN.TCVN',
1446 'vi_vn': 'vi_VN.TCVN',
1447 'vi_vn.tcvn': 'vi_VN.TCVN',
1448 'vi_vn.tcvn5712': 'vi_VN.TCVN',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001449 'vi_vn.viscii': 'vi_VN.VISCII',
1450 'vi_vn.viscii111': 'vi_VN.VISCII',
1451 'wa': 'wa_BE.ISO8859-1',
1452 'wa_be': 'wa_BE.ISO8859-1',
1453 'wa_be.iso88591': 'wa_BE.ISO8859-1',
1454 'wa_be.iso885915': 'wa_BE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001455 'wa_be.iso885915@euro': 'wa_BE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001456 'wa_be@euro': 'wa_BE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001457 'xh': 'xh_ZA.ISO8859-1',
1458 'xh_za': 'xh_ZA.ISO8859-1',
1459 'xh_za.iso88591': 'xh_ZA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001460 'yi': 'yi_US.CP1255',
1461 'yi_us': 'yi_US.CP1255',
1462 'yi_us.cp1255': 'yi_US.CP1255',
1463 'yi_us.microsoftcp1255': 'yi_US.CP1255',
1464 'zh': 'zh_CN.eucCN',
1465 'zh_cn': 'zh_CN.gb2312',
1466 'zh_cn.big5': 'zh_TW.big5',
1467 'zh_cn.euc': 'zh_CN.eucCN',
1468 'zh_cn.gb18030': 'zh_CN.gb18030',
1469 'zh_cn.gb2312': 'zh_CN.gb2312',
1470 'zh_cn.gbk': 'zh_CN.gbk',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001471 'zh_hk': 'zh_HK.big5hkscs',
1472 'zh_hk.big5': 'zh_HK.big5',
1473 'zh_hk.big5hkscs': 'zh_HK.big5hkscs',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001474 'zh_tw': 'zh_TW.big5',
1475 'zh_tw.big5': 'zh_TW.big5',
1476 'zh_tw.euc': 'zh_TW.eucTW',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001477 'zh_tw.euctw': 'zh_TW.eucTW',
1478 'zu': 'zu_ZA.ISO8859-1',
1479 'zu_za': 'zu_ZA.ISO8859-1',
1480 'zu_za.iso88591': 'zu_ZA.ISO8859-1',
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001481}
1482
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001483#
Georg Brandlb709c2c2006-01-20 09:07:35 +00001484# This maps Windows language identifiers to locale strings.
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001485#
Tim Peters777f1082006-01-20 20:03:24 +00001486# This list has been updated from
Georg Brandlb709c2c2006-01-20 09:07:35 +00001487# http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nls_238z.asp
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001488# to include every locale up to Windows Vista.
Fredrik Lundh37a09822002-10-19 20:19:10 +00001489#
Georg Brandl5035c1c2006-01-20 13:38:26 +00001490# NOTE: this mapping is incomplete. If your language is missing, please
1491# submit a bug report to Python bug manager, which you can find via:
1492# http://www.python.org/dev/
1493# Make sure you include the missing language identifier and the suggested
1494# locale code.
1495#
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001496
1497windows_locale = {
Georg Brandlb709c2c2006-01-20 09:07:35 +00001498 0x0436: "af_ZA", # Afrikaans
1499 0x041c: "sq_AL", # Albanian
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001500 0x0484: "gsw_FR",# Alsatian - France
1501 0x045e: "am_ET", # Amharic - Ethiopia
Georg Brandlb709c2c2006-01-20 09:07:35 +00001502 0x0401: "ar_SA", # Arabic - Saudi Arabia
1503 0x0801: "ar_IQ", # Arabic - Iraq
1504 0x0c01: "ar_EG", # Arabic - Egypt
1505 0x1001: "ar_LY", # Arabic - Libya
1506 0x1401: "ar_DZ", # Arabic - Algeria
1507 0x1801: "ar_MA", # Arabic - Morocco
1508 0x1c01: "ar_TN", # Arabic - Tunisia
1509 0x2001: "ar_OM", # Arabic - Oman
1510 0x2401: "ar_YE", # Arabic - Yemen
1511 0x2801: "ar_SY", # Arabic - Syria
1512 0x2c01: "ar_JO", # Arabic - Jordan
1513 0x3001: "ar_LB", # Arabic - Lebanon
1514 0x3401: "ar_KW", # Arabic - Kuwait
1515 0x3801: "ar_AE", # Arabic - United Arab Emirates
1516 0x3c01: "ar_BH", # Arabic - Bahrain
1517 0x4001: "ar_QA", # Arabic - Qatar
1518 0x042b: "hy_AM", # Armenian
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001519 0x044d: "as_IN", # Assamese - India
1520 0x042c: "az_AZ", # Azeri - Latin
Georg Brandlb709c2c2006-01-20 09:07:35 +00001521 0x082c: "az_AZ", # Azeri - Cyrillic
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001522 0x046d: "ba_RU", # Bashkir
1523 0x042d: "eu_ES", # Basque - Russia
Georg Brandlb709c2c2006-01-20 09:07:35 +00001524 0x0423: "be_BY", # Belarusian
1525 0x0445: "bn_IN", # Begali
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001526 0x201a: "bs_BA", # Bosnian - Cyrillic
1527 0x141a: "bs_BA", # Bosnian - Latin
Georg Brandlb709c2c2006-01-20 09:07:35 +00001528 0x047e: "br_FR", # Breton - France
1529 0x0402: "bg_BG", # Bulgarian
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001530# 0x0455: "my_MM", # Burmese - Not supported
Georg Brandlb709c2c2006-01-20 09:07:35 +00001531 0x0403: "ca_ES", # Catalan
1532 0x0004: "zh_CHS",# Chinese - Simplified
1533 0x0404: "zh_TW", # Chinese - Taiwan
1534 0x0804: "zh_CN", # Chinese - PRC
1535 0x0c04: "zh_HK", # Chinese - Hong Kong S.A.R.
1536 0x1004: "zh_SG", # Chinese - Singapore
1537 0x1404: "zh_MO", # Chinese - Macao S.A.R.
1538 0x7c04: "zh_CHT",# Chinese - Traditional
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001539 0x0483: "co_FR", # Corsican - France
Georg Brandlb709c2c2006-01-20 09:07:35 +00001540 0x041a: "hr_HR", # Croatian
1541 0x101a: "hr_BA", # Croatian - Bosnia
1542 0x0405: "cs_CZ", # Czech
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001543 0x0406: "da_DK", # Danish
Georg Brandlb709c2c2006-01-20 09:07:35 +00001544 0x048c: "gbz_AF",# Dari - Afghanistan
1545 0x0465: "div_MV",# Divehi - Maldives
1546 0x0413: "nl_NL", # Dutch - The Netherlands
1547 0x0813: "nl_BE", # Dutch - Belgium
1548 0x0409: "en_US", # English - United States
1549 0x0809: "en_GB", # English - United Kingdom
1550 0x0c09: "en_AU", # English - Australia
1551 0x1009: "en_CA", # English - Canada
1552 0x1409: "en_NZ", # English - New Zealand
1553 0x1809: "en_IE", # English - Ireland
1554 0x1c09: "en_ZA", # English - South Africa
1555 0x2009: "en_JA", # English - Jamaica
1556 0x2409: "en_CB", # English - Carribbean
1557 0x2809: "en_BZ", # English - Belize
1558 0x2c09: "en_TT", # English - Trinidad
1559 0x3009: "en_ZW", # English - Zimbabwe
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001560 0x3409: "en_PH", # English - Philippines
1561 0x4009: "en_IN", # English - India
1562 0x4409: "en_MY", # English - Malaysia
1563 0x4809: "en_IN", # English - Singapore
Georg Brandlb709c2c2006-01-20 09:07:35 +00001564 0x0425: "et_EE", # Estonian
1565 0x0438: "fo_FO", # Faroese
1566 0x0464: "fil_PH",# Filipino
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001567 0x040b: "fi_FI", # Finnish
Georg Brandlb709c2c2006-01-20 09:07:35 +00001568 0x040c: "fr_FR", # French - France
1569 0x080c: "fr_BE", # French - Belgium
1570 0x0c0c: "fr_CA", # French - Canada
1571 0x100c: "fr_CH", # French - Switzerland
1572 0x140c: "fr_LU", # French - Luxembourg
1573 0x180c: "fr_MC", # French - Monaco
1574 0x0462: "fy_NL", # Frisian - Netherlands
1575 0x0456: "gl_ES", # Galician
1576 0x0437: "ka_GE", # Georgian
1577 0x0407: "de_DE", # German - Germany
1578 0x0807: "de_CH", # German - Switzerland
1579 0x0c07: "de_AT", # German - Austria
1580 0x1007: "de_LU", # German - Luxembourg
1581 0x1407: "de_LI", # German - Liechtenstein
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001582 0x0408: "el_GR", # Greek
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001583 0x046f: "kl_GL", # Greenlandic - Greenland
Georg Brandlb709c2c2006-01-20 09:07:35 +00001584 0x0447: "gu_IN", # Gujarati
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001585 0x0468: "ha_NG", # Hausa - Latin
Georg Brandlb709c2c2006-01-20 09:07:35 +00001586 0x040d: "he_IL", # Hebrew
1587 0x0439: "hi_IN", # Hindi
1588 0x040e: "hu_HU", # Hungarian
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001589 0x040f: "is_IS", # Icelandic
Georg Brandlb709c2c2006-01-20 09:07:35 +00001590 0x0421: "id_ID", # Indonesian
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001591 0x045d: "iu_CA", # Inuktitut - Syllabics
Georg Brandlb709c2c2006-01-20 09:07:35 +00001592 0x085d: "iu_CA", # Inuktitut - Latin
1593 0x083c: "ga_IE", # Irish - Ireland
Georg Brandlb709c2c2006-01-20 09:07:35 +00001594 0x0410: "it_IT", # Italian - Italy
1595 0x0810: "it_CH", # Italian - Switzerland
1596 0x0411: "ja_JP", # Japanese
1597 0x044b: "kn_IN", # Kannada - India
1598 0x043f: "kk_KZ", # Kazakh
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001599 0x0453: "kh_KH", # Khmer - Cambodia
1600 0x0486: "qut_GT",# K'iche - Guatemala
1601 0x0487: "rw_RW", # Kinyarwanda - Rwanda
Georg Brandlb709c2c2006-01-20 09:07:35 +00001602 0x0457: "kok_IN",# Konkani
1603 0x0412: "ko_KR", # Korean
1604 0x0440: "ky_KG", # Kyrgyz
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001605 0x0454: "lo_LA", # Lao - Lao PDR
Georg Brandlb709c2c2006-01-20 09:07:35 +00001606 0x0426: "lv_LV", # Latvian
1607 0x0427: "lt_LT", # Lithuanian
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001608 0x082e: "dsb_DE",# Lower Sorbian - Germany
Georg Brandlb709c2c2006-01-20 09:07:35 +00001609 0x046e: "lb_LU", # Luxembourgish
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001610 0x042f: "mk_MK", # FYROM Macedonian
Georg Brandlb709c2c2006-01-20 09:07:35 +00001611 0x043e: "ms_MY", # Malay - Malaysia
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001612 0x083e: "ms_BN", # Malay - Brunei Darussalam
Georg Brandlb709c2c2006-01-20 09:07:35 +00001613 0x044c: "ml_IN", # Malayalam - India
1614 0x043a: "mt_MT", # Maltese
1615 0x0481: "mi_NZ", # Maori
1616 0x047a: "arn_CL",# Mapudungun
1617 0x044e: "mr_IN", # Marathi
1618 0x047c: "moh_CA",# Mohawk - Canada
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001619 0x0450: "mn_MN", # Mongolian - Cyrillic
1620 0x0850: "mn_CN", # Mongolian - PRC
Georg Brandlb709c2c2006-01-20 09:07:35 +00001621 0x0461: "ne_NP", # Nepali
1622 0x0414: "nb_NO", # Norwegian - Bokmal
1623 0x0814: "nn_NO", # Norwegian - Nynorsk
1624 0x0482: "oc_FR", # Occitan - France
1625 0x0448: "or_IN", # Oriya - India
1626 0x0463: "ps_AF", # Pashto - Afghanistan
1627 0x0429: "fa_IR", # Persian
1628 0x0415: "pl_PL", # Polish
1629 0x0416: "pt_BR", # Portuguese - Brazil
1630 0x0816: "pt_PT", # Portuguese - Portugal
1631 0x0446: "pa_IN", # Punjabi
1632 0x046b: "quz_BO",# Quechua (Bolivia)
1633 0x086b: "quz_EC",# Quechua (Ecuador)
1634 0x0c6b: "quz_PE",# Quechua (Peru)
1635 0x0418: "ro_RO", # Romanian - Romania
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001636 0x0417: "rm_CH", # Romansh
Georg Brandlb709c2c2006-01-20 09:07:35 +00001637 0x0419: "ru_RU", # Russian
1638 0x243b: "smn_FI",# Sami Finland
1639 0x103b: "smj_NO",# Sami Norway
1640 0x143b: "smj_SE",# Sami Sweden
1641 0x043b: "se_NO", # Sami Northern Norway
1642 0x083b: "se_SE", # Sami Northern Sweden
1643 0x0c3b: "se_FI", # Sami Northern Finland
1644 0x203b: "sms_FI",# Sami Skolt
1645 0x183b: "sma_NO",# Sami Southern Norway
1646 0x1c3b: "sma_SE",# Sami Southern Sweden
1647 0x044f: "sa_IN", # Sanskrit
1648 0x0c1a: "sr_SP", # Serbian - Cyrillic
1649 0x1c1a: "sr_BA", # Serbian - Bosnia Cyrillic
1650 0x081a: "sr_SP", # Serbian - Latin
1651 0x181a: "sr_BA", # Serbian - Bosnia Latin
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001652 0x045b: "si_LK", # Sinhala - Sri Lanka
Georg Brandlb709c2c2006-01-20 09:07:35 +00001653 0x046c: "ns_ZA", # Northern Sotho
1654 0x0432: "tn_ZA", # Setswana - Southern Africa
1655 0x041b: "sk_SK", # Slovak
1656 0x0424: "sl_SI", # Slovenian
1657 0x040a: "es_ES", # Spanish - Spain
1658 0x080a: "es_MX", # Spanish - Mexico
1659 0x0c0a: "es_ES", # Spanish - Spain (Modern)
1660 0x100a: "es_GT", # Spanish - Guatemala
1661 0x140a: "es_CR", # Spanish - Costa Rica
1662 0x180a: "es_PA", # Spanish - Panama
1663 0x1c0a: "es_DO", # Spanish - Dominican Republic
1664 0x200a: "es_VE", # Spanish - Venezuela
1665 0x240a: "es_CO", # Spanish - Colombia
1666 0x280a: "es_PE", # Spanish - Peru
1667 0x2c0a: "es_AR", # Spanish - Argentina
1668 0x300a: "es_EC", # Spanish - Ecuador
1669 0x340a: "es_CL", # Spanish - Chile
1670 0x380a: "es_UR", # Spanish - Uruguay
1671 0x3c0a: "es_PY", # Spanish - Paraguay
1672 0x400a: "es_BO", # Spanish - Bolivia
1673 0x440a: "es_SV", # Spanish - El Salvador
1674 0x480a: "es_HN", # Spanish - Honduras
1675 0x4c0a: "es_NI", # Spanish - Nicaragua
1676 0x500a: "es_PR", # Spanish - Puerto Rico
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001677 0x540a: "es_US", # Spanish - United States
1678# 0x0430: "", # Sutu - Not supported
Georg Brandlb709c2c2006-01-20 09:07:35 +00001679 0x0441: "sw_KE", # Swahili
1680 0x041d: "sv_SE", # Swedish - Sweden
1681 0x081d: "sv_FI", # Swedish - Finland
1682 0x045a: "syr_SY",# Syriac
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001683 0x0428: "tg_TJ", # Tajik - Cyrillic
1684 0x085f: "tmz_DZ",# Tamazight - Latin
Georg Brandlb709c2c2006-01-20 09:07:35 +00001685 0x0449: "ta_IN", # Tamil
1686 0x0444: "tt_RU", # Tatar
1687 0x044a: "te_IN", # Telugu
1688 0x041e: "th_TH", # Thai
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001689 0x0851: "bo_BT", # Tibetan - Bhutan
1690 0x0451: "bo_CN", # Tibetan - PRC
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001691 0x041f: "tr_TR", # Turkish
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001692 0x0442: "tk_TM", # Turkmen - Cyrillic
1693 0x0480: "ug_CN", # Uighur - Arabic
Georg Brandlb709c2c2006-01-20 09:07:35 +00001694 0x0422: "uk_UA", # Ukrainian
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001695 0x042e: "wen_DE",# Upper Sorbian - Germany
Georg Brandlb709c2c2006-01-20 09:07:35 +00001696 0x0420: "ur_PK", # Urdu
1697 0x0820: "ur_IN", # Urdu - India
1698 0x0443: "uz_UZ", # Uzbek - Latin
1699 0x0843: "uz_UZ", # Uzbek - Cyrillic
1700 0x042a: "vi_VN", # Vietnamese
1701 0x0452: "cy_GB", # Welsh
Jeroen Ruigrok van der Wervenb87b3342009-05-08 14:11:23 +00001702 0x0488: "wo_SN", # Wolof - Senegal
1703 0x0434: "xh_ZA", # Xhosa - South Africa
1704 0x0485: "sah_RU",# Yakut - Cyrillic
1705 0x0478: "ii_CN", # Yi - PRC
1706 0x046a: "yo_NG", # Yoruba - Nigeria
1707 0x0435: "zu_ZA", # Zulu
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001708}
1709
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001710def _print_locale():
1711
1712 """ Test function.
1713 """
1714 categories = {}
1715 def _init_categories(categories=categories):
1716 for k,v in globals().items():
1717 if k[:3] == 'LC_':
1718 categories[k] = v
1719 _init_categories()
1720 del categories['LC_ALL']
1721
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001722 print 'Locale defaults as determined by getdefaultlocale():'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001723 print '-'*72
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001724 lang, enc = getdefaultlocale()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001725 print 'Language: ', lang or '(undefined)'
1726 print 'Encoding: ', enc or '(undefined)'
1727 print
1728
1729 print 'Locale settings on startup:'
1730 print '-'*72
1731 for name,category in categories.items():
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001732 print name, '...'
1733 lang, enc = getlocale(category)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001734 print ' Language: ', lang or '(undefined)'
1735 print ' Encoding: ', enc or '(undefined)'
1736 print
1737
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001738 print
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001739 print 'Locale settings after calling resetlocale():'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001740 print '-'*72
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001741 resetlocale()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001742 for name,category in categories.items():
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001743 print name, '...'
1744 lang, enc = getlocale(category)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001745 print ' Language: ', lang or '(undefined)'
1746 print ' Encoding: ', enc or '(undefined)'
1747 print
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001748
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001749 try:
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001750 setlocale(LC_ALL, "")
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001751 except:
1752 print 'NOTE:'
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001753 print 'setlocale(LC_ALL, "") does not support the default locale'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001754 print 'given in the OS environment variables.'
1755 else:
1756 print
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001757 print 'Locale settings after calling setlocale(LC_ALL, ""):'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001758 print '-'*72
1759 for name,category in categories.items():
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001760 print name, '...'
1761 lang, enc = getlocale(category)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001762 print ' Language: ', lang or '(undefined)'
1763 print ' Encoding: ', enc or '(undefined)'
1764 print
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001765
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001766###
Guido van Rossumeef1d4e1997-11-19 19:01:43 +00001767
Tim Peters1baf8292001-01-24 10:13:46 +00001768try:
1769 LC_MESSAGES
Skip Montanaro0897f0c2002-03-25 21:40:36 +00001770except NameError:
Tim Peters1baf8292001-01-24 10:13:46 +00001771 pass
1772else:
1773 __all__.append("LC_MESSAGES")
1774
Guido van Rossumeef1d4e1997-11-19 19:01:43 +00001775if __name__=='__main__':
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001776 print 'Locale aliasing:'
1777 print
1778 _print_locale()
1779 print
1780 print 'Number formatting:'
1781 print
1782 _test()