Fixed bug in time-to-midnight calculation.
[python.git] / Lib / locale.py
blobe4d6023105e0525fe6538f2ffdae70541a6c97d4
1 """ Locale support.
3 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.
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.
12 """
14 import sys, encodings, encodings.aliases
16 # Try importing the _locale module.
18 # If this fails, fall back on a basic 'C' locale emulation.
20 # Yuck: LC_MESSAGES is non-standard: can't tell whether it exists before
21 # trying the import. So __all__ is also fiddled at the end of the file.
22 __all__ = ["setlocale","Error","localeconv","strcoll","strxfrm",
23 "format","str","atof","atoi","LC_CTYPE","LC_COLLATE",
24 "LC_TIME","LC_MONETARY","LC_NUMERIC", "LC_ALL","CHAR_MAX"]
26 try:
28 from _locale import *
30 except ImportError:
32 # Locale emulation
34 CHAR_MAX = 127
35 LC_ALL = 6
36 LC_COLLATE = 3
37 LC_CTYPE = 0
38 LC_MESSAGES = 5
39 LC_MONETARY = 4
40 LC_NUMERIC = 1
41 LC_TIME = 2
42 Error = ValueError
44 def localeconv():
45 """ localeconv() -> dict.
46 Returns numeric and monetary locale-specific parameters.
47 """
48 # 'C' locale default values
49 return {'grouping': [127],
50 'currency_symbol': '',
51 'n_sign_posn': 127,
52 'p_cs_precedes': 127,
53 'n_cs_precedes': 127,
54 'mon_grouping': [],
55 'n_sep_by_space': 127,
56 'decimal_point': '.',
57 'negative_sign': '',
58 'positive_sign': '',
59 'p_sep_by_space': 127,
60 'int_curr_symbol': '',
61 'p_sign_posn': 127,
62 'thousands_sep': '',
63 'mon_thousands_sep': '',
64 'frac_digits': 127,
65 'mon_decimal_point': '',
66 'int_frac_digits': 127}
68 def setlocale(category, value=None):
69 """ setlocale(integer,string=None) -> string.
70 Activates/queries locale processing.
71 """
72 if value not in (None, '', 'C'):
73 raise Error, '_locale emulation only supports "C" locale'
74 return 'C'
76 def strcoll(a,b):
77 """ strcoll(string,string) -> int.
78 Compares two strings according to the locale.
79 """
80 return cmp(a,b)
82 def strxfrm(s):
83 """ strxfrm(string) -> string.
84 Returns a string that behaves for cmp locale-aware.
85 """
86 return s
88 ### Number formatting APIs
90 # Author: Martin von Loewis
92 #perform the grouping from right to left
93 def _group(s):
94 conv=localeconv()
95 grouping=conv['grouping']
96 if not grouping:return (s, 0)
97 result=""
98 seps = 0
99 spaces = ""
100 if s[-1] == ' ':
101 sp = s.find(' ')
102 spaces = s[sp:]
103 s = s[:sp]
104 while s and grouping:
105 # if grouping is -1, we are done
106 if grouping[0]==CHAR_MAX:
107 break
108 # 0: re-use last group ad infinitum
109 elif grouping[0]!=0:
110 #process last group
111 group=grouping[0]
112 grouping=grouping[1:]
113 if result:
114 result=s[-group:]+conv['thousands_sep']+result
115 seps += 1
116 else:
117 result=s[-group:]
118 s=s[:-group]
119 if s and s[-1] not in "0123456789":
120 # the leading string is only spaces and signs
121 return s+result+spaces,seps
122 if not result:
123 return s+spaces,seps
124 if s:
125 result=s+conv['thousands_sep']+result
126 seps += 1
127 return result+spaces,seps
129 def format(f,val,grouping=0):
130 """Formats a value in the same way that the % formatting would use,
131 but takes the current locale into account.
132 Grouping is applied if the third parameter is true."""
133 result = f % val
134 fields = result.split(".")
135 seps = 0
136 if grouping:
137 fields[0],seps=_group(fields[0])
138 if len(fields)==2:
139 result = fields[0]+localeconv()['decimal_point']+fields[1]
140 elif len(fields)==1:
141 result = fields[0]
142 else:
143 raise Error, "Too many decimal points in result string"
145 while seps:
146 # If the number was formatted for a specific width, then it
147 # might have been filled with spaces to the left or right. If
148 # so, kill as much spaces as there where separators.
149 # Leading zeroes as fillers are not yet dealt with, as it is
150 # not clear how they should interact with grouping.
151 sp = result.find(" ")
152 if sp==-1:break
153 result = result[:sp]+result[sp+1:]
154 seps -= 1
156 return result
158 def str(val):
159 """Convert float to integer, taking the locale into account."""
160 return format("%.12g",val)
162 def atof(string,func=float):
163 "Parses a string as a float according to the locale settings."
164 #First, get rid of the grouping
165 ts = localeconv()['thousands_sep']
166 if ts:
167 string = string.replace(ts, '')
168 #next, replace the decimal point with a dot
169 dd = localeconv()['decimal_point']
170 if dd:
171 string = string.replace(dd, '.')
172 #finally, parse the string
173 return func(string)
175 def atoi(str):
176 "Converts a string to an integer according to the locale settings."
177 return atof(str, int)
179 def _test():
180 setlocale(LC_ALL, "")
181 #do grouping
182 s1=format("%d", 123456789,1)
183 print s1, "is", atoi(s1)
184 #standard formatting
185 s1=str(3.14)
186 print s1, "is", atof(s1)
188 ### Locale name aliasing engine
190 # Author: Marc-Andre Lemburg, mal@lemburg.com
191 # Various tweaks by Fredrik Lundh <fredrik@pythonware.com>
193 # store away the low-level version of setlocale (it's
194 # overridden below)
195 _setlocale = setlocale
197 def normalize(localename):
199 """ Returns a normalized locale code for the given locale
200 name.
202 The returned locale code is formatted for use with
203 setlocale().
205 If normalization fails, the original name is returned
206 unchanged.
208 If the given encoding is not known, the function defaults to
209 the default encoding for the locale code just like setlocale()
210 does.
213 # Normalize the locale name and extract the encoding
214 fullname = localename.lower()
215 if ':' in fullname:
216 # ':' is sometimes used as encoding delimiter.
217 fullname = fullname.replace(':', '.')
218 if '.' in fullname:
219 langname, encoding = fullname.split('.')[:2]
220 fullname = langname + '.' + encoding
221 else:
222 langname = fullname
223 encoding = ''
225 # First lookup: fullname (possibly with encoding)
226 norm_encoding = encoding.replace('-', '')
227 norm_encoding = norm_encoding.replace('_', '')
228 lookup_name = langname + '.' + encoding
229 code = locale_alias.get(lookup_name, None)
230 if code is not None:
231 return code
232 #print 'first lookup failed'
234 # Second try: langname (without encoding)
235 code = locale_alias.get(langname, None)
236 if code is not None:
237 #print 'langname lookup succeeded'
238 if '.' in code:
239 langname, defenc = code.split('.')
240 else:
241 langname = code
242 defenc = ''
243 if encoding:
244 # Convert the encoding to a C lib compatible encoding string
245 norm_encoding = encodings.normalize_encoding(encoding)
246 #print 'norm encoding: %r' % norm_encoding
247 norm_encoding = encodings.aliases.aliases.get(norm_encoding,
248 norm_encoding)
249 #print 'aliased encoding: %r' % norm_encoding
250 encoding = locale_encoding_alias.get(norm_encoding,
251 norm_encoding)
252 else:
253 encoding = defenc
254 #print 'found encoding %r' % encoding
255 if encoding:
256 return langname + '.' + encoding
257 else:
258 return langname
260 else:
261 return localename
263 def _parse_localename(localename):
265 """ Parses the locale code for localename and returns the
266 result as tuple (language code, encoding).
268 The localename is normalized and passed through the locale
269 alias engine. A ValueError is raised in case the locale name
270 cannot be parsed.
272 The language code corresponds to RFC 1766. code and encoding
273 can be None in case the values cannot be determined or are
274 unknown to this implementation.
277 code = normalize(localename)
278 if '@' in localename:
279 # Deal with locale modifiers
280 code, modifier = code.split('@')
281 if modifier == 'euro' and '.' not in code:
282 # Assume Latin-9 for @euro locales. This is bogus,
283 # since some systems may use other encodings for these
284 # locales. Also, we ignore other modifiers.
285 return code, 'iso-8859-15'
287 if '.' in code:
288 return tuple(code.split('.')[:2])
289 elif code == 'C':
290 return None, None
291 raise ValueError, 'unknown locale: %s' % localename
293 def _build_localename(localetuple):
295 """ Builds a locale code from the given tuple (language code,
296 encoding).
298 No aliasing or normalizing takes place.
301 language, encoding = localetuple
302 if language is None:
303 language = 'C'
304 if encoding is None:
305 return language
306 else:
307 return language + '.' + encoding
309 def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
311 """ Tries to determine the default locale settings and returns
312 them as tuple (language code, encoding).
314 According to POSIX, a program which has not called
315 setlocale(LC_ALL, "") runs using the portable 'C' locale.
316 Calling setlocale(LC_ALL, "") lets it use the default locale as
317 defined by the LANG variable. Since we don't want to interfere
318 with the current locale setting we thus emulate the behavior
319 in the way described above.
321 To maintain compatibility with other platforms, not only the
322 LANG variable is tested, but a list of variables given as
323 envvars parameter. The first found to be defined will be
324 used. envvars defaults to the search path used in GNU gettext;
325 it must always contain the variable name 'LANG'.
327 Except for the code 'C', the language code corresponds to RFC
328 1766. code and encoding can be None in case the values cannot
329 be determined.
333 try:
334 # check if it's supported by the _locale module
335 import _locale
336 code, encoding = _locale._getdefaultlocale()
337 except (ImportError, AttributeError):
338 pass
339 else:
340 # make sure the code/encoding values are valid
341 if sys.platform == "win32" and code and code[:2] == "0x":
342 # map windows language identifier to language name
343 code = windows_locale.get(int(code, 0))
344 # ...add other platform-specific processing here, if
345 # necessary...
346 return code, encoding
348 # fall back on POSIX behaviour
349 import os
350 lookup = os.environ.get
351 for variable in envvars:
352 localename = lookup(variable,None)
353 if localename:
354 if variable == 'LANGUAGE':
355 localename = localename.split(':')[0]
356 break
357 else:
358 localename = 'C'
359 return _parse_localename(localename)
362 def getlocale(category=LC_CTYPE):
364 """ Returns the current setting for the given locale category as
365 tuple (language code, encoding).
367 category may be one of the LC_* value except LC_ALL. It
368 defaults to LC_CTYPE.
370 Except for the code 'C', the language code corresponds to RFC
371 1766. code and encoding can be None in case the values cannot
372 be determined.
375 localename = _setlocale(category)
376 if category == LC_ALL and ';' in localename:
377 raise TypeError, 'category LC_ALL is not supported'
378 return _parse_localename(localename)
380 def setlocale(category, locale=None):
382 """ Set the locale for the given category. The locale can be
383 a string, a locale tuple (language code, encoding), or None.
385 Locale tuples are converted to strings the locale aliasing
386 engine. Locale strings are passed directly to the C lib.
388 category may be given as one of the LC_* values.
391 if locale and type(locale) is not type(""):
392 # convert to string
393 locale = normalize(_build_localename(locale))
394 return _setlocale(category, locale)
396 def resetlocale(category=LC_ALL):
398 """ Sets the locale for category to the default setting.
400 The default setting is determined by calling
401 getdefaultlocale(). category defaults to LC_ALL.
404 _setlocale(category, _build_localename(getdefaultlocale()))
406 if sys.platform in ('win32', 'darwin', 'mac'):
407 # On Win32, this will return the ANSI code page
408 # On the Mac, it should return the system encoding;
409 # it might return "ascii" instead
410 def getpreferredencoding(do_setlocale = True):
411 """Return the charset that the user is likely using."""
412 import _locale
413 return _locale._getdefaultlocale()[1]
414 else:
415 # On Unix, if CODESET is available, use that.
416 try:
417 CODESET
418 except NameError:
419 # Fall back to parsing environment variables :-(
420 def getpreferredencoding(do_setlocale = True):
421 """Return the charset that the user is likely using,
422 by looking at environment variables."""
423 return getdefaultlocale()[1]
424 else:
425 def getpreferredencoding(do_setlocale = True):
426 """Return the charset that the user is likely using,
427 according to the system configuration."""
428 if do_setlocale:
429 oldloc = setlocale(LC_CTYPE)
430 setlocale(LC_CTYPE, "")
431 result = nl_langinfo(CODESET)
432 setlocale(LC_CTYPE, oldloc)
433 return result
434 else:
435 return nl_langinfo(CODESET)
438 ### Database
440 # The following data was extracted from the locale.alias file which
441 # comes with X11 and then hand edited removing the explicit encoding
442 # definitions and adding some more aliases. The file is usually
443 # available as /usr/lib/X11/locale/locale.alias.
447 # The local_encoding_alias table maps lowercase encoding alias names
448 # to C locale encoding names (case-sensitive). Note that normalize()
449 # first looks up the encoding in the encodings.aliases dictionary and
450 # then applies this mapping to find the correct C lib name for the
451 # encoding.
453 locale_encoding_alias = {
455 # Mappings for non-standard encoding names used in locale names
456 '437': 'C',
457 'c': 'C',
458 'en': 'ISO8859-1',
459 'jis': 'JIS7',
460 'jis7': 'JIS7',
461 'ajec': 'eucJP',
463 # Mappings from Python codec names to C lib encoding names
464 'ascii': 'ISO8859-1',
465 'latin_1': 'ISO8859-1',
466 'iso8859_1': 'ISO8859-1',
467 'iso8859_10': 'ISO8859-10',
468 'iso8859_11': 'ISO8859-11',
469 'iso8859_13': 'ISO8859-13',
470 'iso8859_14': 'ISO8859-14',
471 'iso8859_15': 'ISO8859-15',
472 'iso8859_2': 'ISO8859-2',
473 'iso8859_3': 'ISO8859-3',
474 'iso8859_4': 'ISO8859-4',
475 'iso8859_5': 'ISO8859-5',
476 'iso8859_6': 'ISO8859-6',
477 'iso8859_7': 'ISO8859-7',
478 'iso8859_8': 'ISO8859-8',
479 'iso8859_9': 'ISO8859-9',
480 'iso2022_jp': 'JIS7',
481 'shift_jis': 'SJIS',
482 'tactis': 'TACTIS',
483 'euc_jp': 'eucJP',
484 'euc_kr': 'eucKR',
485 'utf_8': 'UTF8',
486 'koi8_r': 'KOI8-R',
487 'koi8_u': 'KOI8-U',
488 # XXX This list is still incomplete. If you know more
489 # mappings, please file a bug report. Thanks.
493 # The locale_alias table maps lowercase alias names to C locale names
494 # (case-sensitive). Encodings are always separated from the locale
495 # name using a dot ('.'); they should only be given in case the
496 # language name is needed to interpret the given encoding alias
497 # correctly (CJK codes often have this need).
499 # Note that the normalize() function which uses this tables
500 # removes '_' and '-' characters from the encoding part of the
501 # locale name before doing the lookup. This saves a lot of
502 # space in the table.
504 # MAL 2004-12-10:
505 # Updated alias mapping to most recent locale.alias file
506 # from X.org distribution using makelocalealias.py.
508 # These are the differences compared to the old mapping (Python 2.4
509 # and older):
511 # updated 'bg' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
512 # updated 'bg_bg' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
513 # updated 'bulgarian' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
514 # updated 'cz' -> 'cz_CZ.ISO8859-2' to 'cs_CZ.ISO8859-2'
515 # updated 'cz_cz' -> 'cz_CZ.ISO8859-2' to 'cs_CZ.ISO8859-2'
516 # updated 'czech' -> 'cs_CS.ISO8859-2' to 'cs_CZ.ISO8859-2'
517 # updated 'dutch' -> 'nl_BE.ISO8859-1' to 'nl_NL.ISO8859-1'
518 # updated 'et' -> 'et_EE.ISO8859-4' to 'et_EE.ISO8859-15'
519 # updated 'et_ee' -> 'et_EE.ISO8859-4' to 'et_EE.ISO8859-15'
520 # updated 'fi' -> 'fi_FI.ISO8859-1' to 'fi_FI.ISO8859-15'
521 # updated 'fi_fi' -> 'fi_FI.ISO8859-1' to 'fi_FI.ISO8859-15'
522 # updated 'iw' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
523 # updated 'iw_il' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
524 # updated 'japanese' -> 'ja_JP.SJIS' to 'ja_JP.eucJP'
525 # updated 'lt' -> 'lt_LT.ISO8859-4' to 'lt_LT.ISO8859-13'
526 # updated 'lv' -> 'lv_LV.ISO8859-4' to 'lv_LV.ISO8859-13'
527 # updated 'sl' -> 'sl_CS.ISO8859-2' to 'sl_SI.ISO8859-2'
528 # updated 'slovene' -> 'sl_CS.ISO8859-2' to 'sl_SI.ISO8859-2'
529 # updated 'th_th' -> 'th_TH.TACTIS' to 'th_TH.ISO8859-11'
530 # updated 'zh_cn' -> 'zh_CN.eucCN' to 'zh_CN.gb2312'
531 # updated 'zh_cn.big5' -> 'zh_TW.eucTW' to 'zh_TW.big5'
532 # updated 'zh_tw' -> 'zh_TW.eucTW' to 'zh_TW.big5'
534 locale_alias = {
535 'a3': 'a3_AZ.KOI8-C',
536 'a3_az': 'a3_AZ.KOI8-C',
537 'a3_az.koi8c': 'a3_AZ.KOI8-C',
538 'af': 'af_ZA.ISO8859-1',
539 'af_za': 'af_ZA.ISO8859-1',
540 'af_za.iso88591': 'af_ZA.ISO8859-1',
541 'am': 'am_ET.UTF-8',
542 'american': 'en_US.ISO8859-1',
543 'american.iso88591': 'en_US.ISO8859-1',
544 'ar': 'ar_AA.ISO8859-6',
545 'ar_aa': 'ar_AA.ISO8859-6',
546 'ar_aa.iso88596': 'ar_AA.ISO8859-6',
547 'ar_ae': 'ar_AE.ISO8859-6',
548 'ar_bh': 'ar_BH.ISO8859-6',
549 'ar_dz': 'ar_DZ.ISO8859-6',
550 'ar_eg': 'ar_EG.ISO8859-6',
551 'ar_eg.iso88596': 'ar_EG.ISO8859-6',
552 'ar_iq': 'ar_IQ.ISO8859-6',
553 'ar_jo': 'ar_JO.ISO8859-6',
554 'ar_kw': 'ar_KW.ISO8859-6',
555 'ar_lb': 'ar_LB.ISO8859-6',
556 'ar_ly': 'ar_LY.ISO8859-6',
557 'ar_ma': 'ar_MA.ISO8859-6',
558 'ar_om': 'ar_OM.ISO8859-6',
559 'ar_qa': 'ar_QA.ISO8859-6',
560 'ar_sa': 'ar_SA.ISO8859-6',
561 'ar_sa.iso88596': 'ar_SA.ISO8859-6',
562 'ar_sd': 'ar_SD.ISO8859-6',
563 'ar_sy': 'ar_SY.ISO8859-6',
564 'ar_tn': 'ar_TN.ISO8859-6',
565 'ar_ye': 'ar_YE.ISO8859-6',
566 'arabic': 'ar_AA.ISO8859-6',
567 'arabic.iso88596': 'ar_AA.ISO8859-6',
568 'az': 'az_AZ.ISO8859-9E',
569 'az_az': 'az_AZ.ISO8859-9E',
570 'az_az.iso88599e': 'az_AZ.ISO8859-9E',
571 'be': 'be_BY.CP1251',
572 'be_by': 'be_BY.CP1251',
573 'be_by.cp1251': 'be_BY.CP1251',
574 'be_by.microsoftcp1251': 'be_BY.CP1251',
575 'bg': 'bg_BG.CP1251',
576 'bg_bg': 'bg_BG.CP1251',
577 'bg_bg.cp1251': 'bg_BG.CP1251',
578 'bg_bg.iso88595': 'bg_BG.ISO8859-5',
579 'bg_bg.koi8r': 'bg_BG.KOI8-R',
580 'bg_bg.microsoftcp1251': 'bg_BG.CP1251',
581 'bokmal': 'nb_NO.ISO8859-1',
582 'bokm\xe5l': 'nb_NO.ISO8859-1',
583 'br': 'br_FR.ISO8859-1',
584 'br_fr': 'br_FR.ISO8859-1',
585 'br_fr.iso88591': 'br_FR.ISO8859-1',
586 'br_fr.iso885914': 'br_FR.ISO8859-14',
587 'br_fr.iso885915': 'br_FR.ISO8859-15',
588 'br_fr@euro': 'br_FR.ISO8859-15',
589 'bulgarian': 'bg_BG.CP1251',
590 'c': 'C',
591 'c-french': 'fr_CA.ISO8859-1',
592 'c-french.iso88591': 'fr_CA.ISO8859-1',
593 'c.en': 'C',
594 'c.iso88591': 'en_US.ISO8859-1',
595 'c_c': 'C',
596 'c_c.c': 'C',
597 'ca': 'ca_ES.ISO8859-1',
598 'ca_es': 'ca_ES.ISO8859-1',
599 'ca_es.iso88591': 'ca_ES.ISO8859-1',
600 'ca_es.iso885915': 'ca_ES.ISO8859-15',
601 'ca_es@euro': 'ca_ES.ISO8859-15',
602 'catalan': 'ca_ES.ISO8859-1',
603 'cextend': 'en_US.ISO8859-1',
604 'cextend.en': 'en_US.ISO8859-1',
605 'chinese-s': 'zh_CN.eucCN',
606 'chinese-t': 'zh_TW.eucTW',
607 'croatian': 'hr_HR.ISO8859-2',
608 'cs': 'cs_CZ.ISO8859-2',
609 'cs_cs': 'cs_CZ.ISO8859-2',
610 'cs_cs.iso88592': 'cs_CZ.ISO8859-2',
611 'cs_cz': 'cs_CZ.ISO8859-2',
612 'cs_cz.iso88592': 'cs_CZ.ISO8859-2',
613 'cy': 'cy_GB.ISO8859-1',
614 'cy_gb': 'cy_GB.ISO8859-1',
615 'cy_gb.iso88591': 'cy_GB.ISO8859-1',
616 'cy_gb.iso885914': 'cy_GB.ISO8859-14',
617 'cy_gb.iso885915': 'cy_GB.ISO8859-15',
618 'cy_gb@euro': 'cy_GB.ISO8859-15',
619 'cz': 'cs_CZ.ISO8859-2',
620 'cz_cz': 'cs_CZ.ISO8859-2',
621 'czech': 'cs_CZ.ISO8859-2',
622 'da': 'da_DK.ISO8859-1',
623 'da_dk': 'da_DK.ISO8859-1',
624 'da_dk.88591': 'da_DK.ISO8859-1',
625 'da_dk.885915': 'da_DK.ISO8859-15',
626 'da_dk.iso88591': 'da_DK.ISO8859-1',
627 'da_dk.iso885915': 'da_DK.ISO8859-15',
628 'da_dk@euro': 'da_DK.ISO8859-15',
629 'danish': 'da_DK.ISO8859-1',
630 'danish.iso88591': 'da_DK.ISO8859-1',
631 'dansk': 'da_DK.ISO8859-1',
632 'de': 'de_DE.ISO8859-1',
633 'de_at': 'de_AT.ISO8859-1',
634 'de_at.iso88591': 'de_AT.ISO8859-1',
635 'de_at.iso885915': 'de_AT.ISO8859-15',
636 'de_at@euro': 'de_AT.ISO8859-15',
637 'de_be': 'de_BE.ISO8859-1',
638 'de_be.iso88591': 'de_BE.ISO8859-1',
639 'de_be.iso885915': 'de_BE.ISO8859-15',
640 'de_be@euro': 'de_BE.ISO8859-15',
641 'de_ch': 'de_CH.ISO8859-1',
642 'de_ch.iso88591': 'de_CH.ISO8859-1',
643 'de_ch.iso885915': 'de_CH.ISO8859-15',
644 'de_ch@euro': 'de_CH.ISO8859-15',
645 'de_de': 'de_DE.ISO8859-1',
646 'de_de.88591': 'de_DE.ISO8859-1',
647 'de_de.885915': 'de_DE.ISO8859-15',
648 'de_de.885915@euro': 'de_DE.ISO8859-15',
649 'de_de.iso88591': 'de_DE.ISO8859-1',
650 'de_de.iso885915': 'de_DE.ISO8859-15',
651 'de_de@euro': 'de_DE.ISO8859-15',
652 'de_lu': 'de_LU.ISO8859-1',
653 'de_lu.iso88591': 'de_LU.ISO8859-1',
654 'de_lu.iso885915': 'de_LU.ISO8859-15',
655 'de_lu@euro': 'de_LU.ISO8859-15',
656 'deutsch': 'de_DE.ISO8859-1',
657 'dutch': 'nl_NL.ISO8859-1',
658 'dutch.iso88591': 'nl_BE.ISO8859-1',
659 'ee': 'ee_EE.ISO8859-4',
660 'ee_ee': 'ee_EE.ISO8859-4',
661 'ee_ee.iso88594': 'ee_EE.ISO8859-4',
662 'eesti': 'et_EE.ISO8859-1',
663 'el': 'el_GR.ISO8859-7',
664 'el_gr': 'el_GR.ISO8859-7',
665 'el_gr.iso88597': 'el_GR.ISO8859-7',
666 'el_gr@euro': 'el_GR.ISO8859-15',
667 'en': 'en_US.ISO8859-1',
668 'en.iso88591': 'en_US.ISO8859-1',
669 'en_au': 'en_AU.ISO8859-1',
670 'en_au.iso88591': 'en_AU.ISO8859-1',
671 'en_be': 'en_BE.ISO8859-1',
672 'en_be@euro': 'en_BE.ISO8859-15',
673 'en_bw': 'en_BW.ISO8859-1',
674 'en_ca': 'en_CA.ISO8859-1',
675 'en_ca.iso88591': 'en_CA.ISO8859-1',
676 'en_gb': 'en_GB.ISO8859-1',
677 'en_gb.88591': 'en_GB.ISO8859-1',
678 'en_gb.iso88591': 'en_GB.ISO8859-1',
679 'en_gb.iso885915': 'en_GB.ISO8859-15',
680 'en_gb@euro': 'en_GB.ISO8859-15',
681 'en_hk': 'en_HK.ISO8859-1',
682 'en_ie': 'en_IE.ISO8859-1',
683 'en_ie.iso88591': 'en_IE.ISO8859-1',
684 'en_ie.iso885915': 'en_IE.ISO8859-15',
685 'en_ie@euro': 'en_IE.ISO8859-15',
686 'en_in': 'en_IN.ISO8859-1',
687 'en_nz': 'en_NZ.ISO8859-1',
688 'en_nz.iso88591': 'en_NZ.ISO8859-1',
689 'en_ph': 'en_PH.ISO8859-1',
690 'en_sg': 'en_SG.ISO8859-1',
691 'en_uk': 'en_GB.ISO8859-1',
692 'en_us': 'en_US.ISO8859-1',
693 'en_us.88591': 'en_US.ISO8859-1',
694 'en_us.885915': 'en_US.ISO8859-15',
695 'en_us.iso88591': 'en_US.ISO8859-1',
696 'en_us.iso885915': 'en_US.ISO8859-15',
697 'en_us.iso885915@euro': 'en_US.ISO8859-15',
698 'en_us@euro': 'en_US.ISO8859-15',
699 'en_us@euro@euro': 'en_US.ISO8859-15',
700 'en_za': 'en_ZA.ISO8859-1',
701 'en_za.88591': 'en_ZA.ISO8859-1',
702 'en_za.iso88591': 'en_ZA.ISO8859-1',
703 'en_za.iso885915': 'en_ZA.ISO8859-15',
704 'en_za@euro': 'en_ZA.ISO8859-15',
705 'en_zw': 'en_ZW.ISO8859-1',
706 'eng_gb': 'en_GB.ISO8859-1',
707 'eng_gb.8859': 'en_GB.ISO8859-1',
708 'english': 'en_EN.ISO8859-1',
709 'english.iso88591': 'en_EN.ISO8859-1',
710 'english_uk': 'en_GB.ISO8859-1',
711 'english_uk.8859': 'en_GB.ISO8859-1',
712 'english_united-states': 'en_US.ISO8859-1',
713 'english_united-states.437': 'C',
714 'english_us': 'en_US.ISO8859-1',
715 'english_us.8859': 'en_US.ISO8859-1',
716 'english_us.ascii': 'en_US.ISO8859-1',
717 'eo': 'eo_XX.ISO8859-3',
718 'eo_eo': 'eo_EO.ISO8859-3',
719 'eo_eo.iso88593': 'eo_EO.ISO8859-3',
720 'eo_xx': 'eo_XX.ISO8859-3',
721 'eo_xx.iso88593': 'eo_XX.ISO8859-3',
722 'es': 'es_ES.ISO8859-1',
723 'es_ar': 'es_AR.ISO8859-1',
724 'es_ar.iso88591': 'es_AR.ISO8859-1',
725 'es_bo': 'es_BO.ISO8859-1',
726 'es_bo.iso88591': 'es_BO.ISO8859-1',
727 'es_cl': 'es_CL.ISO8859-1',
728 'es_cl.iso88591': 'es_CL.ISO8859-1',
729 'es_co': 'es_CO.ISO8859-1',
730 'es_co.iso88591': 'es_CO.ISO8859-1',
731 'es_cr': 'es_CR.ISO8859-1',
732 'es_cr.iso88591': 'es_CR.ISO8859-1',
733 'es_do': 'es_DO.ISO8859-1',
734 'es_do.iso88591': 'es_DO.ISO8859-1',
735 'es_ec': 'es_EC.ISO8859-1',
736 'es_ec.iso88591': 'es_EC.ISO8859-1',
737 'es_es': 'es_ES.ISO8859-1',
738 'es_es.88591': 'es_ES.ISO8859-1',
739 'es_es.iso88591': 'es_ES.ISO8859-1',
740 'es_es.iso885915': 'es_ES.ISO8859-15',
741 'es_es@euro': 'es_ES.ISO8859-15',
742 'es_gt': 'es_GT.ISO8859-1',
743 'es_gt.iso88591': 'es_GT.ISO8859-1',
744 'es_hn': 'es_HN.ISO8859-1',
745 'es_hn.iso88591': 'es_HN.ISO8859-1',
746 'es_mx': 'es_MX.ISO8859-1',
747 'es_mx.iso88591': 'es_MX.ISO8859-1',
748 'es_ni': 'es_NI.ISO8859-1',
749 'es_ni.iso88591': 'es_NI.ISO8859-1',
750 'es_pa': 'es_PA.ISO8859-1',
751 'es_pa.iso88591': 'es_PA.ISO8859-1',
752 'es_pa.iso885915': 'es_PA.ISO8859-15',
753 'es_pa@euro': 'es_PA.ISO8859-15',
754 'es_pe': 'es_PE.ISO8859-1',
755 'es_pe.iso88591': 'es_PE.ISO8859-1',
756 'es_pe.iso885915': 'es_PE.ISO8859-15',
757 'es_pe@euro': 'es_PE.ISO8859-15',
758 'es_pr': 'es_PR.ISO8859-1',
759 'es_pr.iso88591': 'es_PR.ISO8859-1',
760 'es_py': 'es_PY.ISO8859-1',
761 'es_py.iso88591': 'es_PY.ISO8859-1',
762 'es_py.iso885915': 'es_PY.ISO8859-15',
763 'es_py@euro': 'es_PY.ISO8859-15',
764 'es_sv': 'es_SV.ISO8859-1',
765 'es_sv.iso88591': 'es_SV.ISO8859-1',
766 'es_sv.iso885915': 'es_SV.ISO8859-15',
767 'es_sv@euro': 'es_SV.ISO8859-15',
768 'es_us': 'es_US.ISO8859-1',
769 'es_uy': 'es_UY.ISO8859-1',
770 'es_uy.iso88591': 'es_UY.ISO8859-1',
771 'es_uy.iso885915': 'es_UY.ISO8859-15',
772 'es_uy@euro': 'es_UY.ISO8859-15',
773 'es_ve': 'es_VE.ISO8859-1',
774 'es_ve.iso88591': 'es_VE.ISO8859-1',
775 'es_ve.iso885915': 'es_VE.ISO8859-15',
776 'es_ve@euro': 'es_VE.ISO8859-15',
777 'estonian': 'et_EE.ISO8859-1',
778 'et': 'et_EE.ISO8859-15',
779 'et_ee': 'et_EE.ISO8859-15',
780 'et_ee.iso88591': 'et_EE.ISO8859-1',
781 'et_ee.iso885913': 'et_EE.ISO8859-13',
782 'et_ee.iso885915': 'et_EE.ISO8859-15',
783 'et_ee.iso88594': 'et_EE.ISO8859-4',
784 'et_ee@euro': 'et_EE.ISO8859-15',
785 'eu': 'eu_ES.ISO8859-1',
786 'eu_es': 'eu_ES.ISO8859-1',
787 'eu_es.iso88591': 'eu_ES.ISO8859-1',
788 'eu_es.iso885915': 'eu_ES.ISO8859-15',
789 'eu_es@euro': 'eu_ES.ISO8859-15',
790 'fa': 'fa_IR.UTF-8',
791 'fa_ir': 'fa_IR.UTF-8',
792 'fa_ir.isiri3342': 'fa_IR.ISIRI-3342',
793 'fi': 'fi_FI.ISO8859-15',
794 'fi_fi': 'fi_FI.ISO8859-15',
795 'fi_fi.88591': 'fi_FI.ISO8859-1',
796 'fi_fi.iso88591': 'fi_FI.ISO8859-1',
797 'fi_fi.iso885915': 'fi_FI.ISO8859-15',
798 'fi_fi.utf8@euro': 'fi_FI.UTF-8',
799 'fi_fi@euro': 'fi_FI.ISO8859-15',
800 'finnish': 'fi_FI.ISO8859-1',
801 'finnish.iso88591': 'fi_FI.ISO8859-1',
802 'fo': 'fo_FO.ISO8859-1',
803 'fo_fo': 'fo_FO.ISO8859-1',
804 'fo_fo.iso88591': 'fo_FO.ISO8859-1',
805 'fo_fo.iso885915': 'fo_FO.ISO8859-15',
806 'fo_fo@euro': 'fo_FO.ISO8859-15',
807 'fr': 'fr_FR.ISO8859-1',
808 'fr_be': 'fr_BE.ISO8859-1',
809 'fr_be.88591': 'fr_BE.ISO8859-1',
810 'fr_be.iso88591': 'fr_BE.ISO8859-1',
811 'fr_be.iso885915': 'fr_BE.ISO8859-15',
812 'fr_be@euro': 'fr_BE.ISO8859-15',
813 'fr_ca': 'fr_CA.ISO8859-1',
814 'fr_ca.88591': 'fr_CA.ISO8859-1',
815 'fr_ca.iso88591': 'fr_CA.ISO8859-1',
816 'fr_ca.iso885915': 'fr_CA.ISO8859-15',
817 'fr_ca@euro': 'fr_CA.ISO8859-15',
818 'fr_ch': 'fr_CH.ISO8859-1',
819 'fr_ch.88591': 'fr_CH.ISO8859-1',
820 'fr_ch.iso88591': 'fr_CH.ISO8859-1',
821 'fr_ch.iso885915': 'fr_CH.ISO8859-15',
822 'fr_ch@euro': 'fr_CH.ISO8859-15',
823 'fr_fr': 'fr_FR.ISO8859-1',
824 'fr_fr.88591': 'fr_FR.ISO8859-1',
825 'fr_fr.iso88591': 'fr_FR.ISO8859-1',
826 'fr_fr.iso885915': 'fr_FR.ISO8859-15',
827 'fr_fr@euro': 'fr_FR.ISO8859-15',
828 'fr_lu': 'fr_LU.ISO8859-1',
829 'fr_lu.88591': 'fr_LU.ISO8859-1',
830 'fr_lu.iso88591': 'fr_LU.ISO8859-1',
831 'fr_lu.iso885915': 'fr_LU.ISO8859-15',
832 'fr_lu@euro': 'fr_LU.ISO8859-15',
833 'fran\xe7ais': 'fr_FR.ISO8859-1',
834 'fre_fr': 'fr_FR.ISO8859-1',
835 'fre_fr.8859': 'fr_FR.ISO8859-1',
836 'french': 'fr_FR.ISO8859-1',
837 'french.iso88591': 'fr_CH.ISO8859-1',
838 'french_france': 'fr_FR.ISO8859-1',
839 'french_france.8859': 'fr_FR.ISO8859-1',
840 'ga': 'ga_IE.ISO8859-1',
841 'ga_ie': 'ga_IE.ISO8859-1',
842 'ga_ie.iso88591': 'ga_IE.ISO8859-1',
843 'ga_ie.iso885914': 'ga_IE.ISO8859-14',
844 'ga_ie.iso885915': 'ga_IE.ISO8859-15',
845 'ga_ie@euro': 'ga_IE.ISO8859-15',
846 'galego': 'gl_ES.ISO8859-1',
847 'galician': 'gl_ES.ISO8859-1',
848 'gd': 'gd_GB.ISO8859-1',
849 'gd_gb': 'gd_GB.ISO8859-1',
850 'gd_gb.iso88591': 'gd_GB.ISO8859-1',
851 'gd_gb.iso885914': 'gd_GB.ISO8859-14',
852 'gd_gb.iso885915': 'gd_GB.ISO8859-15',
853 'gd_gb@euro': 'gd_GB.ISO8859-15',
854 'ger_de': 'de_DE.ISO8859-1',
855 'ger_de.8859': 'de_DE.ISO8859-1',
856 'german': 'de_DE.ISO8859-1',
857 'german.iso88591': 'de_CH.ISO8859-1',
858 'german_germany': 'de_DE.ISO8859-1',
859 'german_germany.8859': 'de_DE.ISO8859-1',
860 'gl': 'gl_ES.ISO8859-1',
861 'gl_es': 'gl_ES.ISO8859-1',
862 'gl_es.iso88591': 'gl_ES.ISO8859-1',
863 'gl_es.iso885915': 'gl_ES.ISO8859-15',
864 'gl_es@euro': 'gl_ES.ISO8859-15',
865 'greek': 'el_GR.ISO8859-7',
866 'greek.iso88597': 'el_GR.ISO8859-7',
867 'gv': 'gv_GB.ISO8859-1',
868 'gv_gb': 'gv_GB.ISO8859-1',
869 'gv_gb.iso88591': 'gv_GB.ISO8859-1',
870 'gv_gb.iso885914': 'gv_GB.ISO8859-14',
871 'gv_gb.iso885915': 'gv_GB.ISO8859-15',
872 'gv_gb@euro': 'gv_GB.ISO8859-15',
873 'he': 'he_IL.ISO8859-8',
874 'he_il': 'he_IL.ISO8859-8',
875 'he_il.cp1255': 'he_IL.CP1255',
876 'he_il.iso88598': 'he_IL.ISO8859-8',
877 'he_il.microsoftcp1255': 'he_IL.CP1255',
878 'hebrew': 'iw_IL.ISO8859-8',
879 'hebrew.iso88598': 'iw_IL.ISO8859-8',
880 'hi': 'hi_IN.ISCII-DEV',
881 'hi_in': 'hi_IN.ISCII-DEV',
882 'hi_in.isciidev': 'hi_IN.ISCII-DEV',
883 'hr': 'hr_HR.ISO8859-2',
884 'hr_hr': 'hr_HR.ISO8859-2',
885 'hr_hr.iso88592': 'hr_HR.ISO8859-2',
886 'hrvatski': 'hr_HR.ISO8859-2',
887 'hu': 'hu_HU.ISO8859-2',
888 'hu_hu': 'hu_HU.ISO8859-2',
889 'hu_hu.iso88592': 'hu_HU.ISO8859-2',
890 'hungarian': 'hu_HU.ISO8859-2',
891 'icelandic': 'is_IS.ISO8859-1',
892 'icelandic.iso88591': 'is_IS.ISO8859-1',
893 'id': 'id_ID.ISO8859-1',
894 'id_id': 'id_ID.ISO8859-1',
895 'in': 'id_ID.ISO8859-1',
896 'in_id': 'id_ID.ISO8859-1',
897 'is': 'is_IS.ISO8859-1',
898 'is_is': 'is_IS.ISO8859-1',
899 'is_is.iso88591': 'is_IS.ISO8859-1',
900 'is_is.iso885915': 'is_IS.ISO8859-15',
901 'is_is@euro': 'is_IS.ISO8859-15',
902 'iso-8859-1': 'en_US.ISO8859-1',
903 'iso-8859-15': 'en_US.ISO8859-15',
904 'iso8859-1': 'en_US.ISO8859-1',
905 'iso8859-15': 'en_US.ISO8859-15',
906 'iso_8859_1': 'en_US.ISO8859-1',
907 'iso_8859_15': 'en_US.ISO8859-15',
908 'it': 'it_IT.ISO8859-1',
909 'it_ch': 'it_CH.ISO8859-1',
910 'it_ch.iso88591': 'it_CH.ISO8859-1',
911 'it_ch.iso885915': 'it_CH.ISO8859-15',
912 'it_ch@euro': 'it_CH.ISO8859-15',
913 'it_it': 'it_IT.ISO8859-1',
914 'it_it.88591': 'it_IT.ISO8859-1',
915 'it_it.iso88591': 'it_IT.ISO8859-1',
916 'it_it.iso885915': 'it_IT.ISO8859-15',
917 'it_it@euro': 'it_IT.ISO8859-15',
918 'italian': 'it_IT.ISO8859-1',
919 'italian.iso88591': 'it_IT.ISO8859-1',
920 'iu': 'iu_CA.NUNACOM-8',
921 'iu_ca': 'iu_CA.NUNACOM-8',
922 'iu_ca.nunacom8': 'iu_CA.NUNACOM-8',
923 'iw': 'he_IL.ISO8859-8',
924 'iw_il': 'he_IL.ISO8859-8',
925 'iw_il.iso88598': 'he_IL.ISO8859-8',
926 'ja': 'ja_JP.eucJP',
927 'ja.jis': 'ja_JP.JIS7',
928 'ja.sjis': 'ja_JP.SJIS',
929 'ja_jp': 'ja_JP.eucJP',
930 'ja_jp.ajec': 'ja_JP.eucJP',
931 'ja_jp.euc': 'ja_JP.eucJP',
932 'ja_jp.eucjp': 'ja_JP.eucJP',
933 'ja_jp.iso-2022-jp': 'ja_JP.JIS7',
934 'ja_jp.iso2022jp': 'ja_JP.JIS7',
935 'ja_jp.jis': 'ja_JP.JIS7',
936 'ja_jp.jis7': 'ja_JP.JIS7',
937 'ja_jp.mscode': 'ja_JP.SJIS',
938 'ja_jp.sjis': 'ja_JP.SJIS',
939 'ja_jp.ujis': 'ja_JP.eucJP',
940 'japan': 'ja_JP.eucJP',
941 'japanese': 'ja_JP.eucJP',
942 'japanese-euc': 'ja_JP.eucJP',
943 'japanese.euc': 'ja_JP.eucJP',
944 'japanese.sjis': 'ja_JP.SJIS',
945 'jp_jp': 'ja_JP.eucJP',
946 'ka': 'ka_GE.GEORGIAN-ACADEMY',
947 'ka_ge': 'ka_GE.GEORGIAN-ACADEMY',
948 'ka_ge.georgianacademy': 'ka_GE.GEORGIAN-ACADEMY',
949 'ka_ge.georgianps': 'ka_GE.GEORGIAN-PS',
950 'ka_ge.georgianrs': 'ka_GE.GEORGIAN-ACADEMY',
951 'kl': 'kl_GL.ISO8859-1',
952 'kl_gl': 'kl_GL.ISO8859-1',
953 'kl_gl.iso88591': 'kl_GL.ISO8859-1',
954 'kl_gl.iso885915': 'kl_GL.ISO8859-15',
955 'kl_gl@euro': 'kl_GL.ISO8859-15',
956 'ko': 'ko_KR.eucKR',
957 'ko_kr': 'ko_KR.eucKR',
958 'ko_kr.euc': 'ko_KR.eucKR',
959 'ko_kr.euckr': 'ko_KR.eucKR',
960 'korean': 'ko_KR.eucKR',
961 'korean.euc': 'ko_KR.eucKR',
962 'kw': 'kw_GB.ISO8859-1',
963 'kw_gb': 'kw_GB.ISO8859-1',
964 'kw_gb.iso88591': 'kw_GB.ISO8859-1',
965 'kw_gb.iso885914': 'kw_GB.ISO8859-14',
966 'kw_gb.iso885915': 'kw_GB.ISO8859-15',
967 'kw_gb@euro': 'kw_GB.ISO8859-15',
968 'lithuanian': 'lt_LT.ISO8859-13',
969 'lo': 'lo_LA.MULELAO-1',
970 'lo_la': 'lo_LA.MULELAO-1',
971 'lo_la.cp1133': 'lo_LA.IBM-CP1133',
972 'lo_la.ibmcp1133': 'lo_LA.IBM-CP1133',
973 'lo_la.mulelao1': 'lo_LA.MULELAO-1',
974 'lt': 'lt_LT.ISO8859-13',
975 'lt_lt': 'lt_LT.ISO8859-13',
976 'lt_lt.iso885913': 'lt_LT.ISO8859-13',
977 'lt_lt.iso88594': 'lt_LT.ISO8859-4',
978 'lv': 'lv_LV.ISO8859-13',
979 'lv_lv': 'lv_LV.ISO8859-13',
980 'lv_lv.iso885913': 'lv_LV.ISO8859-13',
981 'lv_lv.iso88594': 'lv_LV.ISO8859-4',
982 'mi': 'mi_NZ.ISO8859-1',
983 'mi_nz': 'mi_NZ.ISO8859-1',
984 'mi_nz.iso88591': 'mi_NZ.ISO8859-1',
985 'mk': 'mk_MK.ISO8859-5',
986 'mk_mk': 'mk_MK.ISO8859-5',
987 'mk_mk.cp1251': 'mk_MK.CP1251',
988 'mk_mk.iso88595': 'mk_MK.ISO8859-5',
989 'mk_mk.microsoftcp1251': 'mk_MK.CP1251',
990 'ms': 'ms_MY.ISO8859-1',
991 'ms_my': 'ms_MY.ISO8859-1',
992 'ms_my.iso88591': 'ms_MY.ISO8859-1',
993 'mt': 'mt_MT.ISO8859-3',
994 'mt_mt': 'mt_MT.ISO8859-3',
995 'mt_mt.iso88593': 'mt_MT.ISO8859-3',
996 'nb': 'nb_NO.ISO8859-1',
997 'nb_no': 'nb_NO.ISO8859-1',
998 'nb_no.88591': 'nb_NO.ISO8859-1',
999 'nb_no.iso88591': 'nb_NO.ISO8859-1',
1000 'nb_no.iso885915': 'nb_NO.ISO8859-15',
1001 'nb_no@euro': 'nb_NO.ISO8859-15',
1002 'nl': 'nl_NL.ISO8859-1',
1003 'nl_be': 'nl_BE.ISO8859-1',
1004 'nl_be.88591': 'nl_BE.ISO8859-1',
1005 'nl_be.iso88591': 'nl_BE.ISO8859-1',
1006 'nl_be.iso885915': 'nl_BE.ISO8859-15',
1007 'nl_be@euro': 'nl_BE.ISO8859-15',
1008 'nl_nl': 'nl_NL.ISO8859-1',
1009 'nl_nl.88591': 'nl_NL.ISO8859-1',
1010 'nl_nl.iso88591': 'nl_NL.ISO8859-1',
1011 'nl_nl.iso885915': 'nl_NL.ISO8859-15',
1012 'nl_nl@euro': 'nl_NL.ISO8859-15',
1013 'nn': 'nn_NO.ISO8859-1',
1014 'nn_no': 'nn_NO.ISO8859-1',
1015 'nn_no.88591': 'nn_NO.ISO8859-1',
1016 'nn_no.iso88591': 'nn_NO.ISO8859-1',
1017 'nn_no.iso885915': 'nn_NO.ISO8859-15',
1018 'nn_no@euro': 'nn_NO.ISO8859-15',
1019 'no': 'no_NO.ISO8859-1',
1020 'no@nynorsk': 'ny_NO.ISO8859-1',
1021 'no_no': 'no_NO.ISO8859-1',
1022 'no_no.88591': 'no_NO.ISO8859-1',
1023 'no_no.iso88591': 'no_NO.ISO8859-1',
1024 'no_no.iso885915': 'no_NO.ISO8859-15',
1025 'no_no@euro': 'no_NO.ISO8859-15',
1026 'norwegian': 'no_NO.ISO8859-1',
1027 'norwegian.iso88591': 'no_NO.ISO8859-1',
1028 'ny': 'ny_NO.ISO8859-1',
1029 'ny_no': 'ny_NO.ISO8859-1',
1030 'ny_no.88591': 'ny_NO.ISO8859-1',
1031 'ny_no.iso88591': 'ny_NO.ISO8859-1',
1032 'ny_no.iso885915': 'ny_NO.ISO8859-15',
1033 'ny_no@euro': 'ny_NO.ISO8859-15',
1034 'nynorsk': 'nn_NO.ISO8859-1',
1035 'oc': 'oc_FR.ISO8859-1',
1036 'oc_fr': 'oc_FR.ISO8859-1',
1037 'oc_fr.iso88591': 'oc_FR.ISO8859-1',
1038 'oc_fr.iso885915': 'oc_FR.ISO8859-15',
1039 'oc_fr@euro': 'oc_FR.ISO8859-15',
1040 'pd': 'pd_US.ISO8859-1',
1041 'pd_de': 'pd_DE.ISO8859-1',
1042 'pd_de.iso88591': 'pd_DE.ISO8859-1',
1043 'pd_de.iso885915': 'pd_DE.ISO8859-15',
1044 'pd_de@euro': 'pd_DE.ISO8859-15',
1045 'pd_us': 'pd_US.ISO8859-1',
1046 'pd_us.iso88591': 'pd_US.ISO8859-1',
1047 'pd_us.iso885915': 'pd_US.ISO8859-15',
1048 'pd_us@euro': 'pd_US.ISO8859-15',
1049 'ph': 'ph_PH.ISO8859-1',
1050 'ph_ph': 'ph_PH.ISO8859-1',
1051 'ph_ph.iso88591': 'ph_PH.ISO8859-1',
1052 'pl': 'pl_PL.ISO8859-2',
1053 'pl_pl': 'pl_PL.ISO8859-2',
1054 'pl_pl.iso88592': 'pl_PL.ISO8859-2',
1055 'polish': 'pl_PL.ISO8859-2',
1056 'portuguese': 'pt_PT.ISO8859-1',
1057 'portuguese.iso88591': 'pt_PT.ISO8859-1',
1058 'portuguese_brazil': 'pt_BR.ISO8859-1',
1059 'portuguese_brazil.8859': 'pt_BR.ISO8859-1',
1060 'posix': 'C',
1061 'posix-utf2': 'C',
1062 'pp': 'pp_AN.ISO8859-1',
1063 'pp_an': 'pp_AN.ISO8859-1',
1064 'pp_an.iso88591': 'pp_AN.ISO8859-1',
1065 'pt': 'pt_PT.ISO8859-1',
1066 'pt_br': 'pt_BR.ISO8859-1',
1067 'pt_br.88591': 'pt_BR.ISO8859-1',
1068 'pt_br.iso88591': 'pt_BR.ISO8859-1',
1069 'pt_br.iso885915': 'pt_BR.ISO8859-15',
1070 'pt_br@euro': 'pt_BR.ISO8859-15',
1071 'pt_pt': 'pt_PT.ISO8859-1',
1072 'pt_pt.88591': 'pt_PT.ISO8859-1',
1073 'pt_pt.iso88591': 'pt_PT.ISO8859-1',
1074 'pt_pt.iso885915': 'pt_PT.ISO8859-15',
1075 'pt_pt.utf8@euro': 'pt_PT.UTF-8',
1076 'pt_pt@euro': 'pt_PT.ISO8859-15',
1077 'ro': 'ro_RO.ISO8859-2',
1078 'ro_ro': 'ro_RO.ISO8859-2',
1079 'ro_ro.iso88592': 'ro_RO.ISO8859-2',
1080 'romanian': 'ro_RO.ISO8859-2',
1081 'ru': 'ru_RU.ISO8859-5',
1082 'ru_ru': 'ru_RU.ISO8859-5',
1083 'ru_ru.cp1251': 'ru_RU.CP1251',
1084 'ru_ru.iso88595': 'ru_RU.ISO8859-5',
1085 'ru_ru.koi8r': 'ru_RU.KOI8-R',
1086 'ru_ru.microsoftcp1251': 'ru_RU.CP1251',
1087 'ru_ua': 'ru_UA.KOI8-U',
1088 'ru_ua.cp1251': 'ru_UA.CP1251',
1089 'ru_ua.koi8u': 'ru_UA.KOI8-U',
1090 'ru_ua.microsoftcp1251': 'ru_UA.CP1251',
1091 'rumanian': 'ro_RO.ISO8859-2',
1092 'russian': 'ru_RU.ISO8859-5',
1093 'se_no': 'se_NO.UTF-8',
1094 'serbocroatian': 'sh_YU.ISO8859-2',
1095 'sh': 'sh_YU.ISO8859-2',
1096 'sh_hr': 'sh_HR.ISO8859-2',
1097 'sh_hr.iso88592': 'sh_HR.ISO8859-2',
1098 'sh_sp': 'sh_YU.ISO8859-2',
1099 'sh_yu': 'sh_YU.ISO8859-2',
1100 'sk': 'sk_SK.ISO8859-2',
1101 'sk_sk': 'sk_SK.ISO8859-2',
1102 'sk_sk.iso88592': 'sk_SK.ISO8859-2',
1103 'sl': 'sl_SI.ISO8859-2',
1104 'sl_cs': 'sl_CS.ISO8859-2',
1105 'sl_si': 'sl_SI.ISO8859-2',
1106 'sl_si.iso88592': 'sl_SI.ISO8859-2',
1107 'slovak': 'sk_SK.ISO8859-2',
1108 'slovene': 'sl_SI.ISO8859-2',
1109 'slovenian': 'sl_SI.ISO8859-2',
1110 'sp': 'sp_YU.ISO8859-5',
1111 'sp_yu': 'sp_YU.ISO8859-5',
1112 'spanish': 'es_ES.ISO8859-1',
1113 'spanish.iso88591': 'es_ES.ISO8859-1',
1114 'spanish_spain': 'es_ES.ISO8859-1',
1115 'spanish_spain.8859': 'es_ES.ISO8859-1',
1116 'sq': 'sq_AL.ISO8859-2',
1117 'sq_al': 'sq_AL.ISO8859-2',
1118 'sq_al.iso88592': 'sq_AL.ISO8859-2',
1119 'sr': 'sr_YU.ISO8859-5',
1120 'sr@cyrillic': 'sr_YU.ISO8859-5',
1121 'sr_sp': 'sr_SP.ISO8859-2',
1122 'sr_yu': 'sr_YU.ISO8859-5',
1123 'sr_yu.cp1251@cyrillic': 'sr_YU.CP1251',
1124 'sr_yu.iso88592': 'sr_YU.ISO8859-2',
1125 'sr_yu.iso88595': 'sr_YU.ISO8859-5',
1126 'sr_yu.iso88595@cyrillic': 'sr_YU.ISO8859-5',
1127 'sr_yu.microsoftcp1251@cyrillic': 'sr_YU.CP1251',
1128 'sr_yu.utf8@cyrillic': 'sr_YU.UTF-8',
1129 'sr_yu@cyrillic': 'sr_YU.ISO8859-5',
1130 'sv': 'sv_SE.ISO8859-1',
1131 'sv_fi': 'sv_FI.ISO8859-1',
1132 'sv_fi.iso88591': 'sv_FI.ISO8859-1',
1133 'sv_fi.iso885915': 'sv_FI.ISO8859-15',
1134 'sv_fi@euro': 'sv_FI.ISO8859-15',
1135 'sv_se': 'sv_SE.ISO8859-1',
1136 'sv_se.88591': 'sv_SE.ISO8859-1',
1137 'sv_se.iso88591': 'sv_SE.ISO8859-1',
1138 'sv_se.iso885915': 'sv_SE.ISO8859-15',
1139 'sv_se@euro': 'sv_SE.ISO8859-15',
1140 'swedish': 'sv_SE.ISO8859-1',
1141 'swedish.iso88591': 'sv_SE.ISO8859-1',
1142 'ta': 'ta_IN.TSCII-0',
1143 'ta_in': 'ta_IN.TSCII-0',
1144 'ta_in.tscii': 'ta_IN.TSCII-0',
1145 'ta_in.tscii0': 'ta_IN.TSCII-0',
1146 'tg': 'tg_TJ.KOI8-C',
1147 'tg_tj': 'tg_TJ.KOI8-C',
1148 'tg_tj.koi8c': 'tg_TJ.KOI8-C',
1149 'th': 'th_TH.ISO8859-11',
1150 'th_th': 'th_TH.ISO8859-11',
1151 'th_th.iso885911': 'th_TH.ISO8859-11',
1152 'th_th.tactis': 'th_TH.TIS620',
1153 'th_th.tis620': 'th_TH.TIS620',
1154 'thai': 'th_TH.ISO8859-11',
1155 'tl': 'tl_PH.ISO8859-1',
1156 'tl_ph': 'tl_PH.ISO8859-1',
1157 'tl_ph.iso88591': 'tl_PH.ISO8859-1',
1158 'tr': 'tr_TR.ISO8859-9',
1159 'tr_tr': 'tr_TR.ISO8859-9',
1160 'tr_tr.iso88599': 'tr_TR.ISO8859-9',
1161 'tt': 'tt_RU.TATAR-CYR',
1162 'tt_ru': 'tt_RU.TATAR-CYR',
1163 'tt_ru.koi8c': 'tt_RU.KOI8-C',
1164 'tt_ru.tatarcyr': 'tt_RU.TATAR-CYR',
1165 'turkish': 'tr_TR.ISO8859-9',
1166 'turkish.iso88599': 'tr_TR.ISO8859-9',
1167 'uk': 'uk_UA.KOI8-U',
1168 'uk_ua': 'uk_UA.KOI8-U',
1169 'uk_ua.cp1251': 'uk_UA.CP1251',
1170 'uk_ua.iso88595': 'uk_UA.ISO8859-5',
1171 'uk_ua.koi8u': 'uk_UA.KOI8-U',
1172 'uk_ua.microsoftcp1251': 'uk_UA.CP1251',
1173 'univ': 'en_US.utf',
1174 'universal': 'en_US.utf',
1175 'universal.utf8@ucs4': 'en_US.UTF-8',
1176 'ur': 'ur_PK.CP1256',
1177 'ur_pk': 'ur_PK.CP1256',
1178 'ur_pk.cp1256': 'ur_PK.CP1256',
1179 'ur_pk.microsoftcp1256': 'ur_PK.CP1256',
1180 'uz': 'uz_UZ.UTF-8',
1181 'uz_uz': 'uz_UZ.UTF-8',
1182 'vi': 'vi_VN.TCVN',
1183 'vi_vn': 'vi_VN.TCVN',
1184 'vi_vn.tcvn': 'vi_VN.TCVN',
1185 'vi_vn.tcvn5712': 'vi_VN.TCVN',
1186 'vi_vn.viscii': 'vi_VN.VISCII',
1187 'vi_vn.viscii111': 'vi_VN.VISCII',
1188 'wa': 'wa_BE.ISO8859-1',
1189 'wa_be': 'wa_BE.ISO8859-1',
1190 'wa_be.iso88591': 'wa_BE.ISO8859-1',
1191 'wa_be.iso885915': 'wa_BE.ISO8859-15',
1192 'wa_be@euro': 'wa_BE.ISO8859-15',
1193 'yi': 'yi_US.CP1255',
1194 'yi_us': 'yi_US.CP1255',
1195 'yi_us.cp1255': 'yi_US.CP1255',
1196 'yi_us.microsoftcp1255': 'yi_US.CP1255',
1197 'zh': 'zh_CN.eucCN',
1198 'zh_cn': 'zh_CN.gb2312',
1199 'zh_cn.big5': 'zh_TW.big5',
1200 'zh_cn.euc': 'zh_CN.eucCN',
1201 'zh_cn.gb18030': 'zh_CN.gb18030',
1202 'zh_cn.gb2312': 'zh_CN.gb2312',
1203 'zh_cn.gbk': 'zh_CN.gbk',
1204 'zh_hk': 'zh_HK.big5hkscs',
1205 'zh_hk.big5': 'zh_HK.big5',
1206 'zh_hk.big5hkscs': 'zh_HK.big5hkscs',
1207 'zh_tw': 'zh_TW.big5',
1208 'zh_tw.big5': 'zh_TW.big5',
1209 'zh_tw.euc': 'zh_TW.eucTW',
1213 # this maps windows language identifiers (as used on Windows 95 and
1214 # earlier) to locale strings.
1216 # NOTE: this mapping is incomplete. If your language is missing, please
1217 # submit a bug report to Python bug manager, which you can find via:
1218 # http://www.python.org/dev/
1219 # Make sure you include the missing language identifier and the suggested
1220 # locale code.
1223 windows_locale = {
1224 0x0404: "zh_TW", # Chinese (Taiwan)
1225 0x0804: "zh_CN", # Chinese (PRC)
1226 0x0406: "da_DK", # Danish
1227 0x0413: "nl_NL", # Dutch (Netherlands)
1228 0x0409: "en_US", # English (United States)
1229 0x0809: "en_UK", # English (United Kingdom)
1230 0x0c09: "en_AU", # English (Australian)
1231 0x1009: "en_CA", # English (Canadian)
1232 0x1409: "en_NZ", # English (New Zealand)
1233 0x1809: "en_IE", # English (Ireland)
1234 0x1c09: "en_ZA", # English (South Africa)
1235 0x040b: "fi_FI", # Finnish
1236 0x040c: "fr_FR", # French (Standard)
1237 0x080c: "fr_BE", # French (Belgian)
1238 0x0c0c: "fr_CA", # French (Canadian)
1239 0x100c: "fr_CH", # French (Switzerland)
1240 0x0407: "de_DE", # German (Standard)
1241 0x0408: "el_GR", # Greek
1242 0x040d: "iw_IL", # Hebrew
1243 0x040f: "is_IS", # Icelandic
1244 0x0410: "it_IT", # Italian (Standard)
1245 0x0411: "ja_JA", # Japanese
1246 0x0414: "no_NO", # Norwegian (Bokmal)
1247 0x0816: "pt_PT", # Portuguese (Standard)
1248 0x0c0a: "es_ES", # Spanish (Modern Sort)
1249 0x0441: "sw_KE", # Swahili (Kenya)
1250 0x041d: "sv_SE", # Swedish
1251 0x081d: "sv_FI", # Swedish (Finland)
1252 0x041f: "tr_TR", # Turkish
1255 def _print_locale():
1257 """ Test function.
1259 categories = {}
1260 def _init_categories(categories=categories):
1261 for k,v in globals().items():
1262 if k[:3] == 'LC_':
1263 categories[k] = v
1264 _init_categories()
1265 del categories['LC_ALL']
1267 print 'Locale defaults as determined by getdefaultlocale():'
1268 print '-'*72
1269 lang, enc = getdefaultlocale()
1270 print 'Language: ', lang or '(undefined)'
1271 print 'Encoding: ', enc or '(undefined)'
1272 print
1274 print 'Locale settings on startup:'
1275 print '-'*72
1276 for name,category in categories.items():
1277 print name, '...'
1278 lang, enc = getlocale(category)
1279 print ' Language: ', lang or '(undefined)'
1280 print ' Encoding: ', enc or '(undefined)'
1281 print
1283 print
1284 print 'Locale settings after calling resetlocale():'
1285 print '-'*72
1286 resetlocale()
1287 for name,category in categories.items():
1288 print name, '...'
1289 lang, enc = getlocale(category)
1290 print ' Language: ', lang or '(undefined)'
1291 print ' Encoding: ', enc or '(undefined)'
1292 print
1294 try:
1295 setlocale(LC_ALL, "")
1296 except:
1297 print 'NOTE:'
1298 print 'setlocale(LC_ALL, "") does not support the default locale'
1299 print 'given in the OS environment variables.'
1300 else:
1301 print
1302 print 'Locale settings after calling setlocale(LC_ALL, ""):'
1303 print '-'*72
1304 for name,category in categories.items():
1305 print name, '...'
1306 lang, enc = getlocale(category)
1307 print ' Language: ', lang or '(undefined)'
1308 print ' Encoding: ', enc or '(undefined)'
1309 print
1313 try:
1314 LC_MESSAGES
1315 except NameError:
1316 pass
1317 else:
1318 __all__.append("LC_MESSAGES")
1320 if __name__=='__main__':
1321 print 'Locale aliasing:'
1322 print
1323 _print_locale()
1324 print
1325 print 'Number formatting:'
1326 print
1327 _test()