blob: f853867c7eea2f8a64e18796b102fa7e1a7eccfd [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
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +000014import sys, encodings, encodings.aliases
Antoine Pitrouba54eda2008-07-25 20:40:19 +000015import functools
Marc-André Lemburg5431bc32000-06-07 09:11:40 +000016
Fredrik Lundh6c86b992000-07-09 17:12:58 +000017# Try importing the _locale module.
18#
19# If this fails, fall back on a basic 'C' locale emulation.
Guido van Rossumeef1d4e1997-11-19 19:01:43 +000020
Tim Peters1baf8292001-01-24 10:13:46 +000021# Yuck: LC_MESSAGES is non-standard: can't tell whether it exists before
22# trying the import. So __all__ is also fiddled at the end of the file.
Georg Brandl09728b72007-05-01 06:08:15 +000023__all__ = ["getlocale", "getdefaultlocale", "getpreferredencoding", "Error",
24 "setlocale", "resetlocale", "localeconv", "strcoll", "strxfrm",
25 "str", "atof", "atoi", "format", "format_string", "currency",
26 "normalize", "LC_CTYPE", "LC_COLLATE", "LC_TIME", "LC_MONETARY",
27 "LC_NUMERIC", "LC_ALL", "CHAR_MAX"]
Skip Montanaro17ab1232001-01-24 06:27:27 +000028
Marc-André Lemburg23481142000-06-08 17:49:41 +000029try:
Fredrik Lundh6c86b992000-07-09 17:12:58 +000030
Marc-André Lemburg23481142000-06-08 17:49:41 +000031 from _locale import *
32
33except ImportError:
34
Fredrik Lundh6c86b992000-07-09 17:12:58 +000035 # Locale emulation
36
Marc-André Lemburg23481142000-06-08 17:49:41 +000037 CHAR_MAX = 127
38 LC_ALL = 6
39 LC_COLLATE = 3
40 LC_CTYPE = 0
41 LC_MESSAGES = 5
42 LC_MONETARY = 4
43 LC_NUMERIC = 1
44 LC_TIME = 2
45 Error = ValueError
46
47 def localeconv():
Fredrik Lundh6c86b992000-07-09 17:12:58 +000048 """ localeconv() -> dict.
Marc-André Lemburg23481142000-06-08 17:49:41 +000049 Returns numeric and monetary locale-specific parameters.
50 """
51 # 'C' locale default values
52 return {'grouping': [127],
53 'currency_symbol': '',
54 'n_sign_posn': 127,
Fredrik Lundh6c86b992000-07-09 17:12:58 +000055 'p_cs_precedes': 127,
56 'n_cs_precedes': 127,
57 'mon_grouping': [],
Marc-André Lemburg23481142000-06-08 17:49:41 +000058 'n_sep_by_space': 127,
59 'decimal_point': '.',
60 'negative_sign': '',
61 'positive_sign': '',
Fredrik Lundh6c86b992000-07-09 17:12:58 +000062 'p_sep_by_space': 127,
Marc-André Lemburg23481142000-06-08 17:49:41 +000063 'int_curr_symbol': '',
Fredrik Lundh6c86b992000-07-09 17:12:58 +000064 'p_sign_posn': 127,
Marc-André Lemburg23481142000-06-08 17:49:41 +000065 'thousands_sep': '',
Fredrik Lundh6c86b992000-07-09 17:12:58 +000066 'mon_thousands_sep': '',
67 'frac_digits': 127,
Marc-André Lemburg23481142000-06-08 17:49:41 +000068 'mon_decimal_point': '',
69 'int_frac_digits': 127}
Fredrik Lundh6c86b992000-07-09 17:12:58 +000070
Marc-André Lemburg23481142000-06-08 17:49:41 +000071 def setlocale(category, value=None):
Fredrik Lundh6c86b992000-07-09 17:12:58 +000072 """ setlocale(integer,string=None) -> string.
Marc-André Lemburg23481142000-06-08 17:49:41 +000073 Activates/queries locale processing.
74 """
Martin v. Löwis103d6e72003-03-30 15:42:13 +000075 if value not in (None, '', 'C'):
Fredrik Lundh6c86b992000-07-09 17:12:58 +000076 raise Error, '_locale emulation only supports "C" locale'
Marc-André Lemburg23481142000-06-08 17:49:41 +000077 return 'C'
78
79 def strcoll(a,b):
Fredrik Lundh6c86b992000-07-09 17:12:58 +000080 """ strcoll(string,string) -> int.
Marc-André Lemburg23481142000-06-08 17:49:41 +000081 Compares two strings according to the locale.
82 """
83 return cmp(a,b)
84
85 def strxfrm(s):
Fredrik Lundh6c86b992000-07-09 17:12:58 +000086 """ strxfrm(string) -> string.
Marc-André Lemburg23481142000-06-08 17:49:41 +000087 Returns a string that behaves for cmp locale-aware.
88 """
89 return s
Marc-André Lemburg5431bc32000-06-07 09:11:40 +000090
Antoine Pitrouba54eda2008-07-25 20:40:19 +000091
92_localeconv = localeconv
93
94# With this dict, you can override some items of localeconv's return value.
95# This is useful for testing purposes.
96_override_localeconv = {}
97
98@functools.wraps(_localeconv)
99def localeconv():
100 d = _localeconv()
101 if _override_localeconv:
102 d.update(_override_localeconv)
103 return d
104
105
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000106### Number formatting APIs
107
108# Author: Martin von Loewis
Georg Brandlb89316f2006-05-17 15:51:16 +0000109# improved by Georg Brandl
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000110
Antoine Pitroua099d142009-03-14 00:13:36 +0000111# Iterate over grouping intervals
112def _grouping_intervals(grouping):
113 for interval in grouping:
114 # if grouping is -1, we are done
115 if interval == CHAR_MAX:
116 return
117 # 0: re-use last group ad infinitum
118 if interval == 0:
119 while True:
120 yield last_interval
121 yield interval
122 last_interval = interval
123
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000124#perform the grouping from right to left
Georg Brandlb89316f2006-05-17 15:51:16 +0000125def _group(s, monetary=False):
126 conv = localeconv()
127 thousands_sep = conv[monetary and 'mon_thousands_sep' or 'thousands_sep']
128 grouping = conv[monetary and 'mon_grouping' or 'grouping']
129 if not grouping:
130 return (s, 0)
131 result = ""
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000132 seps = 0
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000133 if s[-1] == ' ':
Antoine Pitroua099d142009-03-14 00:13:36 +0000134 stripped = s.rstrip()
135 right_spaces = s[len(stripped):]
136 s = stripped
137 else:
138 right_spaces = ''
139 left_spaces = ''
140 groups = []
141 for interval in _grouping_intervals(grouping):
142 if not s or s[-1] not in "0123456789":
143 # only non-digit characters remain (sign, spaces)
144 left_spaces = s
145 s = ''
Guido van Rossum45e2fbc1998-03-26 21:13:24 +0000146 break
Antoine Pitroua099d142009-03-14 00:13:36 +0000147 groups.append(s[-interval:])
148 s = s[:-interval]
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000149 if s:
Antoine Pitroua099d142009-03-14 00:13:36 +0000150 groups.append(s)
151 groups.reverse()
152 return (
153 left_spaces + thousands_sep.join(groups) + right_spaces,
154 len(groups) - 1
155 )
156
157# Strip a given amount of excess padding from the given string
158def _strip_padding(s, amount):
159 lpos = 0
160 while amount and s[lpos] == ' ':
161 lpos += 1
162 amount -= 1
163 rpos = len(s) - 1
164 while amount and s[rpos] == ' ':
165 rpos -= 1
166 amount -= 1
167 return s[lpos:rpos+1]
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000168
Georg Brandlb89316f2006-05-17 15:51:16 +0000169def format(percent, value, grouping=False, monetary=False, *additional):
170 """Returns the locale-aware substitution of a %? specifier
171 (percent).
Tim Petersfd4c4192006-05-18 02:06:40 +0000172
Georg Brandlb89316f2006-05-17 15:51:16 +0000173 additional is for format strings which contain one or more
174 '*' modifiers."""
175 # this is only for one-percent-specifier strings and this should be checked
176 if percent[0] != '%':
177 raise ValueError("format() must be given exactly one %char "
178 "format specifier")
179 if additional:
180 formatted = percent % ((value,) + additional)
181 else:
182 formatted = percent % value
183 # floats and decimal ints need special action!
184 if percent[-1] in 'eEfFgG':
185 seps = 0
186 parts = formatted.split('.')
187 if grouping:
188 parts[0], seps = _group(parts[0], monetary=monetary)
189 decimal_point = localeconv()[monetary and 'mon_decimal_point'
190 or 'decimal_point']
191 formatted = decimal_point.join(parts)
Antoine Pitroua099d142009-03-14 00:13:36 +0000192 if seps:
193 formatted = _strip_padding(formatted, seps)
Georg Brandlb89316f2006-05-17 15:51:16 +0000194 elif percent[-1] in 'diu':
Antoine Pitroua099d142009-03-14 00:13:36 +0000195 seps = 0
Georg Brandlb89316f2006-05-17 15:51:16 +0000196 if grouping:
Antoine Pitroua099d142009-03-14 00:13:36 +0000197 formatted, seps = _group(formatted, monetary=monetary)
198 if seps:
199 formatted = _strip_padding(formatted, seps)
Georg Brandlb89316f2006-05-17 15:51:16 +0000200 return formatted
201
202import re, operator
203_percent_re = re.compile(r'%(?:\((?P<key>.*?)\))?'
204 r'(?P<modifiers>[-#0-9 +*.hlL]*?)[eEfFgGdiouxXcrs%]')
205
206def format_string(f, val, grouping=False):
207 """Formats a string in the same way that the % formatting would use,
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000208 but takes the current locale into account.
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000209 Grouping is applied if the third parameter is true."""
Georg Brandlb89316f2006-05-17 15:51:16 +0000210 percents = list(_percent_re.finditer(f))
211 new_f = _percent_re.sub('%s', f)
212
213 if isinstance(val, tuple):
214 new_val = list(val)
215 i = 0
216 for perc in percents:
217 starcount = perc.group('modifiers').count('*')
218 new_val[i] = format(perc.group(), new_val[i], grouping, False, *new_val[i+1:i+1+starcount])
219 del new_val[i+1:i+1+starcount]
220 i += (1 + starcount)
221 val = tuple(new_val)
222 elif operator.isMappingType(val):
223 for perc in percents:
224 key = perc.group("key")
225 val[key] = format(perc.group(), val[key], grouping)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000226 else:
Georg Brandlb89316f2006-05-17 15:51:16 +0000227 # val is a single value
228 val = format(percents[0].group(), val, grouping)
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000229
Georg Brandlb89316f2006-05-17 15:51:16 +0000230 return new_f % val
Martin v. Löwis88ad12a2001-04-13 08:09:50 +0000231
Georg Brandlb89316f2006-05-17 15:51:16 +0000232def currency(val, symbol=True, grouping=False, international=False):
233 """Formats val according to the currency settings
234 in the current locale."""
235 conv = localeconv()
236
237 # check for illegal values
238 digits = conv[international and 'int_frac_digits' or 'frac_digits']
239 if digits == 127:
240 raise ValueError("Currency formatting is not possible using "
241 "the 'C' locale.")
242
243 s = format('%%.%if' % digits, abs(val), grouping, monetary=True)
244 # '<' and '>' are markers if the sign must be inserted between symbol and value
245 s = '<' + s + '>'
246
247 if symbol:
248 smb = conv[international and 'int_curr_symbol' or 'currency_symbol']
249 precedes = conv[val<0 and 'n_cs_precedes' or 'p_cs_precedes']
250 separated = conv[val<0 and 'n_sep_by_space' or 'p_sep_by_space']
251
252 if precedes:
253 s = smb + (separated and ' ' or '') + s
254 else:
255 s = s + (separated and ' ' or '') + smb
256
257 sign_pos = conv[val<0 and 'n_sign_posn' or 'p_sign_posn']
258 sign = conv[val<0 and 'negative_sign' or 'positive_sign']
259
260 if sign_pos == 0:
261 s = '(' + s + ')'
262 elif sign_pos == 1:
263 s = sign + s
264 elif sign_pos == 2:
265 s = s + sign
266 elif sign_pos == 3:
267 s = s.replace('<', sign)
268 elif sign_pos == 4:
269 s = s.replace('>', sign)
270 else:
271 # the default if nothing specified;
272 # this should be the most fitting sign position
273 s = sign + s
274
275 return s.replace('<', '').replace('>', '')
Martin v. Löwisdb786872001-01-21 18:52:33 +0000276
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000277def str(val):
278 """Convert float to integer, taking the locale into account."""
Georg Brandlb89316f2006-05-17 15:51:16 +0000279 return format("%.12g", val)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000280
Georg Brandlb89316f2006-05-17 15:51:16 +0000281def atof(string, func=float):
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000282 "Parses a string as a float according to the locale settings."
283 #First, get rid of the grouping
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000284 ts = localeconv()['thousands_sep']
285 if ts:
Skip Montanaro249369c2004-04-10 16:39:32 +0000286 string = string.replace(ts, '')
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000287 #next, replace the decimal point with a dot
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000288 dd = localeconv()['decimal_point']
289 if dd:
Skip Montanaro249369c2004-04-10 16:39:32 +0000290 string = string.replace(dd, '.')
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000291 #finally, parse the string
Skip Montanaro249369c2004-04-10 16:39:32 +0000292 return func(string)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000293
294def atoi(str):
295 "Converts a string to an integer according to the locale settings."
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000296 return atof(str, int)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000297
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000298def _test():
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000299 setlocale(LC_ALL, "")
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000300 #do grouping
Georg Brandlb89316f2006-05-17 15:51:16 +0000301 s1 = format("%d", 123456789,1)
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000302 print s1, "is", atoi(s1)
Guido van Rossumeef1d4e1997-11-19 19:01:43 +0000303 #standard formatting
Georg Brandlb89316f2006-05-17 15:51:16 +0000304 s1 = str(3.14)
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000305 print s1, "is", atof(s1)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000306
307### Locale name aliasing engine
308
309# Author: Marc-Andre Lemburg, mal@lemburg.com
Fredrik Lundh37a09822002-10-19 20:19:10 +0000310# Various tweaks by Fredrik Lundh <fredrik@pythonware.com>
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000311
312# store away the low-level version of setlocale (it's
313# overridden below)
314_setlocale = setlocale
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000315
316def normalize(localename):
317
318 """ Returns a normalized locale code for the given locale
319 name.
320
321 The returned locale code is formatted for use with
322 setlocale().
323
324 If normalization fails, the original name is returned
325 unchanged.
326
327 If the given encoding is not known, the function defaults to
328 the default encoding for the locale code just like setlocale()
329 does.
330
331 """
332 # Normalize the locale name and extract the encoding
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000333 fullname = localename.lower()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000334 if ':' in fullname:
335 # ':' is sometimes used as encoding delimiter.
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000336 fullname = fullname.replace(':', '.')
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000337 if '.' in fullname:
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000338 langname, encoding = fullname.split('.')[:2]
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000339 fullname = langname + '.' + encoding
340 else:
341 langname = fullname
342 encoding = ''
343
344 # First lookup: fullname (possibly with encoding)
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000345 norm_encoding = encoding.replace('-', '')
346 norm_encoding = norm_encoding.replace('_', '')
347 lookup_name = langname + '.' + encoding
348 code = locale_alias.get(lookup_name, None)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000349 if code is not None:
350 return code
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000351 #print 'first lookup failed'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000352
353 # Second try: langname (without encoding)
354 code = locale_alias.get(langname, None)
355 if code is not None:
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000356 #print 'langname lookup succeeded'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000357 if '.' in code:
Eric S. Raymondbe9b5072001-02-09 10:48:30 +0000358 langname, defenc = code.split('.')
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000359 else:
360 langname = code
361 defenc = ''
362 if encoding:
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000363 # Convert the encoding to a C lib compatible encoding string
364 norm_encoding = encodings.normalize_encoding(encoding)
365 #print 'norm encoding: %r' % norm_encoding
366 norm_encoding = encodings.aliases.aliases.get(norm_encoding,
367 norm_encoding)
368 #print 'aliased encoding: %r' % norm_encoding
369 encoding = locale_encoding_alias.get(norm_encoding,
370 norm_encoding)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000371 else:
372 encoding = defenc
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000373 #print 'found encoding %r' % encoding
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000374 if encoding:
375 return langname + '.' + encoding
376 else:
377 return langname
378
379 else:
380 return localename
381
382def _parse_localename(localename):
383
384 """ Parses the locale code for localename and returns the
385 result as tuple (language code, encoding).
386
387 The localename is normalized and passed through the locale
388 alias engine. A ValueError is raised in case the locale name
389 cannot be parsed.
390
391 The language code corresponds to RFC 1766. code and encoding
392 can be None in case the values cannot be determined or are
Jeremy Hyltona05e2932000-06-28 14:48:01 +0000393 unknown to this implementation.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000394
395 """
396 code = normalize(localename)
Georg Brandlb709c2c2006-01-20 09:07:35 +0000397 if '@' in code:
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000398 # Deal with locale modifiers
399 code, modifier = code.split('@')
400 if modifier == 'euro' and '.' not in code:
401 # Assume Latin-9 for @euro locales. This is bogus,
402 # since some systems may use other encodings for these
403 # locales. Also, we ignore other modifiers.
404 return code, 'iso-8859-15'
Tim Peters230a60c2002-11-09 05:08:07 +0000405
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000406 if '.' in code:
Raymond Hettinger346e67f2005-01-01 06:10:26 +0000407 return tuple(code.split('.')[:2])
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000408 elif code == 'C':
409 return None, None
Andrew M. Kuchling1f877ef2001-08-13 14:50:44 +0000410 raise ValueError, 'unknown locale: %s' % localename
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000411
412def _build_localename(localetuple):
413
414 """ Builds a locale code from the given tuple (language code,
415 encoding).
416
417 No aliasing or normalizing takes place.
418
419 """
420 language, encoding = localetuple
421 if language is None:
422 language = 'C'
423 if encoding is None:
424 return language
425 else:
426 return language + '.' + encoding
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000427
Matthias Klosef3f231f2005-09-20 07:02:49 +0000428def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000429
430 """ Tries to determine the default locale settings and returns
431 them as tuple (language code, encoding).
432
433 According to POSIX, a program which has not called
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000434 setlocale(LC_ALL, "") runs using the portable 'C' locale.
435 Calling setlocale(LC_ALL, "") lets it use the default locale as
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000436 defined by the LANG variable. Since we don't want to interfere
Thomas Wouters7e474022000-07-16 12:04:32 +0000437 with the current locale setting we thus emulate the behavior
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000438 in the way described above.
439
440 To maintain compatibility with other platforms, not only the
441 LANG variable is tested, but a list of variables given as
442 envvars parameter. The first found to be defined will be
443 used. envvars defaults to the search path used in GNU gettext;
444 it must always contain the variable name 'LANG'.
445
446 Except for the code 'C', the language code corresponds to RFC
447 1766. code and encoding can be None in case the values cannot
448 be determined.
449
450 """
Fredrik Lundh04661322000-07-09 23:16:10 +0000451
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000452 try:
453 # check if it's supported by the _locale module
454 import _locale
455 code, encoding = _locale._getdefaultlocale()
Fredrik Lundh04661322000-07-09 23:16:10 +0000456 except (ImportError, AttributeError):
457 pass
458 else:
Fredrik Lundh663809e2000-07-10 19:32:19 +0000459 # make sure the code/encoding values are valid
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000460 if sys.platform == "win32" and code and code[:2] == "0x":
461 # map windows language identifier to language name
462 code = windows_locale.get(int(code, 0))
Fredrik Lundh663809e2000-07-10 19:32:19 +0000463 # ...add other platform-specific processing here, if
464 # necessary...
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000465 return code, encoding
Fredrik Lundh04661322000-07-09 23:16:10 +0000466
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000467 # fall back on POSIX behaviour
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000468 import os
469 lookup = os.environ.get
470 for variable in envvars:
471 localename = lookup(variable,None)
Martin v. Löwisc8ae31d2004-07-26 12:45:18 +0000472 if localename:
Matthias Klosef3f231f2005-09-20 07:02:49 +0000473 if variable == 'LANGUAGE':
474 localename = localename.split(':')[0]
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000475 break
476 else:
477 localename = 'C'
478 return _parse_localename(localename)
479
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000480
481def getlocale(category=LC_CTYPE):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000482
483 """ Returns the current setting for the given locale category as
484 tuple (language code, encoding).
485
486 category may be one of the LC_* value except LC_ALL. It
487 defaults to LC_CTYPE.
488
489 Except for the code 'C', the language code corresponds to RFC
490 1766. code and encoding can be None in case the values cannot
491 be determined.
492
493 """
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000494 localename = _setlocale(category)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000495 if category == LC_ALL and ';' in localename:
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000496 raise TypeError, 'category LC_ALL is not supported'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000497 return _parse_localename(localename)
498
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000499def setlocale(category, locale=None):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000500
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000501 """ Set the locale for the given category. The locale can be
502 a string, a locale tuple (language code, encoding), or None.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000503
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000504 Locale tuples are converted to strings the locale aliasing
505 engine. Locale strings are passed directly to the C lib.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000506
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000507 category may be given as one of the LC_* values.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000508
509 """
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000510 if locale and type(locale) is not type(""):
511 # convert to string
512 locale = normalize(_build_localename(locale))
513 return _setlocale(category, locale)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000514
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000515def resetlocale(category=LC_ALL):
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000516
517 """ Sets the locale for category to the default setting.
518
519 The default setting is determined by calling
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000520 getdefaultlocale(). category defaults to LC_ALL.
521
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000522 """
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000523 _setlocale(category, _build_localename(getdefaultlocale()))
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000524
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000525if sys.platform in ('win32', 'darwin', 'mac'):
526 # On Win32, this will return the ANSI code page
527 # On the Mac, it should return the system encoding;
528 # it might return "ascii" instead
529 def getpreferredencoding(do_setlocale = True):
530 """Return the charset that the user is likely using."""
531 import _locale
Tim Petersa326f472002-11-05 03:49:09 +0000532 return _locale._getdefaultlocale()[1]
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000533else:
534 # On Unix, if CODESET is available, use that.
535 try:
536 CODESET
537 except NameError:
538 # Fall back to parsing environment variables :-(
539 def getpreferredencoding(do_setlocale = True):
540 """Return the charset that the user is likely using,
541 by looking at environment variables."""
542 return getdefaultlocale()[1]
543 else:
544 def getpreferredencoding(do_setlocale = True):
545 """Return the charset that the user is likely using,
546 according to the system configuration."""
547 if do_setlocale:
548 oldloc = setlocale(LC_CTYPE)
549 setlocale(LC_CTYPE, "")
550 result = nl_langinfo(CODESET)
551 setlocale(LC_CTYPE, oldloc)
552 return result
553 else:
554 return nl_langinfo(CODESET)
Tim Peters230a60c2002-11-09 05:08:07 +0000555
Martin v. Löwisf0a46682002-11-03 17:20:12 +0000556
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000557### Database
558#
559# The following data was extracted from the locale.alias file which
560# comes with X11 and then hand edited removing the explicit encoding
561# definitions and adding some more aliases. The file is usually
562# available as /usr/lib/X11/locale/locale.alias.
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000563#
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000564
565#
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000566# The local_encoding_alias table maps lowercase encoding alias names
567# to C locale encoding names (case-sensitive). Note that normalize()
568# first looks up the encoding in the encodings.aliases dictionary and
569# then applies this mapping to find the correct C lib name for the
570# encoding.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000571#
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000572locale_encoding_alias = {
573
574 # Mappings for non-standard encoding names used in locale names
575 '437': 'C',
576 'c': 'C',
577 'en': 'ISO8859-1',
578 'jis': 'JIS7',
579 'jis7': 'JIS7',
580 'ajec': 'eucJP',
581
582 # Mappings from Python codec names to C lib encoding names
583 'ascii': 'ISO8859-1',
584 'latin_1': 'ISO8859-1',
585 'iso8859_1': 'ISO8859-1',
586 'iso8859_10': 'ISO8859-10',
587 'iso8859_11': 'ISO8859-11',
588 'iso8859_13': 'ISO8859-13',
589 'iso8859_14': 'ISO8859-14',
590 'iso8859_15': 'ISO8859-15',
591 'iso8859_2': 'ISO8859-2',
592 'iso8859_3': 'ISO8859-3',
593 'iso8859_4': 'ISO8859-4',
594 'iso8859_5': 'ISO8859-5',
595 'iso8859_6': 'ISO8859-6',
596 'iso8859_7': 'ISO8859-7',
597 'iso8859_8': 'ISO8859-8',
598 'iso8859_9': 'ISO8859-9',
599 'iso2022_jp': 'JIS7',
600 'shift_jis': 'SJIS',
601 'tactis': 'TACTIS',
602 'euc_jp': 'eucJP',
603 'euc_kr': 'eucKR',
Marc-André Lemburgb4cebd42004-12-13 19:56:01 +0000604 'utf_8': 'UTF8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000605 'koi8_r': 'KOI8-R',
606 'koi8_u': 'KOI8-U',
607 # XXX This list is still incomplete. If you know more
608 # mappings, please file a bug report. Thanks.
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000609}
610
Fredrik Lundh6c86b992000-07-09 17:12:58 +0000611#
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000612# The locale_alias table maps lowercase alias names to C locale names
613# (case-sensitive). Encodings are always separated from the locale
614# name using a dot ('.'); they should only be given in case the
615# language name is needed to interpret the given encoding alias
616# correctly (CJK codes often have this need).
617#
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000618# Note that the normalize() function which uses this tables
619# removes '_' and '-' characters from the encoding part of the
620# locale name before doing the lookup. This saves a lot of
621# space in the table.
622#
623# MAL 2004-12-10:
624# Updated alias mapping to most recent locale.alias file
625# from X.org distribution using makelocalealias.py.
626#
627# These are the differences compared to the old mapping (Python 2.4
628# and older):
629#
630# updated 'bg' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
631# updated 'bg_bg' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
632# updated 'bulgarian' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
633# updated 'cz' -> 'cz_CZ.ISO8859-2' to 'cs_CZ.ISO8859-2'
634# updated 'cz_cz' -> 'cz_CZ.ISO8859-2' to 'cs_CZ.ISO8859-2'
635# updated 'czech' -> 'cs_CS.ISO8859-2' to 'cs_CZ.ISO8859-2'
636# updated 'dutch' -> 'nl_BE.ISO8859-1' to 'nl_NL.ISO8859-1'
637# updated 'et' -> 'et_EE.ISO8859-4' to 'et_EE.ISO8859-15'
638# updated 'et_ee' -> 'et_EE.ISO8859-4' to 'et_EE.ISO8859-15'
639# updated 'fi' -> 'fi_FI.ISO8859-1' to 'fi_FI.ISO8859-15'
640# updated 'fi_fi' -> 'fi_FI.ISO8859-1' to 'fi_FI.ISO8859-15'
641# updated 'iw' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
642# updated 'iw_il' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
643# updated 'japanese' -> 'ja_JP.SJIS' to 'ja_JP.eucJP'
644# updated 'lt' -> 'lt_LT.ISO8859-4' to 'lt_LT.ISO8859-13'
645# updated 'lv' -> 'lv_LV.ISO8859-4' to 'lv_LV.ISO8859-13'
646# updated 'sl' -> 'sl_CS.ISO8859-2' to 'sl_SI.ISO8859-2'
647# updated 'slovene' -> 'sl_CS.ISO8859-2' to 'sl_SI.ISO8859-2'
648# updated 'th_th' -> 'th_TH.TACTIS' to 'th_TH.ISO8859-11'
649# updated 'zh_cn' -> 'zh_CN.eucCN' to 'zh_CN.gb2312'
650# updated 'zh_cn.big5' -> 'zh_TW.eucTW' to 'zh_TW.big5'
651# updated 'zh_tw' -> 'zh_TW.eucTW' to 'zh_TW.big5'
652#
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000653# MAL 2008-05-30:
654# Updated alias mapping to most recent locale.alias file
655# from X.org distribution using makelocalealias.py.
656#
657# These are the differences compared to the old mapping (Python 2.5
658# and older):
659#
660# updated 'cs_cs.iso88592' -> 'cs_CZ.ISO8859-2' to 'cs_CS.ISO8859-2'
661# updated 'serbocroatian' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
662# updated 'sh' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
663# updated 'sh_hr.iso88592' -> 'sh_HR.ISO8859-2' to 'hr_HR.ISO8859-2'
664# updated 'sh_sp' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
665# updated 'sh_yu' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
666# updated 'sp' -> 'sp_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
667# updated 'sp_yu' -> 'sp_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
668# updated 'sr' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
669# updated 'sr@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
670# updated 'sr_sp' -> 'sr_SP.ISO8859-2' to 'sr_CS.ISO8859-2'
671# updated 'sr_yu' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
672# updated 'sr_yu.cp1251@cyrillic' -> 'sr_YU.CP1251' to 'sr_CS.CP1251'
673# updated 'sr_yu.iso88592' -> 'sr_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
674# updated 'sr_yu.iso88595' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
675# updated 'sr_yu.iso88595@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
676# updated 'sr_yu.microsoftcp1251@cyrillic' -> 'sr_YU.CP1251' to 'sr_CS.CP1251'
677# updated 'sr_yu.utf8@cyrillic' -> 'sr_YU.UTF-8' to 'sr_CS.UTF-8'
678# updated 'sr_yu@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
679
Marc-André Lemburg5431bc32000-06-07 09:11:40 +0000680locale_alias = {
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000681 'a3': 'a3_AZ.KOI8-C',
682 'a3_az': 'a3_AZ.KOI8-C',
683 'a3_az.koi8c': 'a3_AZ.KOI8-C',
684 'af': 'af_ZA.ISO8859-1',
685 'af_za': 'af_ZA.ISO8859-1',
686 'af_za.iso88591': 'af_ZA.ISO8859-1',
687 'am': 'am_ET.UTF-8',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000688 'am_et': 'am_ET.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000689 'american': 'en_US.ISO8859-1',
690 'american.iso88591': 'en_US.ISO8859-1',
691 'ar': 'ar_AA.ISO8859-6',
692 'ar_aa': 'ar_AA.ISO8859-6',
693 'ar_aa.iso88596': 'ar_AA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000694 'ar_ae': 'ar_AE.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000695 'ar_ae.iso88596': 'ar_AE.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000696 'ar_bh': 'ar_BH.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000697 'ar_bh.iso88596': 'ar_BH.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000698 'ar_dz': 'ar_DZ.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000699 'ar_dz.iso88596': 'ar_DZ.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000700 'ar_eg': 'ar_EG.ISO8859-6',
701 'ar_eg.iso88596': 'ar_EG.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000702 'ar_iq': 'ar_IQ.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000703 'ar_iq.iso88596': 'ar_IQ.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000704 'ar_jo': 'ar_JO.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000705 'ar_jo.iso88596': 'ar_JO.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000706 'ar_kw': 'ar_KW.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000707 'ar_kw.iso88596': 'ar_KW.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000708 'ar_lb': 'ar_LB.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000709 'ar_lb.iso88596': 'ar_LB.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000710 'ar_ly': 'ar_LY.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000711 'ar_ly.iso88596': 'ar_LY.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000712 'ar_ma': 'ar_MA.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000713 'ar_ma.iso88596': 'ar_MA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000714 'ar_om': 'ar_OM.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000715 'ar_om.iso88596': 'ar_OM.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000716 'ar_qa': 'ar_QA.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000717 'ar_qa.iso88596': 'ar_QA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000718 'ar_sa': 'ar_SA.ISO8859-6',
719 'ar_sa.iso88596': 'ar_SA.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000720 'ar_sd': 'ar_SD.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000721 'ar_sd.iso88596': 'ar_SD.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000722 'ar_sy': 'ar_SY.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000723 'ar_sy.iso88596': 'ar_SY.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000724 'ar_tn': 'ar_TN.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000725 'ar_tn.iso88596': 'ar_TN.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000726 'ar_ye': 'ar_YE.ISO8859-6',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000727 'ar_ye.iso88596': 'ar_YE.ISO8859-6',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000728 'arabic': 'ar_AA.ISO8859-6',
729 'arabic.iso88596': 'ar_AA.ISO8859-6',
730 'az': 'az_AZ.ISO8859-9E',
731 'az_az': 'az_AZ.ISO8859-9E',
732 'az_az.iso88599e': 'az_AZ.ISO8859-9E',
733 'be': 'be_BY.CP1251',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000734 'be_by': 'be_BY.CP1251',
735 'be_by.cp1251': 'be_BY.CP1251',
736 'be_by.microsoftcp1251': 'be_BY.CP1251',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000737 'bg': 'bg_BG.CP1251',
738 'bg_bg': 'bg_BG.CP1251',
739 'bg_bg.cp1251': 'bg_BG.CP1251',
740 'bg_bg.iso88595': 'bg_BG.ISO8859-5',
741 'bg_bg.koi8r': 'bg_BG.KOI8-R',
742 'bg_bg.microsoftcp1251': 'bg_BG.CP1251',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000743 'bn_in': 'bn_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000744 'bokmal': 'nb_NO.ISO8859-1',
745 'bokm\xe5l': 'nb_NO.ISO8859-1',
746 'br': 'br_FR.ISO8859-1',
747 'br_fr': 'br_FR.ISO8859-1',
748 'br_fr.iso88591': 'br_FR.ISO8859-1',
749 'br_fr.iso885914': 'br_FR.ISO8859-14',
750 'br_fr.iso885915': 'br_FR.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000751 'br_fr.iso885915@euro': 'br_FR.ISO8859-15',
752 'br_fr.utf8@euro': 'br_FR.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000753 'br_fr@euro': 'br_FR.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000754 'bs': 'bs_BA.ISO8859-2',
755 'bs_ba': 'bs_BA.ISO8859-2',
756 'bs_ba.iso88592': 'bs_BA.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000757 'bulgarian': 'bg_BG.CP1251',
758 'c': 'C',
759 'c-french': 'fr_CA.ISO8859-1',
760 'c-french.iso88591': 'fr_CA.ISO8859-1',
761 'c.en': 'C',
762 'c.iso88591': 'en_US.ISO8859-1',
763 'c_c': 'C',
764 'c_c.c': 'C',
765 'ca': 'ca_ES.ISO8859-1',
766 'ca_es': 'ca_ES.ISO8859-1',
767 'ca_es.iso88591': 'ca_ES.ISO8859-1',
768 'ca_es.iso885915': 'ca_ES.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000769 'ca_es.iso885915@euro': 'ca_ES.ISO8859-15',
770 'ca_es.utf8@euro': 'ca_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000771 'ca_es@euro': 'ca_ES.ISO8859-15',
772 'catalan': 'ca_ES.ISO8859-1',
773 'cextend': 'en_US.ISO8859-1',
774 'cextend.en': 'en_US.ISO8859-1',
775 'chinese-s': 'zh_CN.eucCN',
776 'chinese-t': 'zh_TW.eucTW',
777 'croatian': 'hr_HR.ISO8859-2',
778 'cs': 'cs_CZ.ISO8859-2',
779 'cs_cs': 'cs_CZ.ISO8859-2',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000780 'cs_cs.iso88592': 'cs_CS.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000781 'cs_cz': 'cs_CZ.ISO8859-2',
782 'cs_cz.iso88592': 'cs_CZ.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000783 'cy': 'cy_GB.ISO8859-1',
784 'cy_gb': 'cy_GB.ISO8859-1',
785 'cy_gb.iso88591': 'cy_GB.ISO8859-1',
786 'cy_gb.iso885914': 'cy_GB.ISO8859-14',
787 'cy_gb.iso885915': 'cy_GB.ISO8859-15',
788 'cy_gb@euro': 'cy_GB.ISO8859-15',
789 'cz': 'cs_CZ.ISO8859-2',
790 'cz_cz': 'cs_CZ.ISO8859-2',
791 'czech': 'cs_CZ.ISO8859-2',
792 'da': 'da_DK.ISO8859-1',
793 'da_dk': 'da_DK.ISO8859-1',
794 'da_dk.88591': 'da_DK.ISO8859-1',
795 'da_dk.885915': 'da_DK.ISO8859-15',
796 'da_dk.iso88591': 'da_DK.ISO8859-1',
797 'da_dk.iso885915': 'da_DK.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000798 'da_dk@euro': 'da_DK.ISO8859-15',
799 'danish': 'da_DK.ISO8859-1',
800 'danish.iso88591': 'da_DK.ISO8859-1',
801 'dansk': 'da_DK.ISO8859-1',
802 'de': 'de_DE.ISO8859-1',
803 'de_at': 'de_AT.ISO8859-1',
804 'de_at.iso88591': 'de_AT.ISO8859-1',
805 'de_at.iso885915': 'de_AT.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000806 'de_at.iso885915@euro': 'de_AT.ISO8859-15',
807 'de_at.utf8@euro': 'de_AT.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000808 'de_at@euro': 'de_AT.ISO8859-15',
809 'de_be': 'de_BE.ISO8859-1',
810 'de_be.iso88591': 'de_BE.ISO8859-1',
811 'de_be.iso885915': 'de_BE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000812 'de_be.iso885915@euro': 'de_BE.ISO8859-15',
813 'de_be.utf8@euro': 'de_BE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000814 'de_be@euro': 'de_BE.ISO8859-15',
815 'de_ch': 'de_CH.ISO8859-1',
816 'de_ch.iso88591': 'de_CH.ISO8859-1',
817 'de_ch.iso885915': 'de_CH.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000818 'de_ch@euro': 'de_CH.ISO8859-15',
819 'de_de': 'de_DE.ISO8859-1',
820 'de_de.88591': 'de_DE.ISO8859-1',
821 'de_de.885915': 'de_DE.ISO8859-15',
822 'de_de.885915@euro': 'de_DE.ISO8859-15',
823 'de_de.iso88591': 'de_DE.ISO8859-1',
824 'de_de.iso885915': 'de_DE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000825 'de_de.iso885915@euro': 'de_DE.ISO8859-15',
826 'de_de.utf8@euro': 'de_DE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000827 'de_de@euro': 'de_DE.ISO8859-15',
828 'de_lu': 'de_LU.ISO8859-1',
829 'de_lu.iso88591': 'de_LU.ISO8859-1',
830 'de_lu.iso885915': 'de_LU.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000831 'de_lu.iso885915@euro': 'de_LU.ISO8859-15',
832 'de_lu.utf8@euro': 'de_LU.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000833 'de_lu@euro': 'de_LU.ISO8859-15',
834 'deutsch': 'de_DE.ISO8859-1',
835 'dutch': 'nl_NL.ISO8859-1',
836 'dutch.iso88591': 'nl_BE.ISO8859-1',
837 'ee': 'ee_EE.ISO8859-4',
838 'ee_ee': 'ee_EE.ISO8859-4',
839 'ee_ee.iso88594': 'ee_EE.ISO8859-4',
840 'eesti': 'et_EE.ISO8859-1',
841 'el': 'el_GR.ISO8859-7',
842 'el_gr': 'el_GR.ISO8859-7',
843 'el_gr.iso88597': 'el_GR.ISO8859-7',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000844 'el_gr@euro': 'el_GR.ISO8859-15',
845 'en': 'en_US.ISO8859-1',
846 'en.iso88591': 'en_US.ISO8859-1',
847 'en_au': 'en_AU.ISO8859-1',
848 'en_au.iso88591': 'en_AU.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000849 'en_be': 'en_BE.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000850 'en_be@euro': 'en_BE.ISO8859-15',
851 'en_bw': 'en_BW.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000852 'en_bw.iso88591': 'en_BW.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000853 'en_ca': 'en_CA.ISO8859-1',
854 'en_ca.iso88591': 'en_CA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000855 'en_gb': 'en_GB.ISO8859-1',
856 'en_gb.88591': 'en_GB.ISO8859-1',
857 'en_gb.iso88591': 'en_GB.ISO8859-1',
858 'en_gb.iso885915': 'en_GB.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000859 'en_gb@euro': 'en_GB.ISO8859-15',
860 'en_hk': 'en_HK.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000861 'en_hk.iso88591': 'en_HK.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000862 'en_ie': 'en_IE.ISO8859-1',
863 'en_ie.iso88591': 'en_IE.ISO8859-1',
864 'en_ie.iso885915': 'en_IE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000865 'en_ie.iso885915@euro': 'en_IE.ISO8859-15',
866 'en_ie.utf8@euro': 'en_IE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000867 'en_ie@euro': 'en_IE.ISO8859-15',
868 'en_in': 'en_IN.ISO8859-1',
869 'en_nz': 'en_NZ.ISO8859-1',
870 'en_nz.iso88591': 'en_NZ.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000871 'en_ph': 'en_PH.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000872 'en_ph.iso88591': 'en_PH.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000873 'en_sg': 'en_SG.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000874 'en_sg.iso88591': 'en_SG.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000875 'en_uk': 'en_GB.ISO8859-1',
876 'en_us': 'en_US.ISO8859-1',
877 'en_us.88591': 'en_US.ISO8859-1',
878 'en_us.885915': 'en_US.ISO8859-15',
879 'en_us.iso88591': 'en_US.ISO8859-1',
880 'en_us.iso885915': 'en_US.ISO8859-15',
881 'en_us.iso885915@euro': 'en_US.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000882 'en_us@euro': 'en_US.ISO8859-15',
883 'en_us@euro@euro': 'en_US.ISO8859-15',
884 'en_za': 'en_ZA.ISO8859-1',
885 'en_za.88591': 'en_ZA.ISO8859-1',
886 'en_za.iso88591': 'en_ZA.ISO8859-1',
887 'en_za.iso885915': 'en_ZA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000888 'en_za@euro': 'en_ZA.ISO8859-15',
889 'en_zw': 'en_ZW.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000890 'en_zw.iso88591': 'en_ZW.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000891 'eng_gb': 'en_GB.ISO8859-1',
892 'eng_gb.8859': 'en_GB.ISO8859-1',
893 'english': 'en_EN.ISO8859-1',
894 'english.iso88591': 'en_EN.ISO8859-1',
895 'english_uk': 'en_GB.ISO8859-1',
896 'english_uk.8859': 'en_GB.ISO8859-1',
897 'english_united-states': 'en_US.ISO8859-1',
898 'english_united-states.437': 'C',
899 'english_us': 'en_US.ISO8859-1',
900 'english_us.8859': 'en_US.ISO8859-1',
901 'english_us.ascii': 'en_US.ISO8859-1',
902 'eo': 'eo_XX.ISO8859-3',
903 'eo_eo': 'eo_EO.ISO8859-3',
904 'eo_eo.iso88593': 'eo_EO.ISO8859-3',
905 'eo_xx': 'eo_XX.ISO8859-3',
906 'eo_xx.iso88593': 'eo_XX.ISO8859-3',
907 'es': 'es_ES.ISO8859-1',
908 'es_ar': 'es_AR.ISO8859-1',
909 'es_ar.iso88591': 'es_AR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000910 'es_bo': 'es_BO.ISO8859-1',
911 'es_bo.iso88591': 'es_BO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000912 'es_cl': 'es_CL.ISO8859-1',
913 'es_cl.iso88591': 'es_CL.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000914 'es_co': 'es_CO.ISO8859-1',
915 'es_co.iso88591': 'es_CO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000916 'es_cr': 'es_CR.ISO8859-1',
917 'es_cr.iso88591': 'es_CR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000918 'es_do': 'es_DO.ISO8859-1',
919 'es_do.iso88591': 'es_DO.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000920 'es_ec': 'es_EC.ISO8859-1',
921 'es_ec.iso88591': 'es_EC.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000922 'es_es': 'es_ES.ISO8859-1',
923 'es_es.88591': 'es_ES.ISO8859-1',
924 'es_es.iso88591': 'es_ES.ISO8859-1',
925 'es_es.iso885915': 'es_ES.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000926 'es_es.iso885915@euro': 'es_ES.ISO8859-15',
927 'es_es.utf8@euro': 'es_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000928 'es_es@euro': 'es_ES.ISO8859-15',
929 'es_gt': 'es_GT.ISO8859-1',
930 'es_gt.iso88591': 'es_GT.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000931 'es_hn': 'es_HN.ISO8859-1',
932 'es_hn.iso88591': 'es_HN.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000933 'es_mx': 'es_MX.ISO8859-1',
934 'es_mx.iso88591': 'es_MX.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000935 'es_ni': 'es_NI.ISO8859-1',
936 'es_ni.iso88591': 'es_NI.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000937 'es_pa': 'es_PA.ISO8859-1',
938 'es_pa.iso88591': 'es_PA.ISO8859-1',
939 'es_pa.iso885915': 'es_PA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000940 'es_pa@euro': 'es_PA.ISO8859-15',
941 'es_pe': 'es_PE.ISO8859-1',
942 'es_pe.iso88591': 'es_PE.ISO8859-1',
943 'es_pe.iso885915': 'es_PE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000944 'es_pe@euro': 'es_PE.ISO8859-15',
945 'es_pr': 'es_PR.ISO8859-1',
946 'es_pr.iso88591': 'es_PR.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000947 'es_py': 'es_PY.ISO8859-1',
948 'es_py.iso88591': 'es_PY.ISO8859-1',
949 'es_py.iso885915': 'es_PY.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000950 'es_py@euro': 'es_PY.ISO8859-15',
951 'es_sv': 'es_SV.ISO8859-1',
952 'es_sv.iso88591': 'es_SV.ISO8859-1',
953 'es_sv.iso885915': 'es_SV.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000954 'es_sv@euro': 'es_SV.ISO8859-15',
955 'es_us': 'es_US.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000956 'es_us.iso88591': 'es_US.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000957 'es_uy': 'es_UY.ISO8859-1',
958 'es_uy.iso88591': 'es_UY.ISO8859-1',
959 'es_uy.iso885915': 'es_UY.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000960 'es_uy@euro': 'es_UY.ISO8859-15',
961 'es_ve': 'es_VE.ISO8859-1',
962 'es_ve.iso88591': 'es_VE.ISO8859-1',
963 'es_ve.iso885915': 'es_VE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000964 'es_ve@euro': 'es_VE.ISO8859-15',
965 'estonian': 'et_EE.ISO8859-1',
966 'et': 'et_EE.ISO8859-15',
967 'et_ee': 'et_EE.ISO8859-15',
968 'et_ee.iso88591': 'et_EE.ISO8859-1',
969 'et_ee.iso885913': 'et_EE.ISO8859-13',
970 'et_ee.iso885915': 'et_EE.ISO8859-15',
971 'et_ee.iso88594': 'et_EE.ISO8859-4',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000972 'et_ee@euro': 'et_EE.ISO8859-15',
973 'eu': 'eu_ES.ISO8859-1',
974 'eu_es': 'eu_ES.ISO8859-1',
975 'eu_es.iso88591': 'eu_ES.ISO8859-1',
976 'eu_es.iso885915': 'eu_ES.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000977 'eu_es.iso885915@euro': 'eu_ES.ISO8859-15',
978 'eu_es.utf8@euro': 'eu_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000979 'eu_es@euro': 'eu_ES.ISO8859-15',
980 'fa': 'fa_IR.UTF-8',
981 'fa_ir': 'fa_IR.UTF-8',
982 'fa_ir.isiri3342': 'fa_IR.ISIRI-3342',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000983 'fi': 'fi_FI.ISO8859-15',
984 'fi_fi': 'fi_FI.ISO8859-15',
985 'fi_fi.88591': 'fi_FI.ISO8859-1',
986 'fi_fi.iso88591': 'fi_FI.ISO8859-1',
987 'fi_fi.iso885915': 'fi_FI.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +0000988 'fi_fi.iso885915@euro': 'fi_FI.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000989 'fi_fi.utf8@euro': 'fi_FI.UTF-8',
990 'fi_fi@euro': 'fi_FI.ISO8859-15',
991 'finnish': 'fi_FI.ISO8859-1',
992 'finnish.iso88591': 'fi_FI.ISO8859-1',
993 'fo': 'fo_FO.ISO8859-1',
994 'fo_fo': 'fo_FO.ISO8859-1',
995 'fo_fo.iso88591': 'fo_FO.ISO8859-1',
996 'fo_fo.iso885915': 'fo_FO.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +0000997 'fo_fo@euro': 'fo_FO.ISO8859-15',
998 'fr': 'fr_FR.ISO8859-1',
999 'fr_be': 'fr_BE.ISO8859-1',
1000 'fr_be.88591': 'fr_BE.ISO8859-1',
1001 'fr_be.iso88591': 'fr_BE.ISO8859-1',
1002 'fr_be.iso885915': 'fr_BE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001003 'fr_be.iso885915@euro': 'fr_BE.ISO8859-15',
1004 'fr_be.utf8@euro': 'fr_BE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001005 'fr_be@euro': 'fr_BE.ISO8859-15',
1006 'fr_ca': 'fr_CA.ISO8859-1',
1007 'fr_ca.88591': 'fr_CA.ISO8859-1',
1008 'fr_ca.iso88591': 'fr_CA.ISO8859-1',
1009 'fr_ca.iso885915': 'fr_CA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001010 'fr_ca@euro': 'fr_CA.ISO8859-15',
1011 'fr_ch': 'fr_CH.ISO8859-1',
1012 'fr_ch.88591': 'fr_CH.ISO8859-1',
1013 'fr_ch.iso88591': 'fr_CH.ISO8859-1',
1014 'fr_ch.iso885915': 'fr_CH.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001015 'fr_ch@euro': 'fr_CH.ISO8859-15',
1016 'fr_fr': 'fr_FR.ISO8859-1',
1017 'fr_fr.88591': 'fr_FR.ISO8859-1',
1018 'fr_fr.iso88591': 'fr_FR.ISO8859-1',
1019 'fr_fr.iso885915': 'fr_FR.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001020 'fr_fr.iso885915@euro': 'fr_FR.ISO8859-15',
1021 'fr_fr.utf8@euro': 'fr_FR.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001022 'fr_fr@euro': 'fr_FR.ISO8859-15',
1023 'fr_lu': 'fr_LU.ISO8859-1',
1024 'fr_lu.88591': 'fr_LU.ISO8859-1',
1025 'fr_lu.iso88591': 'fr_LU.ISO8859-1',
1026 'fr_lu.iso885915': 'fr_LU.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001027 'fr_lu.iso885915@euro': 'fr_LU.ISO8859-15',
1028 'fr_lu.utf8@euro': 'fr_LU.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001029 'fr_lu@euro': 'fr_LU.ISO8859-15',
1030 'fran\xe7ais': 'fr_FR.ISO8859-1',
1031 'fre_fr': 'fr_FR.ISO8859-1',
1032 'fre_fr.8859': 'fr_FR.ISO8859-1',
1033 'french': 'fr_FR.ISO8859-1',
1034 'french.iso88591': 'fr_CH.ISO8859-1',
1035 'french_france': 'fr_FR.ISO8859-1',
1036 'french_france.8859': 'fr_FR.ISO8859-1',
1037 'ga': 'ga_IE.ISO8859-1',
1038 'ga_ie': 'ga_IE.ISO8859-1',
1039 'ga_ie.iso88591': 'ga_IE.ISO8859-1',
1040 'ga_ie.iso885914': 'ga_IE.ISO8859-14',
1041 'ga_ie.iso885915': 'ga_IE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001042 'ga_ie.iso885915@euro': 'ga_IE.ISO8859-15',
1043 'ga_ie.utf8@euro': 'ga_IE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001044 'ga_ie@euro': 'ga_IE.ISO8859-15',
1045 'galego': 'gl_ES.ISO8859-1',
1046 'galician': 'gl_ES.ISO8859-1',
1047 'gd': 'gd_GB.ISO8859-1',
1048 'gd_gb': 'gd_GB.ISO8859-1',
1049 'gd_gb.iso88591': 'gd_GB.ISO8859-1',
1050 'gd_gb.iso885914': 'gd_GB.ISO8859-14',
1051 'gd_gb.iso885915': 'gd_GB.ISO8859-15',
1052 'gd_gb@euro': 'gd_GB.ISO8859-15',
1053 'ger_de': 'de_DE.ISO8859-1',
1054 'ger_de.8859': 'de_DE.ISO8859-1',
1055 'german': 'de_DE.ISO8859-1',
1056 'german.iso88591': 'de_CH.ISO8859-1',
1057 'german_germany': 'de_DE.ISO8859-1',
1058 'german_germany.8859': 'de_DE.ISO8859-1',
1059 'gl': 'gl_ES.ISO8859-1',
1060 'gl_es': 'gl_ES.ISO8859-1',
1061 'gl_es.iso88591': 'gl_ES.ISO8859-1',
1062 'gl_es.iso885915': 'gl_ES.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001063 'gl_es.iso885915@euro': 'gl_ES.ISO8859-15',
1064 'gl_es.utf8@euro': 'gl_ES.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001065 'gl_es@euro': 'gl_ES.ISO8859-15',
1066 'greek': 'el_GR.ISO8859-7',
1067 'greek.iso88597': 'el_GR.ISO8859-7',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001068 'gu_in': 'gu_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001069 'gv': 'gv_GB.ISO8859-1',
1070 'gv_gb': 'gv_GB.ISO8859-1',
1071 'gv_gb.iso88591': 'gv_GB.ISO8859-1',
1072 'gv_gb.iso885914': 'gv_GB.ISO8859-14',
1073 'gv_gb.iso885915': 'gv_GB.ISO8859-15',
1074 'gv_gb@euro': 'gv_GB.ISO8859-15',
1075 'he': 'he_IL.ISO8859-8',
1076 'he_il': 'he_IL.ISO8859-8',
1077 'he_il.cp1255': 'he_IL.CP1255',
1078 'he_il.iso88598': 'he_IL.ISO8859-8',
1079 'he_il.microsoftcp1255': 'he_IL.CP1255',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001080 'hebrew': 'iw_IL.ISO8859-8',
1081 'hebrew.iso88598': 'iw_IL.ISO8859-8',
1082 'hi': 'hi_IN.ISCII-DEV',
1083 'hi_in': 'hi_IN.ISCII-DEV',
1084 'hi_in.isciidev': 'hi_IN.ISCII-DEV',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001085 'hr': 'hr_HR.ISO8859-2',
1086 'hr_hr': 'hr_HR.ISO8859-2',
1087 'hr_hr.iso88592': 'hr_HR.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001088 'hrvatski': 'hr_HR.ISO8859-2',
1089 'hu': 'hu_HU.ISO8859-2',
1090 'hu_hu': 'hu_HU.ISO8859-2',
1091 'hu_hu.iso88592': 'hu_HU.ISO8859-2',
1092 'hungarian': 'hu_HU.ISO8859-2',
1093 'icelandic': 'is_IS.ISO8859-1',
1094 'icelandic.iso88591': 'is_IS.ISO8859-1',
1095 'id': 'id_ID.ISO8859-1',
1096 'id_id': 'id_ID.ISO8859-1',
1097 'in': 'id_ID.ISO8859-1',
1098 'in_id': 'id_ID.ISO8859-1',
1099 'is': 'is_IS.ISO8859-1',
1100 'is_is': 'is_IS.ISO8859-1',
1101 'is_is.iso88591': 'is_IS.ISO8859-1',
1102 'is_is.iso885915': 'is_IS.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001103 'is_is@euro': 'is_IS.ISO8859-15',
1104 'iso-8859-1': 'en_US.ISO8859-1',
1105 'iso-8859-15': 'en_US.ISO8859-15',
1106 'iso8859-1': 'en_US.ISO8859-1',
1107 'iso8859-15': 'en_US.ISO8859-15',
1108 'iso_8859_1': 'en_US.ISO8859-1',
1109 'iso_8859_15': 'en_US.ISO8859-15',
1110 'it': 'it_IT.ISO8859-1',
1111 'it_ch': 'it_CH.ISO8859-1',
1112 'it_ch.iso88591': 'it_CH.ISO8859-1',
1113 'it_ch.iso885915': 'it_CH.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001114 'it_ch@euro': 'it_CH.ISO8859-15',
1115 'it_it': 'it_IT.ISO8859-1',
1116 'it_it.88591': 'it_IT.ISO8859-1',
1117 'it_it.iso88591': 'it_IT.ISO8859-1',
1118 'it_it.iso885915': 'it_IT.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001119 'it_it.iso885915@euro': 'it_IT.ISO8859-15',
1120 'it_it.utf8@euro': 'it_IT.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001121 'it_it@euro': 'it_IT.ISO8859-15',
1122 'italian': 'it_IT.ISO8859-1',
1123 'italian.iso88591': 'it_IT.ISO8859-1',
1124 'iu': 'iu_CA.NUNACOM-8',
1125 'iu_ca': 'iu_CA.NUNACOM-8',
1126 'iu_ca.nunacom8': 'iu_CA.NUNACOM-8',
1127 'iw': 'he_IL.ISO8859-8',
1128 'iw_il': 'he_IL.ISO8859-8',
1129 'iw_il.iso88598': 'he_IL.ISO8859-8',
1130 'ja': 'ja_JP.eucJP',
1131 'ja.jis': 'ja_JP.JIS7',
1132 'ja.sjis': 'ja_JP.SJIS',
1133 'ja_jp': 'ja_JP.eucJP',
1134 'ja_jp.ajec': 'ja_JP.eucJP',
1135 'ja_jp.euc': 'ja_JP.eucJP',
1136 'ja_jp.eucjp': 'ja_JP.eucJP',
1137 'ja_jp.iso-2022-jp': 'ja_JP.JIS7',
1138 'ja_jp.iso2022jp': 'ja_JP.JIS7',
1139 'ja_jp.jis': 'ja_JP.JIS7',
1140 'ja_jp.jis7': 'ja_JP.JIS7',
1141 'ja_jp.mscode': 'ja_JP.SJIS',
1142 'ja_jp.sjis': 'ja_JP.SJIS',
1143 'ja_jp.ujis': 'ja_JP.eucJP',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001144 'japan': 'ja_JP.eucJP',
1145 'japanese': 'ja_JP.eucJP',
1146 'japanese-euc': 'ja_JP.eucJP',
1147 'japanese.euc': 'ja_JP.eucJP',
1148 'japanese.sjis': 'ja_JP.SJIS',
1149 'jp_jp': 'ja_JP.eucJP',
1150 'ka': 'ka_GE.GEORGIAN-ACADEMY',
1151 'ka_ge': 'ka_GE.GEORGIAN-ACADEMY',
1152 'ka_ge.georgianacademy': 'ka_GE.GEORGIAN-ACADEMY',
1153 'ka_ge.georgianps': 'ka_GE.GEORGIAN-PS',
1154 'ka_ge.georgianrs': 'ka_GE.GEORGIAN-ACADEMY',
1155 'kl': 'kl_GL.ISO8859-1',
1156 'kl_gl': 'kl_GL.ISO8859-1',
1157 'kl_gl.iso88591': 'kl_GL.ISO8859-1',
1158 'kl_gl.iso885915': 'kl_GL.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001159 'kl_gl@euro': 'kl_GL.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001160 'km_kh': 'km_KH.UTF-8',
1161 'kn_in': 'kn_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001162 'ko': 'ko_KR.eucKR',
1163 'ko_kr': 'ko_KR.eucKR',
1164 'ko_kr.euc': 'ko_KR.eucKR',
1165 'ko_kr.euckr': 'ko_KR.eucKR',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001166 'korean': 'ko_KR.eucKR',
1167 'korean.euc': 'ko_KR.eucKR',
1168 'kw': 'kw_GB.ISO8859-1',
1169 'kw_gb': 'kw_GB.ISO8859-1',
1170 'kw_gb.iso88591': 'kw_GB.ISO8859-1',
1171 'kw_gb.iso885914': 'kw_GB.ISO8859-14',
1172 'kw_gb.iso885915': 'kw_GB.ISO8859-15',
1173 'kw_gb@euro': 'kw_GB.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001174 'ky': 'ky_KG.UTF-8',
1175 'ky_kg': 'ky_KG.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001176 'lithuanian': 'lt_LT.ISO8859-13',
1177 'lo': 'lo_LA.MULELAO-1',
1178 'lo_la': 'lo_LA.MULELAO-1',
1179 'lo_la.cp1133': 'lo_LA.IBM-CP1133',
1180 'lo_la.ibmcp1133': 'lo_LA.IBM-CP1133',
1181 'lo_la.mulelao1': 'lo_LA.MULELAO-1',
1182 'lt': 'lt_LT.ISO8859-13',
1183 'lt_lt': 'lt_LT.ISO8859-13',
1184 'lt_lt.iso885913': 'lt_LT.ISO8859-13',
1185 'lt_lt.iso88594': 'lt_LT.ISO8859-4',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001186 'lv': 'lv_LV.ISO8859-13',
1187 'lv_lv': 'lv_LV.ISO8859-13',
1188 'lv_lv.iso885913': 'lv_LV.ISO8859-13',
1189 'lv_lv.iso88594': 'lv_LV.ISO8859-4',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001190 'mi': 'mi_NZ.ISO8859-1',
1191 'mi_nz': 'mi_NZ.ISO8859-1',
1192 'mi_nz.iso88591': 'mi_NZ.ISO8859-1',
1193 'mk': 'mk_MK.ISO8859-5',
1194 'mk_mk': 'mk_MK.ISO8859-5',
1195 'mk_mk.cp1251': 'mk_MK.CP1251',
1196 'mk_mk.iso88595': 'mk_MK.ISO8859-5',
1197 'mk_mk.microsoftcp1251': 'mk_MK.CP1251',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001198 'mr_in': 'mr_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001199 'ms': 'ms_MY.ISO8859-1',
1200 'ms_my': 'ms_MY.ISO8859-1',
1201 'ms_my.iso88591': 'ms_MY.ISO8859-1',
1202 'mt': 'mt_MT.ISO8859-3',
1203 'mt_mt': 'mt_MT.ISO8859-3',
1204 'mt_mt.iso88593': 'mt_MT.ISO8859-3',
1205 'nb': 'nb_NO.ISO8859-1',
1206 'nb_no': 'nb_NO.ISO8859-1',
1207 'nb_no.88591': 'nb_NO.ISO8859-1',
1208 'nb_no.iso88591': 'nb_NO.ISO8859-1',
1209 'nb_no.iso885915': 'nb_NO.ISO8859-15',
1210 'nb_no@euro': 'nb_NO.ISO8859-15',
1211 'nl': 'nl_NL.ISO8859-1',
1212 'nl_be': 'nl_BE.ISO8859-1',
1213 'nl_be.88591': 'nl_BE.ISO8859-1',
1214 'nl_be.iso88591': 'nl_BE.ISO8859-1',
1215 'nl_be.iso885915': 'nl_BE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001216 'nl_be.iso885915@euro': 'nl_BE.ISO8859-15',
1217 'nl_be.utf8@euro': 'nl_BE.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001218 'nl_be@euro': 'nl_BE.ISO8859-15',
1219 'nl_nl': 'nl_NL.ISO8859-1',
1220 'nl_nl.88591': 'nl_NL.ISO8859-1',
1221 'nl_nl.iso88591': 'nl_NL.ISO8859-1',
1222 'nl_nl.iso885915': 'nl_NL.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001223 'nl_nl.iso885915@euro': 'nl_NL.ISO8859-15',
1224 'nl_nl.utf8@euro': 'nl_NL.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001225 'nl_nl@euro': 'nl_NL.ISO8859-15',
1226 'nn': 'nn_NO.ISO8859-1',
1227 'nn_no': 'nn_NO.ISO8859-1',
1228 'nn_no.88591': 'nn_NO.ISO8859-1',
1229 'nn_no.iso88591': 'nn_NO.ISO8859-1',
1230 'nn_no.iso885915': 'nn_NO.ISO8859-15',
1231 'nn_no@euro': 'nn_NO.ISO8859-15',
1232 'no': 'no_NO.ISO8859-1',
1233 'no@nynorsk': 'ny_NO.ISO8859-1',
1234 'no_no': 'no_NO.ISO8859-1',
1235 'no_no.88591': 'no_NO.ISO8859-1',
1236 'no_no.iso88591': 'no_NO.ISO8859-1',
1237 'no_no.iso885915': 'no_NO.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001238 'no_no@euro': 'no_NO.ISO8859-15',
1239 'norwegian': 'no_NO.ISO8859-1',
1240 'norwegian.iso88591': 'no_NO.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001241 'nr': 'nr_ZA.ISO8859-1',
1242 'nr_za': 'nr_ZA.ISO8859-1',
1243 'nr_za.iso88591': 'nr_ZA.ISO8859-1',
1244 'nso': 'nso_ZA.ISO8859-15',
1245 'nso_za': 'nso_ZA.ISO8859-15',
1246 'nso_za.iso885915': 'nso_ZA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001247 'ny': 'ny_NO.ISO8859-1',
1248 'ny_no': 'ny_NO.ISO8859-1',
1249 'ny_no.88591': 'ny_NO.ISO8859-1',
1250 'ny_no.iso88591': 'ny_NO.ISO8859-1',
1251 'ny_no.iso885915': 'ny_NO.ISO8859-15',
1252 'ny_no@euro': 'ny_NO.ISO8859-15',
1253 'nynorsk': 'nn_NO.ISO8859-1',
1254 'oc': 'oc_FR.ISO8859-1',
1255 'oc_fr': 'oc_FR.ISO8859-1',
1256 'oc_fr.iso88591': 'oc_FR.ISO8859-1',
1257 'oc_fr.iso885915': 'oc_FR.ISO8859-15',
1258 'oc_fr@euro': 'oc_FR.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001259 'pa_in': 'pa_IN.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001260 'pd': 'pd_US.ISO8859-1',
1261 'pd_de': 'pd_DE.ISO8859-1',
1262 'pd_de.iso88591': 'pd_DE.ISO8859-1',
1263 'pd_de.iso885915': 'pd_DE.ISO8859-15',
1264 'pd_de@euro': 'pd_DE.ISO8859-15',
1265 'pd_us': 'pd_US.ISO8859-1',
1266 'pd_us.iso88591': 'pd_US.ISO8859-1',
1267 'pd_us.iso885915': 'pd_US.ISO8859-15',
1268 'pd_us@euro': 'pd_US.ISO8859-15',
1269 'ph': 'ph_PH.ISO8859-1',
1270 'ph_ph': 'ph_PH.ISO8859-1',
1271 'ph_ph.iso88591': 'ph_PH.ISO8859-1',
1272 'pl': 'pl_PL.ISO8859-2',
1273 'pl_pl': 'pl_PL.ISO8859-2',
1274 'pl_pl.iso88592': 'pl_PL.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001275 'polish': 'pl_PL.ISO8859-2',
1276 'portuguese': 'pt_PT.ISO8859-1',
1277 'portuguese.iso88591': 'pt_PT.ISO8859-1',
1278 'portuguese_brazil': 'pt_BR.ISO8859-1',
1279 'portuguese_brazil.8859': 'pt_BR.ISO8859-1',
1280 'posix': 'C',
1281 'posix-utf2': 'C',
1282 'pp': 'pp_AN.ISO8859-1',
1283 'pp_an': 'pp_AN.ISO8859-1',
1284 'pp_an.iso88591': 'pp_AN.ISO8859-1',
1285 'pt': 'pt_PT.ISO8859-1',
1286 'pt_br': 'pt_BR.ISO8859-1',
1287 'pt_br.88591': 'pt_BR.ISO8859-1',
1288 'pt_br.iso88591': 'pt_BR.ISO8859-1',
1289 'pt_br.iso885915': 'pt_BR.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001290 'pt_br@euro': 'pt_BR.ISO8859-15',
1291 'pt_pt': 'pt_PT.ISO8859-1',
1292 'pt_pt.88591': 'pt_PT.ISO8859-1',
1293 'pt_pt.iso88591': 'pt_PT.ISO8859-1',
1294 'pt_pt.iso885915': 'pt_PT.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001295 'pt_pt.iso885915@euro': 'pt_PT.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001296 'pt_pt.utf8@euro': 'pt_PT.UTF-8',
1297 'pt_pt@euro': 'pt_PT.ISO8859-15',
1298 'ro': 'ro_RO.ISO8859-2',
1299 'ro_ro': 'ro_RO.ISO8859-2',
1300 'ro_ro.iso88592': 'ro_RO.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001301 'romanian': 'ro_RO.ISO8859-2',
1302 'ru': 'ru_RU.ISO8859-5',
1303 'ru_ru': 'ru_RU.ISO8859-5',
1304 'ru_ru.cp1251': 'ru_RU.CP1251',
1305 'ru_ru.iso88595': 'ru_RU.ISO8859-5',
1306 'ru_ru.koi8r': 'ru_RU.KOI8-R',
1307 'ru_ru.microsoftcp1251': 'ru_RU.CP1251',
1308 'ru_ua': 'ru_UA.KOI8-U',
1309 'ru_ua.cp1251': 'ru_UA.CP1251',
1310 'ru_ua.koi8u': 'ru_UA.KOI8-U',
1311 'ru_ua.microsoftcp1251': 'ru_UA.CP1251',
1312 'rumanian': 'ro_RO.ISO8859-2',
1313 'russian': 'ru_RU.ISO8859-5',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001314 'rw': 'rw_RW.ISO8859-1',
1315 'rw_rw': 'rw_RW.ISO8859-1',
1316 'rw_rw.iso88591': 'rw_RW.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001317 'se_no': 'se_NO.UTF-8',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001318 'serbocroatian': 'sr_CS.ISO8859-2',
1319 'sh': 'sr_CS.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001320 'sh_hr': 'sh_HR.ISO8859-2',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001321 'sh_hr.iso88592': 'hr_HR.ISO8859-2',
1322 'sh_sp': 'sr_CS.ISO8859-2',
1323 'sh_yu': 'sr_CS.ISO8859-2',
1324 'si': 'si_LK.UTF-8',
1325 'si_lk': 'si_LK.UTF-8',
1326 'sinhala': 'si_LK.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001327 'sk': 'sk_SK.ISO8859-2',
1328 'sk_sk': 'sk_SK.ISO8859-2',
1329 'sk_sk.iso88592': 'sk_SK.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001330 'sl': 'sl_SI.ISO8859-2',
1331 'sl_cs': 'sl_CS.ISO8859-2',
1332 'sl_si': 'sl_SI.ISO8859-2',
1333 'sl_si.iso88592': 'sl_SI.ISO8859-2',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001334 'slovak': 'sk_SK.ISO8859-2',
1335 'slovene': 'sl_SI.ISO8859-2',
1336 'slovenian': 'sl_SI.ISO8859-2',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001337 'sp': 'sr_CS.ISO8859-5',
1338 'sp_yu': 'sr_CS.ISO8859-5',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001339 'spanish': 'es_ES.ISO8859-1',
1340 'spanish.iso88591': 'es_ES.ISO8859-1',
1341 'spanish_spain': 'es_ES.ISO8859-1',
1342 'spanish_spain.8859': 'es_ES.ISO8859-1',
1343 'sq': 'sq_AL.ISO8859-2',
1344 'sq_al': 'sq_AL.ISO8859-2',
1345 'sq_al.iso88592': 'sq_AL.ISO8859-2',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001346 'sr': 'sr_CS.ISO8859-5',
1347 'sr@cyrillic': 'sr_CS.ISO8859-5',
1348 'sr@latn': 'sr_CS.ISO8859-2',
1349 'sr_cs.iso88592': 'sr_CS.ISO8859-2',
1350 'sr_cs.iso88592@latn': 'sr_CS.ISO8859-2',
1351 'sr_cs.iso88595': 'sr_CS.ISO8859-5',
1352 'sr_cs.utf8@latn': 'sr_CS.UTF-8',
1353 'sr_cs@latn': 'sr_CS.ISO8859-2',
1354 'sr_sp': 'sr_CS.ISO8859-2',
1355 'sr_yu': 'sr_CS.ISO8859-5',
1356 'sr_yu.cp1251@cyrillic': 'sr_CS.CP1251',
1357 'sr_yu.iso88592': 'sr_CS.ISO8859-2',
1358 'sr_yu.iso88595': 'sr_CS.ISO8859-5',
1359 'sr_yu.iso88595@cyrillic': 'sr_CS.ISO8859-5',
1360 'sr_yu.microsoftcp1251@cyrillic': 'sr_CS.CP1251',
1361 'sr_yu.utf8@cyrillic': 'sr_CS.UTF-8',
1362 'sr_yu@cyrillic': 'sr_CS.ISO8859-5',
1363 'ss': 'ss_ZA.ISO8859-1',
1364 'ss_za': 'ss_ZA.ISO8859-1',
1365 'ss_za.iso88591': 'ss_ZA.ISO8859-1',
1366 'st': 'st_ZA.ISO8859-1',
1367 'st_za': 'st_ZA.ISO8859-1',
1368 'st_za.iso88591': 'st_ZA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001369 'sv': 'sv_SE.ISO8859-1',
1370 'sv_fi': 'sv_FI.ISO8859-1',
1371 'sv_fi.iso88591': 'sv_FI.ISO8859-1',
1372 'sv_fi.iso885915': 'sv_FI.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001373 'sv_fi.iso885915@euro': 'sv_FI.ISO8859-15',
1374 'sv_fi.utf8@euro': 'sv_FI.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001375 'sv_fi@euro': 'sv_FI.ISO8859-15',
1376 'sv_se': 'sv_SE.ISO8859-1',
1377 'sv_se.88591': 'sv_SE.ISO8859-1',
1378 'sv_se.iso88591': 'sv_SE.ISO8859-1',
1379 'sv_se.iso885915': 'sv_SE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001380 'sv_se@euro': 'sv_SE.ISO8859-15',
1381 'swedish': 'sv_SE.ISO8859-1',
1382 'swedish.iso88591': 'sv_SE.ISO8859-1',
1383 'ta': 'ta_IN.TSCII-0',
1384 'ta_in': 'ta_IN.TSCII-0',
1385 'ta_in.tscii': 'ta_IN.TSCII-0',
1386 'ta_in.tscii0': 'ta_IN.TSCII-0',
1387 'tg': 'tg_TJ.KOI8-C',
1388 'tg_tj': 'tg_TJ.KOI8-C',
1389 'tg_tj.koi8c': 'tg_TJ.KOI8-C',
1390 'th': 'th_TH.ISO8859-11',
1391 'th_th': 'th_TH.ISO8859-11',
1392 'th_th.iso885911': 'th_TH.ISO8859-11',
1393 'th_th.tactis': 'th_TH.TIS620',
1394 'th_th.tis620': 'th_TH.TIS620',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001395 'thai': 'th_TH.ISO8859-11',
1396 'tl': 'tl_PH.ISO8859-1',
1397 'tl_ph': 'tl_PH.ISO8859-1',
1398 'tl_ph.iso88591': 'tl_PH.ISO8859-1',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001399 'tn': 'tn_ZA.ISO8859-15',
1400 'tn_za': 'tn_ZA.ISO8859-15',
1401 'tn_za.iso885915': 'tn_ZA.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001402 'tr': 'tr_TR.ISO8859-9',
1403 'tr_tr': 'tr_TR.ISO8859-9',
1404 'tr_tr.iso88599': 'tr_TR.ISO8859-9',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001405 'ts': 'ts_ZA.ISO8859-1',
1406 'ts_za': 'ts_ZA.ISO8859-1',
1407 'ts_za.iso88591': 'ts_ZA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001408 'tt': 'tt_RU.TATAR-CYR',
1409 'tt_ru': 'tt_RU.TATAR-CYR',
1410 'tt_ru.koi8c': 'tt_RU.KOI8-C',
1411 'tt_ru.tatarcyr': 'tt_RU.TATAR-CYR',
1412 'turkish': 'tr_TR.ISO8859-9',
1413 'turkish.iso88599': 'tr_TR.ISO8859-9',
1414 'uk': 'uk_UA.KOI8-U',
1415 'uk_ua': 'uk_UA.KOI8-U',
1416 'uk_ua.cp1251': 'uk_UA.CP1251',
1417 'uk_ua.iso88595': 'uk_UA.ISO8859-5',
1418 'uk_ua.koi8u': 'uk_UA.KOI8-U',
1419 'uk_ua.microsoftcp1251': 'uk_UA.CP1251',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001420 'univ': 'en_US.utf',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001421 'universal': 'en_US.utf',
1422 'universal.utf8@ucs4': 'en_US.UTF-8',
1423 'ur': 'ur_PK.CP1256',
1424 'ur_pk': 'ur_PK.CP1256',
1425 'ur_pk.cp1256': 'ur_PK.CP1256',
1426 'ur_pk.microsoftcp1256': 'ur_PK.CP1256',
1427 'uz': 'uz_UZ.UTF-8',
1428 'uz_uz': 'uz_UZ.UTF-8',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001429 'uz_uz.iso88591': 'uz_UZ.ISO8859-1',
1430 'uz_uz.utf8@cyrillic': 'uz_UZ.UTF-8',
1431 'uz_uz@cyrillic': 'uz_UZ.UTF-8',
1432 've': 've_ZA.UTF-8',
1433 've_za': 've_ZA.UTF-8',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001434 'vi': 'vi_VN.TCVN',
1435 'vi_vn': 'vi_VN.TCVN',
1436 'vi_vn.tcvn': 'vi_VN.TCVN',
1437 'vi_vn.tcvn5712': 'vi_VN.TCVN',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001438 'vi_vn.viscii': 'vi_VN.VISCII',
1439 'vi_vn.viscii111': 'vi_VN.VISCII',
1440 'wa': 'wa_BE.ISO8859-1',
1441 'wa_be': 'wa_BE.ISO8859-1',
1442 'wa_be.iso88591': 'wa_BE.ISO8859-1',
1443 'wa_be.iso885915': 'wa_BE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001444 'wa_be.iso885915@euro': 'wa_BE.ISO8859-15',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001445 'wa_be@euro': 'wa_BE.ISO8859-15',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001446 'xh': 'xh_ZA.ISO8859-1',
1447 'xh_za': 'xh_ZA.ISO8859-1',
1448 'xh_za.iso88591': 'xh_ZA.ISO8859-1',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001449 'yi': 'yi_US.CP1255',
1450 'yi_us': 'yi_US.CP1255',
1451 'yi_us.cp1255': 'yi_US.CP1255',
1452 'yi_us.microsoftcp1255': 'yi_US.CP1255',
1453 'zh': 'zh_CN.eucCN',
1454 'zh_cn': 'zh_CN.gb2312',
1455 'zh_cn.big5': 'zh_TW.big5',
1456 'zh_cn.euc': 'zh_CN.eucCN',
1457 'zh_cn.gb18030': 'zh_CN.gb18030',
1458 'zh_cn.gb2312': 'zh_CN.gb2312',
1459 'zh_cn.gbk': 'zh_CN.gbk',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001460 'zh_hk': 'zh_HK.big5hkscs',
1461 'zh_hk.big5': 'zh_HK.big5',
1462 'zh_hk.big5hkscs': 'zh_HK.big5hkscs',
Marc-André Lemburgbb4f1bd2004-12-10 21:58:14 +00001463 'zh_tw': 'zh_TW.big5',
1464 'zh_tw.big5': 'zh_TW.big5',
1465 'zh_tw.euc': 'zh_TW.eucTW',
Marc-André Lemburgadff65b2008-05-30 20:52:18 +00001466 'zh_tw.euctw': 'zh_TW.eucTW',
1467 'zu': 'zu_ZA.ISO8859-1',
1468 'zu_za': 'zu_ZA.ISO8859-1',
1469 'zu_za.iso88591': 'zu_ZA.ISO8859-1',
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001470}
1471
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001472#
Georg Brandlb709c2c2006-01-20 09:07:35 +00001473# This maps Windows language identifiers to locale strings.
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001474#
Tim Peters777f1082006-01-20 20:03:24 +00001475# This list has been updated from
Georg Brandlb709c2c2006-01-20 09:07:35 +00001476# http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nls_238z.asp
1477# to include every locale up to Windows XP.
Fredrik Lundh37a09822002-10-19 20:19:10 +00001478#
Georg Brandl5035c1c2006-01-20 13:38:26 +00001479# NOTE: this mapping is incomplete. If your language is missing, please
1480# submit a bug report to Python bug manager, which you can find via:
1481# http://www.python.org/dev/
1482# Make sure you include the missing language identifier and the suggested
1483# locale code.
1484#
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001485
1486windows_locale = {
Georg Brandlb709c2c2006-01-20 09:07:35 +00001487 0x0436: "af_ZA", # Afrikaans
1488 0x041c: "sq_AL", # Albanian
1489 0x0401: "ar_SA", # Arabic - Saudi Arabia
1490 0x0801: "ar_IQ", # Arabic - Iraq
1491 0x0c01: "ar_EG", # Arabic - Egypt
1492 0x1001: "ar_LY", # Arabic - Libya
1493 0x1401: "ar_DZ", # Arabic - Algeria
1494 0x1801: "ar_MA", # Arabic - Morocco
1495 0x1c01: "ar_TN", # Arabic - Tunisia
1496 0x2001: "ar_OM", # Arabic - Oman
1497 0x2401: "ar_YE", # Arabic - Yemen
1498 0x2801: "ar_SY", # Arabic - Syria
1499 0x2c01: "ar_JO", # Arabic - Jordan
1500 0x3001: "ar_LB", # Arabic - Lebanon
1501 0x3401: "ar_KW", # Arabic - Kuwait
1502 0x3801: "ar_AE", # Arabic - United Arab Emirates
1503 0x3c01: "ar_BH", # Arabic - Bahrain
1504 0x4001: "ar_QA", # Arabic - Qatar
1505 0x042b: "hy_AM", # Armenian
1506 0x042c: "az_AZ", # Azeri Latin
1507 0x082c: "az_AZ", # Azeri - Cyrillic
1508 0x042d: "eu_ES", # Basque
1509 0x0423: "be_BY", # Belarusian
1510 0x0445: "bn_IN", # Begali
1511 0x201a: "bs_BA", # Bosnian
1512 0x141a: "bs_BA", # Bosnian - Cyrillic
1513 0x047e: "br_FR", # Breton - France
1514 0x0402: "bg_BG", # Bulgarian
1515 0x0403: "ca_ES", # Catalan
1516 0x0004: "zh_CHS",# Chinese - Simplified
1517 0x0404: "zh_TW", # Chinese - Taiwan
1518 0x0804: "zh_CN", # Chinese - PRC
1519 0x0c04: "zh_HK", # Chinese - Hong Kong S.A.R.
1520 0x1004: "zh_SG", # Chinese - Singapore
1521 0x1404: "zh_MO", # Chinese - Macao S.A.R.
1522 0x7c04: "zh_CHT",# Chinese - Traditional
1523 0x041a: "hr_HR", # Croatian
1524 0x101a: "hr_BA", # Croatian - Bosnia
1525 0x0405: "cs_CZ", # Czech
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001526 0x0406: "da_DK", # Danish
Georg Brandlb709c2c2006-01-20 09:07:35 +00001527 0x048c: "gbz_AF",# Dari - Afghanistan
1528 0x0465: "div_MV",# Divehi - Maldives
1529 0x0413: "nl_NL", # Dutch - The Netherlands
1530 0x0813: "nl_BE", # Dutch - Belgium
1531 0x0409: "en_US", # English - United States
1532 0x0809: "en_GB", # English - United Kingdom
1533 0x0c09: "en_AU", # English - Australia
1534 0x1009: "en_CA", # English - Canada
1535 0x1409: "en_NZ", # English - New Zealand
1536 0x1809: "en_IE", # English - Ireland
1537 0x1c09: "en_ZA", # English - South Africa
1538 0x2009: "en_JA", # English - Jamaica
1539 0x2409: "en_CB", # English - Carribbean
1540 0x2809: "en_BZ", # English - Belize
1541 0x2c09: "en_TT", # English - Trinidad
1542 0x3009: "en_ZW", # English - Zimbabwe
1543 0x3409: "en_PH", # English - Phillippines
1544 0x0425: "et_EE", # Estonian
1545 0x0438: "fo_FO", # Faroese
1546 0x0464: "fil_PH",# Filipino
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001547 0x040b: "fi_FI", # Finnish
Georg Brandlb709c2c2006-01-20 09:07:35 +00001548 0x040c: "fr_FR", # French - France
1549 0x080c: "fr_BE", # French - Belgium
1550 0x0c0c: "fr_CA", # French - Canada
1551 0x100c: "fr_CH", # French - Switzerland
1552 0x140c: "fr_LU", # French - Luxembourg
1553 0x180c: "fr_MC", # French - Monaco
1554 0x0462: "fy_NL", # Frisian - Netherlands
1555 0x0456: "gl_ES", # Galician
1556 0x0437: "ka_GE", # Georgian
1557 0x0407: "de_DE", # German - Germany
1558 0x0807: "de_CH", # German - Switzerland
1559 0x0c07: "de_AT", # German - Austria
1560 0x1007: "de_LU", # German - Luxembourg
1561 0x1407: "de_LI", # German - Liechtenstein
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001562 0x0408: "el_GR", # Greek
Georg Brandlb709c2c2006-01-20 09:07:35 +00001563 0x0447: "gu_IN", # Gujarati
1564 0x040d: "he_IL", # Hebrew
1565 0x0439: "hi_IN", # Hindi
1566 0x040e: "hu_HU", # Hungarian
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001567 0x040f: "is_IS", # Icelandic
Georg Brandlb709c2c2006-01-20 09:07:35 +00001568 0x0421: "id_ID", # Indonesian
1569 0x045d: "iu_CA", # Inuktitut
1570 0x085d: "iu_CA", # Inuktitut - Latin
1571 0x083c: "ga_IE", # Irish - Ireland
1572 0x0434: "xh_ZA", # Xhosa - South Africa
1573 0x0435: "zu_ZA", # Zulu
1574 0x0410: "it_IT", # Italian - Italy
1575 0x0810: "it_CH", # Italian - Switzerland
1576 0x0411: "ja_JP", # Japanese
1577 0x044b: "kn_IN", # Kannada - India
1578 0x043f: "kk_KZ", # Kazakh
1579 0x0457: "kok_IN",# Konkani
1580 0x0412: "ko_KR", # Korean
1581 0x0440: "ky_KG", # Kyrgyz
1582 0x0426: "lv_LV", # Latvian
1583 0x0427: "lt_LT", # Lithuanian
1584 0x046e: "lb_LU", # Luxembourgish
1585 0x042f: "mk_MK", # FYRO Macedonian
1586 0x043e: "ms_MY", # Malay - Malaysia
1587 0x083e: "ms_BN", # Malay - Brunei
1588 0x044c: "ml_IN", # Malayalam - India
1589 0x043a: "mt_MT", # Maltese
1590 0x0481: "mi_NZ", # Maori
1591 0x047a: "arn_CL",# Mapudungun
1592 0x044e: "mr_IN", # Marathi
1593 0x047c: "moh_CA",# Mohawk - Canada
1594 0x0450: "mn_MN", # Mongolian
1595 0x0461: "ne_NP", # Nepali
1596 0x0414: "nb_NO", # Norwegian - Bokmal
1597 0x0814: "nn_NO", # Norwegian - Nynorsk
1598 0x0482: "oc_FR", # Occitan - France
1599 0x0448: "or_IN", # Oriya - India
1600 0x0463: "ps_AF", # Pashto - Afghanistan
1601 0x0429: "fa_IR", # Persian
1602 0x0415: "pl_PL", # Polish
1603 0x0416: "pt_BR", # Portuguese - Brazil
1604 0x0816: "pt_PT", # Portuguese - Portugal
1605 0x0446: "pa_IN", # Punjabi
1606 0x046b: "quz_BO",# Quechua (Bolivia)
1607 0x086b: "quz_EC",# Quechua (Ecuador)
1608 0x0c6b: "quz_PE",# Quechua (Peru)
1609 0x0418: "ro_RO", # Romanian - Romania
1610 0x0417: "rm_CH", # Raeto-Romanese
1611 0x0419: "ru_RU", # Russian
1612 0x243b: "smn_FI",# Sami Finland
1613 0x103b: "smj_NO",# Sami Norway
1614 0x143b: "smj_SE",# Sami Sweden
1615 0x043b: "se_NO", # Sami Northern Norway
1616 0x083b: "se_SE", # Sami Northern Sweden
1617 0x0c3b: "se_FI", # Sami Northern Finland
1618 0x203b: "sms_FI",# Sami Skolt
1619 0x183b: "sma_NO",# Sami Southern Norway
1620 0x1c3b: "sma_SE",# Sami Southern Sweden
1621 0x044f: "sa_IN", # Sanskrit
1622 0x0c1a: "sr_SP", # Serbian - Cyrillic
1623 0x1c1a: "sr_BA", # Serbian - Bosnia Cyrillic
1624 0x081a: "sr_SP", # Serbian - Latin
1625 0x181a: "sr_BA", # Serbian - Bosnia Latin
1626 0x046c: "ns_ZA", # Northern Sotho
1627 0x0432: "tn_ZA", # Setswana - Southern Africa
1628 0x041b: "sk_SK", # Slovak
1629 0x0424: "sl_SI", # Slovenian
1630 0x040a: "es_ES", # Spanish - Spain
1631 0x080a: "es_MX", # Spanish - Mexico
1632 0x0c0a: "es_ES", # Spanish - Spain (Modern)
1633 0x100a: "es_GT", # Spanish - Guatemala
1634 0x140a: "es_CR", # Spanish - Costa Rica
1635 0x180a: "es_PA", # Spanish - Panama
1636 0x1c0a: "es_DO", # Spanish - Dominican Republic
1637 0x200a: "es_VE", # Spanish - Venezuela
1638 0x240a: "es_CO", # Spanish - Colombia
1639 0x280a: "es_PE", # Spanish - Peru
1640 0x2c0a: "es_AR", # Spanish - Argentina
1641 0x300a: "es_EC", # Spanish - Ecuador
1642 0x340a: "es_CL", # Spanish - Chile
1643 0x380a: "es_UR", # Spanish - Uruguay
1644 0x3c0a: "es_PY", # Spanish - Paraguay
1645 0x400a: "es_BO", # Spanish - Bolivia
1646 0x440a: "es_SV", # Spanish - El Salvador
1647 0x480a: "es_HN", # Spanish - Honduras
1648 0x4c0a: "es_NI", # Spanish - Nicaragua
1649 0x500a: "es_PR", # Spanish - Puerto Rico
1650 0x0441: "sw_KE", # Swahili
1651 0x041d: "sv_SE", # Swedish - Sweden
1652 0x081d: "sv_FI", # Swedish - Finland
1653 0x045a: "syr_SY",# Syriac
1654 0x0449: "ta_IN", # Tamil
1655 0x0444: "tt_RU", # Tatar
1656 0x044a: "te_IN", # Telugu
1657 0x041e: "th_TH", # Thai
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001658 0x041f: "tr_TR", # Turkish
Georg Brandlb709c2c2006-01-20 09:07:35 +00001659 0x0422: "uk_UA", # Ukrainian
1660 0x0420: "ur_PK", # Urdu
1661 0x0820: "ur_IN", # Urdu - India
1662 0x0443: "uz_UZ", # Uzbek - Latin
1663 0x0843: "uz_UZ", # Uzbek - Cyrillic
1664 0x042a: "vi_VN", # Vietnamese
1665 0x0452: "cy_GB", # Welsh
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001666}
1667
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001668def _print_locale():
1669
1670 """ Test function.
1671 """
1672 categories = {}
1673 def _init_categories(categories=categories):
1674 for k,v in globals().items():
1675 if k[:3] == 'LC_':
1676 categories[k] = v
1677 _init_categories()
1678 del categories['LC_ALL']
1679
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001680 print 'Locale defaults as determined by getdefaultlocale():'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001681 print '-'*72
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001682 lang, enc = getdefaultlocale()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001683 print 'Language: ', lang or '(undefined)'
1684 print 'Encoding: ', enc or '(undefined)'
1685 print
1686
1687 print 'Locale settings on startup:'
1688 print '-'*72
1689 for name,category in categories.items():
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001690 print name, '...'
1691 lang, enc = getlocale(category)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001692 print ' Language: ', lang or '(undefined)'
1693 print ' Encoding: ', enc or '(undefined)'
1694 print
1695
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001696 print
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001697 print 'Locale settings after calling resetlocale():'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001698 print '-'*72
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001699 resetlocale()
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001700 for name,category in categories.items():
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001701 print name, '...'
1702 lang, enc = getlocale(category)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001703 print ' Language: ', lang or '(undefined)'
1704 print ' Encoding: ', enc or '(undefined)'
1705 print
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001706
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001707 try:
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001708 setlocale(LC_ALL, "")
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001709 except:
1710 print 'NOTE:'
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001711 print 'setlocale(LC_ALL, "") does not support the default locale'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001712 print 'given in the OS environment variables.'
1713 else:
1714 print
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001715 print 'Locale settings after calling setlocale(LC_ALL, ""):'
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001716 print '-'*72
1717 for name,category in categories.items():
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001718 print name, '...'
1719 lang, enc = getlocale(category)
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001720 print ' Language: ', lang or '(undefined)'
1721 print ' Encoding: ', enc or '(undefined)'
1722 print
Fredrik Lundh6c86b992000-07-09 17:12:58 +00001723
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001724###
Guido van Rossumeef1d4e1997-11-19 19:01:43 +00001725
Tim Peters1baf8292001-01-24 10:13:46 +00001726try:
1727 LC_MESSAGES
Skip Montanaro0897f0c2002-03-25 21:40:36 +00001728except NameError:
Tim Peters1baf8292001-01-24 10:13:46 +00001729 pass
1730else:
1731 __all__.append("LC_MESSAGES")
1732
Guido van Rossumeef1d4e1997-11-19 19:01:43 +00001733if __name__=='__main__':
Marc-André Lemburg5431bc32000-06-07 09:11:40 +00001734 print 'Locale aliasing:'
1735 print
1736 _print_locale()
1737 print
1738 print 'Number formatting:'
1739 print
1740 _test()