home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / lib / python2.6 / locale.py < prev    next >
Encoding:
Python Source  |  2010-12-26  |  86.4 KB  |  1,852 lines

  1. """ Locale support.
  2.  
  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.
  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.  
  14. import sys, encodings, encodings.aliases
  15. import functools
  16.  
  17. # Try importing the _locale module.
  18. #
  19. # If this fails, fall back on a basic 'C' locale emulation.
  20.  
  21. # 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.
  23. __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"]
  28.  
  29. try:
  30.  
  31.     from _locale import *
  32.  
  33. except ImportError:
  34.  
  35.     # Locale emulation
  36.  
  37.     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():
  48.         """ localeconv() -> dict.
  49.             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,
  55.                 'p_cs_precedes': 127,
  56.                 'n_cs_precedes': 127,
  57.                 'mon_grouping': [],
  58.                 'n_sep_by_space': 127,
  59.                 'decimal_point': '.',
  60.                 'negative_sign': '',
  61.                 'positive_sign': '',
  62.                 'p_sep_by_space': 127,
  63.                 'int_curr_symbol': '',
  64.                 'p_sign_posn': 127,
  65.                 'thousands_sep': '',
  66.                 'mon_thousands_sep': '',
  67.                 'frac_digits': 127,
  68.                 'mon_decimal_point': '',
  69.                 'int_frac_digits': 127}
  70.  
  71.     def setlocale(category, value=None):
  72.         """ setlocale(integer,string=None) -> string.
  73.             Activates/queries locale processing.
  74.         """
  75.         if value not in (None, '', 'C'):
  76.             raise Error, '_locale emulation only supports "C" locale'
  77.         return 'C'
  78.  
  79.     def strcoll(a,b):
  80.         """ strcoll(string,string) -> int.
  81.             Compares two strings according to the locale.
  82.         """
  83.         return cmp(a,b)
  84.  
  85.     def strxfrm(s):
  86.         """ strxfrm(string) -> string.
  87.             Returns a string that behaves for cmp locale-aware.
  88.         """
  89.         return s
  90.  
  91.  
  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)
  99. def localeconv():
  100.     d = _localeconv()
  101.     if _override_localeconv:
  102.         d.update(_override_localeconv)
  103.     return d
  104.  
  105.  
  106. ### Number formatting APIs
  107.  
  108. # Author: Martin von Loewis
  109. # improved by Georg Brandl
  110.  
  111. # Iterate over grouping intervals
  112. def _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.  
  124. #perform the grouping from right to left
  125. def _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 = ""
  132.     seps = 0
  133.     if s[-1] == ' ':
  134.         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 = ''
  146.             break
  147.         groups.append(s[-interval:])
  148.         s = s[:-interval]
  149.     if s:
  150.         groups.append(s)
  151.     groups.reverse()
  152.     return (
  153.         left_spaces + thousands_sep.join(groups) + right_spaces,
  154.         len(thousands_sep) * (len(groups) - 1)
  155.     )
  156.  
  157. # Strip a given amount of excess padding from the given string
  158. def _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]
  168.  
  169. def format(percent, value, grouping=False, monetary=False, *additional):
  170.     """Returns the locale-aware substitution of a %? specifier
  171.     (percent).
  172.  
  173.     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)
  192.         if seps:
  193.             formatted = _strip_padding(formatted, seps)
  194.     elif percent[-1] in 'diu':
  195.         seps = 0
  196.         if grouping:
  197.             formatted, seps = _group(formatted, monetary=monetary)
  198.         if seps:
  199.             formatted = _strip_padding(formatted, seps)
  200.     return formatted
  201.  
  202. import re, operator
  203. _percent_re = re.compile(r'%(?:\((?P<key>.*?)\))?'
  204.                          r'(?P<modifiers>[-#0-9 +*.hlL]*?)[eEfFgGdiouxXcrs%]')
  205.  
  206. def format_string(f, val, grouping=False):
  207.     """Formats a string in the same way that the % formatting would use,
  208.     but takes the current locale into account.
  209.     Grouping is applied if the third parameter is true."""
  210.     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)
  226.     else:
  227.         # val is a single value
  228.         val = format(percents[0].group(), val, grouping)
  229.  
  230.     return new_f % val
  231.  
  232. def 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('>', '')
  276.  
  277. def str(val):
  278.     """Convert float to integer, taking the locale into account."""
  279.     return format("%.12g", val)
  280.  
  281. def atof(string, func=float):
  282.     "Parses a string as a float according to the locale settings."
  283.     #First, get rid of the grouping
  284.     ts = localeconv()['thousands_sep']
  285.     if ts:
  286.         string = string.replace(ts, '')
  287.     #next, replace the decimal point with a dot
  288.     dd = localeconv()['decimal_point']
  289.     if dd:
  290.         string = string.replace(dd, '.')
  291.     #finally, parse the string
  292.     return func(string)
  293.  
  294. def atoi(str):
  295.     "Converts a string to an integer according to the locale settings."
  296.     return atof(str, int)
  297.  
  298. def _test():
  299.     setlocale(LC_ALL, "")
  300.     #do grouping
  301.     s1 = format("%d", 123456789,1)
  302.     print s1, "is", atoi(s1)
  303.     #standard formatting
  304.     s1 = str(3.14)
  305.     print s1, "is", atof(s1)
  306.  
  307. ### Locale name aliasing engine
  308.  
  309. # Author: Marc-Andre Lemburg, mal@lemburg.com
  310. # Various tweaks by Fredrik Lundh <fredrik@pythonware.com>
  311.  
  312. # store away the low-level version of setlocale (it's
  313. # overridden below)
  314. _setlocale = setlocale
  315.  
  316. def 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
  333.     fullname = localename.lower()
  334.     if ':' in fullname:
  335.         # ':' is sometimes used as encoding delimiter.
  336.         fullname = fullname.replace(':', '.')
  337.     if '.' in fullname:
  338.         langname, encoding = fullname.split('.')[:2]
  339.         fullname = langname + '.' + encoding
  340.     else:
  341.         langname = fullname
  342.         encoding = ''
  343.  
  344.     # First lookup: fullname (possibly with encoding)
  345.     norm_encoding = encoding.replace('-', '')
  346.     norm_encoding = norm_encoding.replace('_', '')
  347.     lookup_name = langname + '.' + encoding
  348.     code = locale_alias.get(lookup_name, None)
  349.     if code is not None:
  350.         return code
  351.     #print 'first lookup failed'
  352.  
  353.     # Second try: langname (without encoding)
  354.     code = locale_alias.get(langname, None)
  355.     if code is not None:
  356.         #print 'langname lookup succeeded'
  357.         if '.' in code:
  358.             langname, defenc = code.split('.')
  359.         else:
  360.             langname = code
  361.             defenc = ''
  362.         if encoding:
  363.             # 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)
  371.         else:
  372.             encoding = defenc
  373.         #print 'found encoding %r' % encoding
  374.         if encoding:
  375.             return langname + '.' + encoding
  376.         else:
  377.             return langname
  378.  
  379.     else:
  380.         return localename
  381.  
  382. def _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
  393.         unknown to this implementation.
  394.  
  395.     """
  396.     code = normalize(localename)
  397.     if '@' in code:
  398.         # 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'
  405.  
  406.     if '.' in code:
  407.         return tuple(code.split('.')[:2])
  408.     elif code == 'C':
  409.         return None, None
  410.     raise ValueError, 'unknown locale: %s' % localename
  411.  
  412. def _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
  427.  
  428. def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
  429.  
  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
  434.         setlocale(LC_ALL, "") runs using the portable 'C' locale.
  435.         Calling setlocale(LC_ALL, "") lets it use the default locale as
  436.         defined by the LANG variable. Since we don't want to interfere
  437.         with the current locale setting we thus emulate the behavior
  438.         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.     """
  451.  
  452.     try:
  453.         # check if it's supported by the _locale module
  454.         import _locale
  455.         code, encoding = _locale._getdefaultlocale()
  456.     except (ImportError, AttributeError):
  457.         pass
  458.     else:
  459.         # make sure the code/encoding values are valid
  460.         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))
  463.         # ...add other platform-specific processing here, if
  464.         # necessary...
  465.         return code, encoding
  466.  
  467.     # fall back on POSIX behaviour
  468.     import os
  469.     lookup = os.environ.get
  470.     for variable in envvars:
  471.         localename = lookup(variable,None)
  472.         if localename:
  473.             if variable == 'LANGUAGE':
  474.                 localename = localename.split(':')[0]
  475.             break
  476.     else:
  477.         localename = 'C'
  478.     return _parse_localename(localename)
  479.  
  480.  
  481. def getlocale(category=LC_CTYPE):
  482.  
  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.     """
  494.     localename = _setlocale(category)
  495.     if category == LC_ALL and ';' in localename:
  496.         raise TypeError, 'category LC_ALL is not supported'
  497.     return _parse_localename(localename)
  498.  
  499. def setlocale(category, locale=None):
  500.  
  501.     """ Set the locale for the given category.  The locale can be
  502.         a string, a locale tuple (language code, encoding), or None.
  503.  
  504.         Locale tuples are converted to strings the locale aliasing
  505.         engine.  Locale strings are passed directly to the C lib.
  506.  
  507.         category may be given as one of the LC_* values.
  508.  
  509.     """
  510.     if locale and type(locale) is not type(""):
  511.         # convert to string
  512.         locale = normalize(_build_localename(locale))
  513.     return _setlocale(category, locale)
  514.  
  515. def resetlocale(category=LC_ALL):
  516.  
  517.     """ Sets the locale for category to the default setting.
  518.  
  519.         The default setting is determined by calling
  520.         getdefaultlocale(). category defaults to LC_ALL.
  521.  
  522.     """
  523.     _setlocale(category, _build_localename(getdefaultlocale()))
  524.  
  525. if 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
  532.         return _locale._getdefaultlocale()[1]
  533. else:
  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.                 try:
  550.                     setlocale(LC_CTYPE, "")
  551.                 except Error:
  552.                     pass
  553.                 result = nl_langinfo(CODESET)
  554.                 setlocale(LC_CTYPE, oldloc)
  555.                 return result
  556.             else:
  557.                 return nl_langinfo(CODESET)
  558.  
  559.  
  560. ### Database
  561. #
  562. # The following data was extracted from the locale.alias file which
  563. # comes with X11 and then hand edited removing the explicit encoding
  564. # definitions and adding some more aliases. The file is usually
  565. # available as /usr/lib/X11/locale/locale.alias.
  566. #
  567.  
  568. #
  569. # The local_encoding_alias table maps lowercase encoding alias names
  570. # to C locale encoding names (case-sensitive). Note that normalize()
  571. # first looks up the encoding in the encodings.aliases dictionary and
  572. # then applies this mapping to find the correct C lib name for the
  573. # encoding.
  574. #
  575. locale_encoding_alias = {
  576.  
  577.     # Mappings for non-standard encoding names used in locale names
  578.     '437':                          'C',
  579.     'c':                            'C',
  580.     'en':                           'ISO8859-1',
  581.     'jis':                          'JIS7',
  582.     'jis7':                         'JIS7',
  583.     'ajec':                         'eucJP',
  584.  
  585.     # Mappings from Python codec names to C lib encoding names
  586.     'ascii':                        'ISO8859-1',
  587.     'latin_1':                      'ISO8859-1',
  588.     'iso8859_1':                    'ISO8859-1',
  589.     'iso8859_10':                   'ISO8859-10',
  590.     'iso8859_11':                   'ISO8859-11',
  591.     'iso8859_13':                   'ISO8859-13',
  592.     'iso8859_14':                   'ISO8859-14',
  593.     'iso8859_15':                   'ISO8859-15',
  594.     'iso8859_16':                   'ISO8859-16',
  595.     'iso8859_2':                    'ISO8859-2',
  596.     'iso8859_3':                    'ISO8859-3',
  597.     'iso8859_4':                    'ISO8859-4',
  598.     'iso8859_5':                    'ISO8859-5',
  599.     'iso8859_6':                    'ISO8859-6',
  600.     'iso8859_7':                    'ISO8859-7',
  601.     'iso8859_8':                    'ISO8859-8',
  602.     'iso8859_9':                    'ISO8859-9',
  603.     'iso2022_jp':                   'JIS7',
  604.     'shift_jis':                    'SJIS',
  605.     'tactis':                       'TACTIS',
  606.     'euc_jp':                       'eucJP',
  607.     'euc_kr':                       'eucKR',
  608.     'utf_8':                        'UTF8',
  609.     'koi8_r':                       'KOI8-R',
  610.     'koi8_u':                       'KOI8-U',
  611.     # XXX This list is still incomplete. If you know more
  612.     # mappings, please file a bug report. Thanks.
  613. }
  614.  
  615. #
  616. # The locale_alias table maps lowercase alias names to C locale names
  617. # (case-sensitive). Encodings are always separated from the locale
  618. # name using a dot ('.'); they should only be given in case the
  619. # language name is needed to interpret the given encoding alias
  620. # correctly (CJK codes often have this need).
  621. #
  622. # Note that the normalize() function which uses this tables
  623. # removes '_' and '-' characters from the encoding part of the
  624. # locale name before doing the lookup. This saves a lot of
  625. # space in the table.
  626. #
  627. # MAL 2004-12-10:
  628. # Updated alias mapping to most recent locale.alias file
  629. # from X.org distribution using makelocalealias.py.
  630. #
  631. # These are the differences compared to the old mapping (Python 2.4
  632. # and older):
  633. #
  634. #    updated 'bg' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
  635. #    updated 'bg_bg' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
  636. #    updated 'bulgarian' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
  637. #    updated 'cz' -> 'cz_CZ.ISO8859-2' to 'cs_CZ.ISO8859-2'
  638. #    updated 'cz_cz' -> 'cz_CZ.ISO8859-2' to 'cs_CZ.ISO8859-2'
  639. #    updated 'czech' -> 'cs_CS.ISO8859-2' to 'cs_CZ.ISO8859-2'
  640. #    updated 'dutch' -> 'nl_BE.ISO8859-1' to 'nl_NL.ISO8859-1'
  641. #    updated 'et' -> 'et_EE.ISO8859-4' to 'et_EE.ISO8859-15'
  642. #    updated 'et_ee' -> 'et_EE.ISO8859-4' to 'et_EE.ISO8859-15'
  643. #    updated 'fi' -> 'fi_FI.ISO8859-1' to 'fi_FI.ISO8859-15'
  644. #    updated 'fi_fi' -> 'fi_FI.ISO8859-1' to 'fi_FI.ISO8859-15'
  645. #    updated 'iw' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
  646. #    updated 'iw_il' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
  647. #    updated 'japanese' -> 'ja_JP.SJIS' to 'ja_JP.eucJP'
  648. #    updated 'lt' -> 'lt_LT.ISO8859-4' to 'lt_LT.ISO8859-13'
  649. #    updated 'lv' -> 'lv_LV.ISO8859-4' to 'lv_LV.ISO8859-13'
  650. #    updated 'sl' -> 'sl_CS.ISO8859-2' to 'sl_SI.ISO8859-2'
  651. #    updated 'slovene' -> 'sl_CS.ISO8859-2' to 'sl_SI.ISO8859-2'
  652. #    updated 'th_th' -> 'th_TH.TACTIS' to 'th_TH.ISO8859-11'
  653. #    updated 'zh_cn' -> 'zh_CN.eucCN' to 'zh_CN.gb2312'
  654. #    updated 'zh_cn.big5' -> 'zh_TW.eucTW' to 'zh_TW.big5'
  655. #    updated 'zh_tw' -> 'zh_TW.eucTW' to 'zh_TW.big5'
  656. #
  657. # MAL 2008-05-30:
  658. # Updated alias mapping to most recent locale.alias file
  659. # from X.org distribution using makelocalealias.py.
  660. #
  661. # These are the differences compared to the old mapping (Python 2.5
  662. # and older):
  663. #
  664. #    updated 'cs_cs.iso88592' -> 'cs_CZ.ISO8859-2' to 'cs_CS.ISO8859-2'
  665. #    updated 'serbocroatian' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
  666. #    updated 'sh' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
  667. #    updated 'sh_hr.iso88592' -> 'sh_HR.ISO8859-2' to 'hr_HR.ISO8859-2'
  668. #    updated 'sh_sp' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
  669. #    updated 'sh_yu' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
  670. #    updated 'sp' -> 'sp_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
  671. #    updated 'sp_yu' -> 'sp_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
  672. #    updated 'sr' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
  673. #    updated 'sr@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
  674. #    updated 'sr_sp' -> 'sr_SP.ISO8859-2' to 'sr_CS.ISO8859-2'
  675. #    updated 'sr_yu' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
  676. #    updated 'sr_yu.cp1251@cyrillic' -> 'sr_YU.CP1251' to 'sr_CS.CP1251'
  677. #    updated 'sr_yu.iso88592' -> 'sr_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
  678. #    updated 'sr_yu.iso88595' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
  679. #    updated 'sr_yu.iso88595@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
  680. #    updated 'sr_yu.microsoftcp1251@cyrillic' -> 'sr_YU.CP1251' to 'sr_CS.CP1251'
  681. #    updated 'sr_yu.utf8@cyrillic' -> 'sr_YU.UTF-8' to 'sr_CS.UTF-8'
  682. #    updated 'sr_yu@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
  683. #
  684. # AP 2010-04-12:
  685. # Updated alias mapping to most recent locale.alias file
  686. # from X.org distribution using makelocalealias.py.
  687. #
  688. # These are the differences compared to the old mapping (Python 2.6.5
  689. # and older):
  690. #
  691. #    updated 'ru' -> 'ru_RU.ISO8859-5' to 'ru_RU.UTF-8'
  692. #    updated 'ru_ru' -> 'ru_RU.ISO8859-5' to 'ru_RU.UTF-8'
  693. #    updated 'serbocroatian' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
  694. #    updated 'sh' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
  695. #    updated 'sh_yu' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
  696. #    updated 'sr' -> 'sr_CS.ISO8859-5' to 'sr_RS.UTF-8'
  697. #    updated 'sr@cyrillic' -> 'sr_CS.ISO8859-5' to 'sr_RS.UTF-8'
  698. #    updated 'sr@latn' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
  699. #    updated 'sr_cs.utf8@latn' -> 'sr_CS.UTF-8' to 'sr_RS.UTF-8@latin'
  700. #    updated 'sr_cs@latn' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
  701. #    updated 'sr_yu' -> 'sr_CS.ISO8859-5' to 'sr_RS.UTF-8@latin'
  702. #    updated 'sr_yu.utf8@cyrillic' -> 'sr_CS.UTF-8' to 'sr_RS.UTF-8'
  703. #    updated 'sr_yu@cyrillic' -> 'sr_CS.ISO8859-5' to 'sr_RS.UTF-8'
  704. #
  705.  
  706. locale_alias = {
  707.     'a3':                                   'a3_AZ.KOI8-C',
  708.     'a3_az':                                'a3_AZ.KOI8-C',
  709.     'a3_az.koi8c':                          'a3_AZ.KOI8-C',
  710.     'af':                                   'af_ZA.ISO8859-1',
  711.     'af_za':                                'af_ZA.ISO8859-1',
  712.     'af_za.iso88591':                       'af_ZA.ISO8859-1',
  713.     'am':                                   'am_ET.UTF-8',
  714.     'am_et':                                'am_ET.UTF-8',
  715.     'american':                             'en_US.ISO8859-1',
  716.     'american.iso88591':                    'en_US.ISO8859-1',
  717.     'ar':                                   'ar_AA.ISO8859-6',
  718.     'ar_aa':                                'ar_AA.ISO8859-6',
  719.     'ar_aa.iso88596':                       'ar_AA.ISO8859-6',
  720.     'ar_ae':                                'ar_AE.ISO8859-6',
  721.     'ar_ae.iso88596':                       'ar_AE.ISO8859-6',
  722.     'ar_bh':                                'ar_BH.ISO8859-6',
  723.     'ar_bh.iso88596':                       'ar_BH.ISO8859-6',
  724.     'ar_dz':                                'ar_DZ.ISO8859-6',
  725.     'ar_dz.iso88596':                       'ar_DZ.ISO8859-6',
  726.     'ar_eg':                                'ar_EG.ISO8859-6',
  727.     'ar_eg.iso88596':                       'ar_EG.ISO8859-6',
  728.     'ar_iq':                                'ar_IQ.ISO8859-6',
  729.     'ar_iq.iso88596':                       'ar_IQ.ISO8859-6',
  730.     'ar_jo':                                'ar_JO.ISO8859-6',
  731.     'ar_jo.iso88596':                       'ar_JO.ISO8859-6',
  732.     'ar_kw':                                'ar_KW.ISO8859-6',
  733.     'ar_kw.iso88596':                       'ar_KW.ISO8859-6',
  734.     'ar_lb':                                'ar_LB.ISO8859-6',
  735.     'ar_lb.iso88596':                       'ar_LB.ISO8859-6',
  736.     'ar_ly':                                'ar_LY.ISO8859-6',
  737.     'ar_ly.iso88596':                       'ar_LY.ISO8859-6',
  738.     'ar_ma':                                'ar_MA.ISO8859-6',
  739.     'ar_ma.iso88596':                       'ar_MA.ISO8859-6',
  740.     'ar_om':                                'ar_OM.ISO8859-6',
  741.     'ar_om.iso88596':                       'ar_OM.ISO8859-6',
  742.     'ar_qa':                                'ar_QA.ISO8859-6',
  743.     'ar_qa.iso88596':                       'ar_QA.ISO8859-6',
  744.     'ar_sa':                                'ar_SA.ISO8859-6',
  745.     'ar_sa.iso88596':                       'ar_SA.ISO8859-6',
  746.     'ar_sd':                                'ar_SD.ISO8859-6',
  747.     'ar_sd.iso88596':                       'ar_SD.ISO8859-6',
  748.     'ar_sy':                                'ar_SY.ISO8859-6',
  749.     'ar_sy.iso88596':                       'ar_SY.ISO8859-6',
  750.     'ar_tn':                                'ar_TN.ISO8859-6',
  751.     'ar_tn.iso88596':                       'ar_TN.ISO8859-6',
  752.     'ar_ye':                                'ar_YE.ISO8859-6',
  753.     'ar_ye.iso88596':                       'ar_YE.ISO8859-6',
  754.     'arabic':                               'ar_AA.ISO8859-6',
  755.     'arabic.iso88596':                      'ar_AA.ISO8859-6',
  756.     'as':                                   'as_IN.UTF-8',
  757.     'az':                                   'az_AZ.ISO8859-9E',
  758.     'az_az':                                'az_AZ.ISO8859-9E',
  759.     'az_az.iso88599e':                      'az_AZ.ISO8859-9E',
  760.     'be':                                   'be_BY.CP1251',
  761.     'be@latin':                             'be_BY.UTF-8@latin',
  762.     'be_by':                                'be_BY.CP1251',
  763.     'be_by.cp1251':                         'be_BY.CP1251',
  764.     'be_by.microsoftcp1251':                'be_BY.CP1251',
  765.     'be_by.utf8@latin':                     'be_BY.UTF-8@latin',
  766.     'be_by@latin':                          'be_BY.UTF-8@latin',
  767.     'bg':                                   'bg_BG.CP1251',
  768.     'bg_bg':                                'bg_BG.CP1251',
  769.     'bg_bg.cp1251':                         'bg_BG.CP1251',
  770.     'bg_bg.iso88595':                       'bg_BG.ISO8859-5',
  771.     'bg_bg.koi8r':                          'bg_BG.KOI8-R',
  772.     'bg_bg.microsoftcp1251':                'bg_BG.CP1251',
  773.     'bn_in':                                'bn_IN.UTF-8',
  774.     'bokmal':                               'nb_NO.ISO8859-1',
  775.     'bokm\xe5l':                            'nb_NO.ISO8859-1',
  776.     'br':                                   'br_FR.ISO8859-1',
  777.     'br_fr':                                'br_FR.ISO8859-1',
  778.     'br_fr.iso88591':                       'br_FR.ISO8859-1',
  779.     'br_fr.iso885914':                      'br_FR.ISO8859-14',
  780.     'br_fr.iso885915':                      'br_FR.ISO8859-15',
  781.     'br_fr.iso885915@euro':                 'br_FR.ISO8859-15',
  782.     'br_fr.utf8@euro':                      'br_FR.UTF-8',
  783.     'br_fr@euro':                           'br_FR.ISO8859-15',
  784.     'bs':                                   'bs_BA.ISO8859-2',
  785.     'bs_ba':                                'bs_BA.ISO8859-2',
  786.     'bs_ba.iso88592':                       'bs_BA.ISO8859-2',
  787.     'bulgarian':                            'bg_BG.CP1251',
  788.     'c':                                    'C',
  789.     'c-french':                             'fr_CA.ISO8859-1',
  790.     'c-french.iso88591':                    'fr_CA.ISO8859-1',
  791.     'c.en':                                 'C',
  792.     'c.iso88591':                           'en_US.ISO8859-1',
  793.     'c_c':                                  'C',
  794.     'c_c.c':                                'C',
  795.     'ca':                                   'ca_ES.ISO8859-1',
  796.     'ca_ad':                                'ca_AD.ISO8859-1',
  797.     'ca_ad.iso88591':                       'ca_AD.ISO8859-1',
  798.     'ca_ad.iso885915':                      'ca_AD.ISO8859-15',
  799.     'ca_ad.iso885915@euro':                 'ca_AD.ISO8859-15',
  800.     'ca_ad.utf8@euro':                      'ca_AD.UTF-8',
  801.     'ca_ad@euro':                           'ca_AD.ISO8859-15',
  802.     'ca_es':                                'ca_ES.ISO8859-1',
  803.     'ca_es.iso88591':                       'ca_ES.ISO8859-1',
  804.     'ca_es.iso885915':                      'ca_ES.ISO8859-15',
  805.     'ca_es.iso885915@euro':                 'ca_ES.ISO8859-15',
  806.     'ca_es.utf8@euro':                      'ca_ES.UTF-8',
  807.     'ca_es@euro':                           'ca_ES.ISO8859-15',
  808.     'ca_fr':                                'ca_FR.ISO8859-1',
  809.     'ca_fr.iso88591':                       'ca_FR.ISO8859-1',
  810.     'ca_fr.iso885915':                      'ca_FR.ISO8859-15',
  811.     'ca_fr.iso885915@euro':                 'ca_FR.ISO8859-15',
  812.     'ca_fr.utf8@euro':                      'ca_FR.UTF-8',
  813.     'ca_fr@euro':                           'ca_FR.ISO8859-15',
  814.     'ca_it':                                'ca_IT.ISO8859-1',
  815.     'ca_it.iso88591':                       'ca_IT.ISO8859-1',
  816.     'ca_it.iso885915':                      'ca_IT.ISO8859-15',
  817.     'ca_it.iso885915@euro':                 'ca_IT.ISO8859-15',
  818.     'ca_it.utf8@euro':                      'ca_IT.UTF-8',
  819.     'ca_it@euro':                           'ca_IT.ISO8859-15',
  820.     'catalan':                              'ca_ES.ISO8859-1',
  821.     'cextend':                              'en_US.ISO8859-1',
  822.     'cextend.en':                           'en_US.ISO8859-1',
  823.     'chinese-s':                            'zh_CN.eucCN',
  824.     'chinese-t':                            'zh_TW.eucTW',
  825.     'croatian':                             'hr_HR.ISO8859-2',
  826.     'cs':                                   'cs_CZ.ISO8859-2',
  827.     'cs_cs':                                'cs_CZ.ISO8859-2',
  828.     'cs_cs.iso88592':                       'cs_CS.ISO8859-2',
  829.     'cs_cz':                                'cs_CZ.ISO8859-2',
  830.     'cs_cz.iso88592':                       'cs_CZ.ISO8859-2',
  831.     'cy':                                   'cy_GB.ISO8859-1',
  832.     'cy_gb':                                'cy_GB.ISO8859-1',
  833.     'cy_gb.iso88591':                       'cy_GB.ISO8859-1',
  834.     'cy_gb.iso885914':                      'cy_GB.ISO8859-14',
  835.     'cy_gb.iso885915':                      'cy_GB.ISO8859-15',
  836.     'cy_gb@euro':                           'cy_GB.ISO8859-15',
  837.     'cz':                                   'cs_CZ.ISO8859-2',
  838.     'cz_cz':                                'cs_CZ.ISO8859-2',
  839.     'czech':                                'cs_CZ.ISO8859-2',
  840.     'da':                                   'da_DK.ISO8859-1',
  841.     'da.iso885915':                         'da_DK.ISO8859-15',
  842.     'da_dk':                                'da_DK.ISO8859-1',
  843.     'da_dk.88591':                          'da_DK.ISO8859-1',
  844.     'da_dk.885915':                         'da_DK.ISO8859-15',
  845.     'da_dk.iso88591':                       'da_DK.ISO8859-1',
  846.     'da_dk.iso885915':                      'da_DK.ISO8859-15',
  847.     'da_dk@euro':                           'da_DK.ISO8859-15',
  848.     'danish':                               'da_DK.ISO8859-1',
  849.     'danish.iso88591':                      'da_DK.ISO8859-1',
  850.     'dansk':                                'da_DK.ISO8859-1',
  851.     'de':                                   'de_DE.ISO8859-1',
  852.     'de.iso885915':                         'de_DE.ISO8859-15',
  853.     'de_at':                                'de_AT.ISO8859-1',
  854.     'de_at.iso88591':                       'de_AT.ISO8859-1',
  855.     'de_at.iso885915':                      'de_AT.ISO8859-15',
  856.     'de_at.iso885915@euro':                 'de_AT.ISO8859-15',
  857.     'de_at.utf8@euro':                      'de_AT.UTF-8',
  858.     'de_at@euro':                           'de_AT.ISO8859-15',
  859.     'de_be':                                'de_BE.ISO8859-1',
  860.     'de_be.iso88591':                       'de_BE.ISO8859-1',
  861.     'de_be.iso885915':                      'de_BE.ISO8859-15',
  862.     'de_be.iso885915@euro':                 'de_BE.ISO8859-15',
  863.     'de_be.utf8@euro':                      'de_BE.UTF-8',
  864.     'de_be@euro':                           'de_BE.ISO8859-15',
  865.     'de_ch':                                'de_CH.ISO8859-1',
  866.     'de_ch.iso88591':                       'de_CH.ISO8859-1',
  867.     'de_ch.iso885915':                      'de_CH.ISO8859-15',
  868.     'de_ch@euro':                           'de_CH.ISO8859-15',
  869.     'de_de':                                'de_DE.ISO8859-1',
  870.     'de_de.88591':                          'de_DE.ISO8859-1',
  871.     'de_de.885915':                         'de_DE.ISO8859-15',
  872.     'de_de.885915@euro':                    'de_DE.ISO8859-15',
  873.     'de_de.iso88591':                       'de_DE.ISO8859-1',
  874.     'de_de.iso885915':                      'de_DE.ISO8859-15',
  875.     'de_de.iso885915@euro':                 'de_DE.ISO8859-15',
  876.     'de_de.utf8@euro':                      'de_DE.UTF-8',
  877.     'de_de@euro':                           'de_DE.ISO8859-15',
  878.     'de_lu':                                'de_LU.ISO8859-1',
  879.     'de_lu.iso88591':                       'de_LU.ISO8859-1',
  880.     'de_lu.iso885915':                      'de_LU.ISO8859-15',
  881.     'de_lu.iso885915@euro':                 'de_LU.ISO8859-15',
  882.     'de_lu.utf8@euro':                      'de_LU.UTF-8',
  883.     'de_lu@euro':                           'de_LU.ISO8859-15',
  884.     'deutsch':                              'de_DE.ISO8859-1',
  885.     'dutch':                                'nl_NL.ISO8859-1',
  886.     'dutch.iso88591':                       'nl_BE.ISO8859-1',
  887.     'ee':                                   'ee_EE.ISO8859-4',
  888.     'ee_ee':                                'ee_EE.ISO8859-4',
  889.     'ee_ee.iso88594':                       'ee_EE.ISO8859-4',
  890.     'eesti':                                'et_EE.ISO8859-1',
  891.     'el':                                   'el_GR.ISO8859-7',
  892.     'el_gr':                                'el_GR.ISO8859-7',
  893.     'el_gr.iso88597':                       'el_GR.ISO8859-7',
  894.     'el_gr@euro':                           'el_GR.ISO8859-15',
  895.     'en':                                   'en_US.ISO8859-1',
  896.     'en.iso88591':                          'en_US.ISO8859-1',
  897.     'en_au':                                'en_AU.ISO8859-1',
  898.     'en_au.iso88591':                       'en_AU.ISO8859-1',
  899.     'en_be':                                'en_BE.ISO8859-1',
  900.     'en_be@euro':                           'en_BE.ISO8859-15',
  901.     'en_bw':                                'en_BW.ISO8859-1',
  902.     'en_bw.iso88591':                       'en_BW.ISO8859-1',
  903.     'en_ca':                                'en_CA.ISO8859-1',
  904.     'en_ca.iso88591':                       'en_CA.ISO8859-1',
  905.     'en_gb':                                'en_GB.ISO8859-1',
  906.     'en_gb.88591':                          'en_GB.ISO8859-1',
  907.     'en_gb.iso88591':                       'en_GB.ISO8859-1',
  908.     'en_gb.iso885915':                      'en_GB.ISO8859-15',
  909.     'en_gb@euro':                           'en_GB.ISO8859-15',
  910.     'en_hk':                                'en_HK.ISO8859-1',
  911.     'en_hk.iso88591':                       'en_HK.ISO8859-1',
  912.     'en_ie':                                'en_IE.ISO8859-1',
  913.     'en_ie.iso88591':                       'en_IE.ISO8859-1',
  914.     'en_ie.iso885915':                      'en_IE.ISO8859-15',
  915.     'en_ie.iso885915@euro':                 'en_IE.ISO8859-15',
  916.     'en_ie.utf8@euro':                      'en_IE.UTF-8',
  917.     'en_ie@euro':                           'en_IE.ISO8859-15',
  918.     'en_in':                                'en_IN.ISO8859-1',
  919.     'en_nz':                                'en_NZ.ISO8859-1',
  920.     'en_nz.iso88591':                       'en_NZ.ISO8859-1',
  921.     'en_ph':                                'en_PH.ISO8859-1',
  922.     'en_ph.iso88591':                       'en_PH.ISO8859-1',
  923.     'en_sg':                                'en_SG.ISO8859-1',
  924.     'en_sg.iso88591':                       'en_SG.ISO8859-1',
  925.     'en_uk':                                'en_GB.ISO8859-1',
  926.     'en_us':                                'en_US.ISO8859-1',
  927.     'en_us.88591':                          'en_US.ISO8859-1',
  928.     'en_us.885915':                         'en_US.ISO8859-15',
  929.     'en_us.iso88591':                       'en_US.ISO8859-1',
  930.     'en_us.iso885915':                      'en_US.ISO8859-15',
  931.     'en_us.iso885915@euro':                 'en_US.ISO8859-15',
  932.     'en_us@euro':                           'en_US.ISO8859-15',
  933.     'en_us@euro@euro':                      'en_US.ISO8859-15',
  934.     'en_za':                                'en_ZA.ISO8859-1',
  935.     'en_za.88591':                          'en_ZA.ISO8859-1',
  936.     'en_za.iso88591':                       'en_ZA.ISO8859-1',
  937.     'en_za.iso885915':                      'en_ZA.ISO8859-15',
  938.     'en_za@euro':                           'en_ZA.ISO8859-15',
  939.     'en_zw':                                'en_ZW.ISO8859-1',
  940.     'en_zw.iso88591':                       'en_ZW.ISO8859-1',
  941.     'eng_gb':                               'en_GB.ISO8859-1',
  942.     'eng_gb.8859':                          'en_GB.ISO8859-1',
  943.     'english':                              'en_EN.ISO8859-1',
  944.     'english.iso88591':                     'en_EN.ISO8859-1',
  945.     'english_uk':                           'en_GB.ISO8859-1',
  946.     'english_uk.8859':                      'en_GB.ISO8859-1',
  947.     'english_united-states':                'en_US.ISO8859-1',
  948.     'english_united-states.437':            'C',
  949.     'english_us':                           'en_US.ISO8859-1',
  950.     'english_us.8859':                      'en_US.ISO8859-1',
  951.     'english_us.ascii':                     'en_US.ISO8859-1',
  952.     'eo':                                   'eo_XX.ISO8859-3',
  953.     'eo_eo':                                'eo_EO.ISO8859-3',
  954.     'eo_eo.iso88593':                       'eo_EO.ISO8859-3',
  955.     'eo_xx':                                'eo_XX.ISO8859-3',
  956.     'eo_xx.iso88593':                       'eo_XX.ISO8859-3',
  957.     'es':                                   'es_ES.ISO8859-1',
  958.     'es_ar':                                'es_AR.ISO8859-1',
  959.     'es_ar.iso88591':                       'es_AR.ISO8859-1',
  960.     'es_bo':                                'es_BO.ISO8859-1',
  961.     'es_bo.iso88591':                       'es_BO.ISO8859-1',
  962.     'es_cl':                                'es_CL.ISO8859-1',
  963.     'es_cl.iso88591':                       'es_CL.ISO8859-1',
  964.     'es_co':                                'es_CO.ISO8859-1',
  965.     'es_co.iso88591':                       'es_CO.ISO8859-1',
  966.     'es_cr':                                'es_CR.ISO8859-1',
  967.     'es_cr.iso88591':                       'es_CR.ISO8859-1',
  968.     'es_do':                                'es_DO.ISO8859-1',
  969.     'es_do.iso88591':                       'es_DO.ISO8859-1',
  970.     'es_ec':                                'es_EC.ISO8859-1',
  971.     'es_ec.iso88591':                       'es_EC.ISO8859-1',
  972.     'es_es':                                'es_ES.ISO8859-1',
  973.     'es_es.88591':                          'es_ES.ISO8859-1',
  974.     'es_es.iso88591':                       'es_ES.ISO8859-1',
  975.     'es_es.iso885915':                      'es_ES.ISO8859-15',
  976.     'es_es.iso885915@euro':                 'es_ES.ISO8859-15',
  977.     'es_es.utf8@euro':                      'es_ES.UTF-8',
  978.     'es_es@euro':                           'es_ES.ISO8859-15',
  979.     'es_gt':                                'es_GT.ISO8859-1',
  980.     'es_gt.iso88591':                       'es_GT.ISO8859-1',
  981.     'es_hn':                                'es_HN.ISO8859-1',
  982.     'es_hn.iso88591':                       'es_HN.ISO8859-1',
  983.     'es_mx':                                'es_MX.ISO8859-1',
  984.     'es_mx.iso88591':                       'es_MX.ISO8859-1',
  985.     'es_ni':                                'es_NI.ISO8859-1',
  986.     'es_ni.iso88591':                       'es_NI.ISO8859-1',
  987.     'es_pa':                                'es_PA.ISO8859-1',
  988.     'es_pa.iso88591':                       'es_PA.ISO8859-1',
  989.     'es_pa.iso885915':                      'es_PA.ISO8859-15',
  990.     'es_pa@euro':                           'es_PA.ISO8859-15',
  991.     'es_pe':                                'es_PE.ISO8859-1',
  992.     'es_pe.iso88591':                       'es_PE.ISO8859-1',
  993.     'es_pe.iso885915':                      'es_PE.ISO8859-15',
  994.     'es_pe@euro':                           'es_PE.ISO8859-15',
  995.     'es_pr':                                'es_PR.ISO8859-1',
  996.     'es_pr.iso88591':                       'es_PR.ISO8859-1',
  997.     'es_py':                                'es_PY.ISO8859-1',
  998.     'es_py.iso88591':                       'es_PY.ISO8859-1',
  999.     'es_py.iso885915':                      'es_PY.ISO8859-15',
  1000.     'es_py@euro':                           'es_PY.ISO8859-15',
  1001.     'es_sv':                                'es_SV.ISO8859-1',
  1002.     'es_sv.iso88591':                       'es_SV.ISO8859-1',
  1003.     'es_sv.iso885915':                      'es_SV.ISO8859-15',
  1004.     'es_sv@euro':                           'es_SV.ISO8859-15',
  1005.     'es_us':                                'es_US.ISO8859-1',
  1006.     'es_us.iso88591':                       'es_US.ISO8859-1',
  1007.     'es_uy':                                'es_UY.ISO8859-1',
  1008.     'es_uy.iso88591':                       'es_UY.ISO8859-1',
  1009.     'es_uy.iso885915':                      'es_UY.ISO8859-15',
  1010.     'es_uy@euro':                           'es_UY.ISO8859-15',
  1011.     'es_ve':                                'es_VE.ISO8859-1',
  1012.     'es_ve.iso88591':                       'es_VE.ISO8859-1',
  1013.     'es_ve.iso885915':                      'es_VE.ISO8859-15',
  1014.     'es_ve@euro':                           'es_VE.ISO8859-15',
  1015.     'estonian':                             'et_EE.ISO8859-1',
  1016.     'et':                                   'et_EE.ISO8859-15',
  1017.     'et_ee':                                'et_EE.ISO8859-15',
  1018.     'et_ee.iso88591':                       'et_EE.ISO8859-1',
  1019.     'et_ee.iso885913':                      'et_EE.ISO8859-13',
  1020.     'et_ee.iso885915':                      'et_EE.ISO8859-15',
  1021.     'et_ee.iso88594':                       'et_EE.ISO8859-4',
  1022.     'et_ee@euro':                           'et_EE.ISO8859-15',
  1023.     'eu':                                   'eu_ES.ISO8859-1',
  1024.     'eu_es':                                'eu_ES.ISO8859-1',
  1025.     'eu_es.iso88591':                       'eu_ES.ISO8859-1',
  1026.     'eu_es.iso885915':                      'eu_ES.ISO8859-15',
  1027.     'eu_es.iso885915@euro':                 'eu_ES.ISO8859-15',
  1028.     'eu_es.utf8@euro':                      'eu_ES.UTF-8',
  1029.     'eu_es@euro':                           'eu_ES.ISO8859-15',
  1030.     'fa':                                   'fa_IR.UTF-8',
  1031.     'fa_ir':                                'fa_IR.UTF-8',
  1032.     'fa_ir.isiri3342':                      'fa_IR.ISIRI-3342',
  1033.     'fi':                                   'fi_FI.ISO8859-15',
  1034.     'fi.iso885915':                         'fi_FI.ISO8859-15',
  1035.     'fi_fi':                                'fi_FI.ISO8859-15',
  1036.     'fi_fi.88591':                          'fi_FI.ISO8859-1',
  1037.     'fi_fi.iso88591':                       'fi_FI.ISO8859-1',
  1038.     'fi_fi.iso885915':                      'fi_FI.ISO8859-15',
  1039.     'fi_fi.iso885915@euro':                 'fi_FI.ISO8859-15',
  1040.     'fi_fi.utf8@euro':                      'fi_FI.UTF-8',
  1041.     'fi_fi@euro':                           'fi_FI.ISO8859-15',
  1042.     'finnish':                              'fi_FI.ISO8859-1',
  1043.     'finnish.iso88591':                     'fi_FI.ISO8859-1',
  1044.     'fo':                                   'fo_FO.ISO8859-1',
  1045.     'fo_fo':                                'fo_FO.ISO8859-1',
  1046.     'fo_fo.iso88591':                       'fo_FO.ISO8859-1',
  1047.     'fo_fo.iso885915':                      'fo_FO.ISO8859-15',
  1048.     'fo_fo@euro':                           'fo_FO.ISO8859-15',
  1049.     'fr':                                   'fr_FR.ISO8859-1',
  1050.     'fr.iso885915':                         'fr_FR.ISO8859-15',
  1051.     'fr_be':                                'fr_BE.ISO8859-1',
  1052.     'fr_be.88591':                          'fr_BE.ISO8859-1',
  1053.     'fr_be.iso88591':                       'fr_BE.ISO8859-1',
  1054.     'fr_be.iso885915':                      'fr_BE.ISO8859-15',
  1055.     'fr_be.iso885915@euro':                 'fr_BE.ISO8859-15',
  1056.     'fr_be.utf8@euro':                      'fr_BE.UTF-8',
  1057.     'fr_be@euro':                           'fr_BE.ISO8859-15',
  1058.     'fr_ca':                                'fr_CA.ISO8859-1',
  1059.     'fr_ca.88591':                          'fr_CA.ISO8859-1',
  1060.     'fr_ca.iso88591':                       'fr_CA.ISO8859-1',
  1061.     'fr_ca.iso885915':                      'fr_CA.ISO8859-15',
  1062.     'fr_ca@euro':                           'fr_CA.ISO8859-15',
  1063.     'fr_ch':                                'fr_CH.ISO8859-1',
  1064.     'fr_ch.88591':                          'fr_CH.ISO8859-1',
  1065.     'fr_ch.iso88591':                       'fr_CH.ISO8859-1',
  1066.     'fr_ch.iso885915':                      'fr_CH.ISO8859-15',
  1067.     'fr_ch@euro':                           'fr_CH.ISO8859-15',
  1068.     'fr_fr':                                'fr_FR.ISO8859-1',
  1069.     'fr_fr.88591':                          'fr_FR.ISO8859-1',
  1070.     'fr_fr.iso88591':                       'fr_FR.ISO8859-1',
  1071.     'fr_fr.iso885915':                      'fr_FR.ISO8859-15',
  1072.     'fr_fr.iso885915@euro':                 'fr_FR.ISO8859-15',
  1073.     'fr_fr.utf8@euro':                      'fr_FR.UTF-8',
  1074.     'fr_fr@euro':                           'fr_FR.ISO8859-15',
  1075.     'fr_lu':                                'fr_LU.ISO8859-1',
  1076.     'fr_lu.88591':                          'fr_LU.ISO8859-1',
  1077.     'fr_lu.iso88591':                       'fr_LU.ISO8859-1',
  1078.     'fr_lu.iso885915':                      'fr_LU.ISO8859-15',
  1079.     'fr_lu.iso885915@euro':                 'fr_LU.ISO8859-15',
  1080.     'fr_lu.utf8@euro':                      'fr_LU.UTF-8',
  1081.     'fr_lu@euro':                           'fr_LU.ISO8859-15',
  1082.     'fran\xe7ais':                          'fr_FR.ISO8859-1',
  1083.     'fre_fr':                               'fr_FR.ISO8859-1',
  1084.     'fre_fr.8859':                          'fr_FR.ISO8859-1',
  1085.     'french':                               'fr_FR.ISO8859-1',
  1086.     'french.iso88591':                      'fr_CH.ISO8859-1',
  1087.     'french_france':                        'fr_FR.ISO8859-1',
  1088.     'french_france.8859':                   'fr_FR.ISO8859-1',
  1089.     'ga':                                   'ga_IE.ISO8859-1',
  1090.     'ga_ie':                                'ga_IE.ISO8859-1',
  1091.     'ga_ie.iso88591':                       'ga_IE.ISO8859-1',
  1092.     'ga_ie.iso885914':                      'ga_IE.ISO8859-14',
  1093.     'ga_ie.iso885915':                      'ga_IE.ISO8859-15',
  1094.     'ga_ie.iso885915@euro':                 'ga_IE.ISO8859-15',
  1095.     'ga_ie.utf8@euro':                      'ga_IE.UTF-8',
  1096.     'ga_ie@euro':                           'ga_IE.ISO8859-15',
  1097.     'galego':                               'gl_ES.ISO8859-1',
  1098.     'galician':                             'gl_ES.ISO8859-1',
  1099.     'gd':                                   'gd_GB.ISO8859-1',
  1100.     'gd_gb':                                'gd_GB.ISO8859-1',
  1101.     'gd_gb.iso88591':                       'gd_GB.ISO8859-1',
  1102.     'gd_gb.iso885914':                      'gd_GB.ISO8859-14',
  1103.     'gd_gb.iso885915':                      'gd_GB.ISO8859-15',
  1104.     'gd_gb@euro':                           'gd_GB.ISO8859-15',
  1105.     'ger_de':                               'de_DE.ISO8859-1',
  1106.     'ger_de.8859':                          'de_DE.ISO8859-1',
  1107.     'german':                               'de_DE.ISO8859-1',
  1108.     'german.iso88591':                      'de_CH.ISO8859-1',
  1109.     'german_germany':                       'de_DE.ISO8859-1',
  1110.     'german_germany.8859':                  'de_DE.ISO8859-1',
  1111.     'gl':                                   'gl_ES.ISO8859-1',
  1112.     'gl_es':                                'gl_ES.ISO8859-1',
  1113.     'gl_es.iso88591':                       'gl_ES.ISO8859-1',
  1114.     'gl_es.iso885915':                      'gl_ES.ISO8859-15',
  1115.     'gl_es.iso885915@euro':                 'gl_ES.ISO8859-15',
  1116.     'gl_es.utf8@euro':                      'gl_ES.UTF-8',
  1117.     'gl_es@euro':                           'gl_ES.ISO8859-15',
  1118.     'greek':                                'el_GR.ISO8859-7',
  1119.     'greek.iso88597':                       'el_GR.ISO8859-7',
  1120.     'gu_in':                                'gu_IN.UTF-8',
  1121.     'gv':                                   'gv_GB.ISO8859-1',
  1122.     'gv_gb':                                'gv_GB.ISO8859-1',
  1123.     'gv_gb.iso88591':                       'gv_GB.ISO8859-1',
  1124.     'gv_gb.iso885914':                      'gv_GB.ISO8859-14',
  1125.     'gv_gb.iso885915':                      'gv_GB.ISO8859-15',
  1126.     'gv_gb@euro':                           'gv_GB.ISO8859-15',
  1127.     'he':                                   'he_IL.ISO8859-8',
  1128.     'he_il':                                'he_IL.ISO8859-8',
  1129.     'he_il.cp1255':                         'he_IL.CP1255',
  1130.     'he_il.iso88598':                       'he_IL.ISO8859-8',
  1131.     'he_il.microsoftcp1255':                'he_IL.CP1255',
  1132.     'hebrew':                               'iw_IL.ISO8859-8',
  1133.     'hebrew.iso88598':                      'iw_IL.ISO8859-8',
  1134.     'hi':                                   'hi_IN.ISCII-DEV',
  1135.     'hi_in':                                'hi_IN.ISCII-DEV',
  1136.     'hi_in.isciidev':                       'hi_IN.ISCII-DEV',
  1137.     'hne':                                  'hne_IN.UTF-8',
  1138.     'hr':                                   'hr_HR.ISO8859-2',
  1139.     'hr_hr':                                'hr_HR.ISO8859-2',
  1140.     'hr_hr.iso88592':                       'hr_HR.ISO8859-2',
  1141.     'hrvatski':                             'hr_HR.ISO8859-2',
  1142.     'hu':                                   'hu_HU.ISO8859-2',
  1143.     'hu_hu':                                'hu_HU.ISO8859-2',
  1144.     'hu_hu.iso88592':                       'hu_HU.ISO8859-2',
  1145.     'hungarian':                            'hu_HU.ISO8859-2',
  1146.     'icelandic':                            'is_IS.ISO8859-1',
  1147.     'icelandic.iso88591':                   'is_IS.ISO8859-1',
  1148.     'id':                                   'id_ID.ISO8859-1',
  1149.     'id_id':                                'id_ID.ISO8859-1',
  1150.     'in':                                   'id_ID.ISO8859-1',
  1151.     'in_id':                                'id_ID.ISO8859-1',
  1152.     'is':                                   'is_IS.ISO8859-1',
  1153.     'is_is':                                'is_IS.ISO8859-1',
  1154.     'is_is.iso88591':                       'is_IS.ISO8859-1',
  1155.     'is_is.iso885915':                      'is_IS.ISO8859-15',
  1156.     'is_is@euro':                           'is_IS.ISO8859-15',
  1157.     'iso-8859-1':                           'en_US.ISO8859-1',
  1158.     'iso-8859-15':                          'en_US.ISO8859-15',
  1159.     'iso8859-1':                            'en_US.ISO8859-1',
  1160.     'iso8859-15':                           'en_US.ISO8859-15',
  1161.     'iso_8859_1':                           'en_US.ISO8859-1',
  1162.     'iso_8859_15':                          'en_US.ISO8859-15',
  1163.     'it':                                   'it_IT.ISO8859-1',
  1164.     'it.iso885915':                         'it_IT.ISO8859-15',
  1165.     'it_ch':                                'it_CH.ISO8859-1',
  1166.     'it_ch.iso88591':                       'it_CH.ISO8859-1',
  1167.     'it_ch.iso885915':                      'it_CH.ISO8859-15',
  1168.     'it_ch@euro':                           'it_CH.ISO8859-15',
  1169.     'it_it':                                'it_IT.ISO8859-1',
  1170.     'it_it.88591':                          'it_IT.ISO8859-1',
  1171.     'it_it.iso88591':                       'it_IT.ISO8859-1',
  1172.     'it_it.iso885915':                      'it_IT.ISO8859-15',
  1173.     'it_it.iso885915@euro':                 'it_IT.ISO8859-15',
  1174.     'it_it.utf8@euro':                      'it_IT.UTF-8',
  1175.     'it_it@euro':                           'it_IT.ISO8859-15',
  1176.     'italian':                              'it_IT.ISO8859-1',
  1177.     'italian.iso88591':                     'it_IT.ISO8859-1',
  1178.     'iu':                                   'iu_CA.NUNACOM-8',
  1179.     'iu_ca':                                'iu_CA.NUNACOM-8',
  1180.     'iu_ca.nunacom8':                       'iu_CA.NUNACOM-8',
  1181.     'iw':                                   'he_IL.ISO8859-8',
  1182.     'iw_il':                                'he_IL.ISO8859-8',
  1183.     'iw_il.iso88598':                       'he_IL.ISO8859-8',
  1184.     'ja':                                   'ja_JP.eucJP',
  1185.     'ja.jis':                               'ja_JP.JIS7',
  1186.     'ja.sjis':                              'ja_JP.SJIS',
  1187.     'ja_jp':                                'ja_JP.eucJP',
  1188.     'ja_jp.ajec':                           'ja_JP.eucJP',
  1189.     'ja_jp.euc':                            'ja_JP.eucJP',
  1190.     'ja_jp.eucjp':                          'ja_JP.eucJP',
  1191.     'ja_jp.iso-2022-jp':                    'ja_JP.JIS7',
  1192.     'ja_jp.iso2022jp':                      'ja_JP.JIS7',
  1193.     'ja_jp.jis':                            'ja_JP.JIS7',
  1194.     'ja_jp.jis7':                           'ja_JP.JIS7',
  1195.     'ja_jp.mscode':                         'ja_JP.SJIS',
  1196.     'ja_jp.pck':                            'ja_JP.SJIS',
  1197.     'ja_jp.sjis':                           'ja_JP.SJIS',
  1198.     'ja_jp.ujis':                           'ja_JP.eucJP',
  1199.     'japan':                                'ja_JP.eucJP',
  1200.     'japanese':                             'ja_JP.eucJP',
  1201.     'japanese-euc':                         'ja_JP.eucJP',
  1202.     'japanese.euc':                         'ja_JP.eucJP',
  1203.     'japanese.sjis':                        'ja_JP.SJIS',
  1204.     'jp_jp':                                'ja_JP.eucJP',
  1205.     'ka':                                   'ka_GE.GEORGIAN-ACADEMY',
  1206.     'ka_ge':                                'ka_GE.GEORGIAN-ACADEMY',
  1207.     'ka_ge.georgianacademy':                'ka_GE.GEORGIAN-ACADEMY',
  1208.     'ka_ge.georgianps':                     'ka_GE.GEORGIAN-PS',
  1209.     'ka_ge.georgianrs':                     'ka_GE.GEORGIAN-ACADEMY',
  1210.     'kl':                                   'kl_GL.ISO8859-1',
  1211.     'kl_gl':                                'kl_GL.ISO8859-1',
  1212.     'kl_gl.iso88591':                       'kl_GL.ISO8859-1',
  1213.     'kl_gl.iso885915':                      'kl_GL.ISO8859-15',
  1214.     'kl_gl@euro':                           'kl_GL.ISO8859-15',
  1215.     'km_kh':                                'km_KH.UTF-8',
  1216.     'kn':                                   'kn_IN.UTF-8',
  1217.     'kn_in':                                'kn_IN.UTF-8',
  1218.     'ko':                                   'ko_KR.eucKR',
  1219.     'ko_kr':                                'ko_KR.eucKR',
  1220.     'ko_kr.euc':                            'ko_KR.eucKR',
  1221.     'ko_kr.euckr':                          'ko_KR.eucKR',
  1222.     'korean':                               'ko_KR.eucKR',
  1223.     'korean.euc':                           'ko_KR.eucKR',
  1224.     'ks':                                   'ks_IN.UTF-8',
  1225.     'ks_in@devanagari':                     'ks_IN@devanagari.UTF-8',
  1226.     'kw':                                   'kw_GB.ISO8859-1',
  1227.     'kw_gb':                                'kw_GB.ISO8859-1',
  1228.     'kw_gb.iso88591':                       'kw_GB.ISO8859-1',
  1229.     'kw_gb.iso885914':                      'kw_GB.ISO8859-14',
  1230.     'kw_gb.iso885915':                      'kw_GB.ISO8859-15',
  1231.     'kw_gb@euro':                           'kw_GB.ISO8859-15',
  1232.     'ky':                                   'ky_KG.UTF-8',
  1233.     'ky_kg':                                'ky_KG.UTF-8',
  1234.     'lithuanian':                           'lt_LT.ISO8859-13',
  1235.     'lo':                                   'lo_LA.MULELAO-1',
  1236.     'lo_la':                                'lo_LA.MULELAO-1',
  1237.     'lo_la.cp1133':                         'lo_LA.IBM-CP1133',
  1238.     'lo_la.ibmcp1133':                      'lo_LA.IBM-CP1133',
  1239.     'lo_la.mulelao1':                       'lo_LA.MULELAO-1',
  1240.     'lt':                                   'lt_LT.ISO8859-13',
  1241.     'lt_lt':                                'lt_LT.ISO8859-13',
  1242.     'lt_lt.iso885913':                      'lt_LT.ISO8859-13',
  1243.     'lt_lt.iso88594':                       'lt_LT.ISO8859-4',
  1244.     'lv':                                   'lv_LV.ISO8859-13',
  1245.     'lv_lv':                                'lv_LV.ISO8859-13',
  1246.     'lv_lv.iso885913':                      'lv_LV.ISO8859-13',
  1247.     'lv_lv.iso88594':                       'lv_LV.ISO8859-4',
  1248.     'mai':                                  'mai_IN.UTF-8',
  1249.     'mi':                                   'mi_NZ.ISO8859-1',
  1250.     'mi_nz':                                'mi_NZ.ISO8859-1',
  1251.     'mi_nz.iso88591':                       'mi_NZ.ISO8859-1',
  1252.     'mk':                                   'mk_MK.ISO8859-5',
  1253.     'mk_mk':                                'mk_MK.ISO8859-5',
  1254.     'mk_mk.cp1251':                         'mk_MK.CP1251',
  1255.     'mk_mk.iso88595':                       'mk_MK.ISO8859-5',
  1256.     'mk_mk.microsoftcp1251':                'mk_MK.CP1251',
  1257.     'ml':                                   'ml_IN.UTF-8',
  1258.     'mr':                                   'mr_IN.UTF-8',
  1259.     'mr_in':                                'mr_IN.UTF-8',
  1260.     'ms':                                   'ms_MY.ISO8859-1',
  1261.     'ms_my':                                'ms_MY.ISO8859-1',
  1262.     'ms_my.iso88591':                       'ms_MY.ISO8859-1',
  1263.     'mt':                                   'mt_MT.ISO8859-3',
  1264.     'mt_mt':                                'mt_MT.ISO8859-3',
  1265.     'mt_mt.iso88593':                       'mt_MT.ISO8859-3',
  1266.     'nb':                                   'nb_NO.ISO8859-1',
  1267.     'nb_no':                                'nb_NO.ISO8859-1',
  1268.     'nb_no.88591':                          'nb_NO.ISO8859-1',
  1269.     'nb_no.iso88591':                       'nb_NO.ISO8859-1',
  1270.     'nb_no.iso885915':                      'nb_NO.ISO8859-15',
  1271.     'nb_no@euro':                           'nb_NO.ISO8859-15',
  1272.     'nl':                                   'nl_NL.ISO8859-1',
  1273.     'nl.iso885915':                         'nl_NL.ISO8859-15',
  1274.     'nl_be':                                'nl_BE.ISO8859-1',
  1275.     'nl_be.88591':                          'nl_BE.ISO8859-1',
  1276.     'nl_be.iso88591':                       'nl_BE.ISO8859-1',
  1277.     'nl_be.iso885915':                      'nl_BE.ISO8859-15',
  1278.     'nl_be.iso885915@euro':                 'nl_BE.ISO8859-15',
  1279.     'nl_be.utf8@euro':                      'nl_BE.UTF-8',
  1280.     'nl_be@euro':                           'nl_BE.ISO8859-15',
  1281.     'nl_nl':                                'nl_NL.ISO8859-1',
  1282.     'nl_nl.88591':                          'nl_NL.ISO8859-1',
  1283.     'nl_nl.iso88591':                       'nl_NL.ISO8859-1',
  1284.     'nl_nl.iso885915':                      'nl_NL.ISO8859-15',
  1285.     'nl_nl.iso885915@euro':                 'nl_NL.ISO8859-15',
  1286.     'nl_nl.utf8@euro':                      'nl_NL.UTF-8',
  1287.     'nl_nl@euro':                           'nl_NL.ISO8859-15',
  1288.     'nn':                                   'nn_NO.ISO8859-1',
  1289.     'nn_no':                                'nn_NO.ISO8859-1',
  1290.     'nn_no.88591':                          'nn_NO.ISO8859-1',
  1291.     'nn_no.iso88591':                       'nn_NO.ISO8859-1',
  1292.     'nn_no.iso885915':                      'nn_NO.ISO8859-15',
  1293.     'nn_no@euro':                           'nn_NO.ISO8859-15',
  1294.     'no':                                   'no_NO.ISO8859-1',
  1295.     'no@nynorsk':                           'ny_NO.ISO8859-1',
  1296.     'no_no':                                'no_NO.ISO8859-1',
  1297.     'no_no.88591':                          'no_NO.ISO8859-1',
  1298.     'no_no.iso88591':                       'no_NO.ISO8859-1',
  1299.     'no_no.iso885915':                      'no_NO.ISO8859-15',
  1300.     'no_no.iso88591@bokmal':                'no_NO.ISO8859-1',
  1301.     'no_no.iso88591@nynorsk':               'no_NO.ISO8859-1',
  1302.     'no_no@euro':                           'no_NO.ISO8859-15',
  1303.     'norwegian':                            'no_NO.ISO8859-1',
  1304.     'norwegian.iso88591':                   'no_NO.ISO8859-1',
  1305.     'nr':                                   'nr_ZA.ISO8859-1',
  1306.     'nr_za':                                'nr_ZA.ISO8859-1',
  1307.     'nr_za.iso88591':                       'nr_ZA.ISO8859-1',
  1308.     'nso':                                  'nso_ZA.ISO8859-15',
  1309.     'nso_za':                               'nso_ZA.ISO8859-15',
  1310.     'nso_za.iso885915':                     'nso_ZA.ISO8859-15',
  1311.     'ny':                                   'ny_NO.ISO8859-1',
  1312.     'ny_no':                                'ny_NO.ISO8859-1',
  1313.     'ny_no.88591':                          'ny_NO.ISO8859-1',
  1314.     'ny_no.iso88591':                       'ny_NO.ISO8859-1',
  1315.     'ny_no.iso885915':                      'ny_NO.ISO8859-15',
  1316.     'ny_no@euro':                           'ny_NO.ISO8859-15',
  1317.     'nynorsk':                              'nn_NO.ISO8859-1',
  1318.     'oc':                                   'oc_FR.ISO8859-1',
  1319.     'oc_fr':                                'oc_FR.ISO8859-1',
  1320.     'oc_fr.iso88591':                       'oc_FR.ISO8859-1',
  1321.     'oc_fr.iso885915':                      'oc_FR.ISO8859-15',
  1322.     'oc_fr@euro':                           'oc_FR.ISO8859-15',
  1323.     'or':                                   'or_IN.UTF-8',
  1324.     'pa':                                   'pa_IN.UTF-8',
  1325.     'pa_in':                                'pa_IN.UTF-8',
  1326.     'pd':                                   'pd_US.ISO8859-1',
  1327.     'pd_de':                                'pd_DE.ISO8859-1',
  1328.     'pd_de.iso88591':                       'pd_DE.ISO8859-1',
  1329.     'pd_de.iso885915':                      'pd_DE.ISO8859-15',
  1330.     'pd_de@euro':                           'pd_DE.ISO8859-15',
  1331.     'pd_us':                                'pd_US.ISO8859-1',
  1332.     'pd_us.iso88591':                       'pd_US.ISO8859-1',
  1333.     'pd_us.iso885915':                      'pd_US.ISO8859-15',
  1334.     'pd_us@euro':                           'pd_US.ISO8859-15',
  1335.     'ph':                                   'ph_PH.ISO8859-1',
  1336.     'ph_ph':                                'ph_PH.ISO8859-1',
  1337.     'ph_ph.iso88591':                       'ph_PH.ISO8859-1',
  1338.     'pl':                                   'pl_PL.ISO8859-2',
  1339.     'pl_pl':                                'pl_PL.ISO8859-2',
  1340.     'pl_pl.iso88592':                       'pl_PL.ISO8859-2',
  1341.     'polish':                               'pl_PL.ISO8859-2',
  1342.     'portuguese':                           'pt_PT.ISO8859-1',
  1343.     'portuguese.iso88591':                  'pt_PT.ISO8859-1',
  1344.     'portuguese_brazil':                    'pt_BR.ISO8859-1',
  1345.     'portuguese_brazil.8859':               'pt_BR.ISO8859-1',
  1346.     'posix':                                'C',
  1347.     'posix-utf2':                           'C',
  1348.     'pp':                                   'pp_AN.ISO8859-1',
  1349.     'pp_an':                                'pp_AN.ISO8859-1',
  1350.     'pp_an.iso88591':                       'pp_AN.ISO8859-1',
  1351.     'pt':                                   'pt_PT.ISO8859-1',
  1352.     'pt.iso885915':                         'pt_PT.ISO8859-15',
  1353.     'pt_br':                                'pt_BR.ISO8859-1',
  1354.     'pt_br.88591':                          'pt_BR.ISO8859-1',
  1355.     'pt_br.iso88591':                       'pt_BR.ISO8859-1',
  1356.     'pt_br.iso885915':                      'pt_BR.ISO8859-15',
  1357.     'pt_br@euro':                           'pt_BR.ISO8859-15',
  1358.     'pt_pt':                                'pt_PT.ISO8859-1',
  1359.     'pt_pt.88591':                          'pt_PT.ISO8859-1',
  1360.     'pt_pt.iso88591':                       'pt_PT.ISO8859-1',
  1361.     'pt_pt.iso885915':                      'pt_PT.ISO8859-15',
  1362.     'pt_pt.iso885915@euro':                 'pt_PT.ISO8859-15',
  1363.     'pt_pt.utf8@euro':                      'pt_PT.UTF-8',
  1364.     'pt_pt@euro':                           'pt_PT.ISO8859-15',
  1365.     'ro':                                   'ro_RO.ISO8859-2',
  1366.     'ro_ro':                                'ro_RO.ISO8859-2',
  1367.     'ro_ro.iso88592':                       'ro_RO.ISO8859-2',
  1368.     'romanian':                             'ro_RO.ISO8859-2',
  1369.     'ru':                                   'ru_RU.UTF-8',
  1370.     'ru.koi8r':                             'ru_RU.KOI8-R',
  1371.     'ru_ru':                                'ru_RU.UTF-8',
  1372.     'ru_ru.cp1251':                         'ru_RU.CP1251',
  1373.     'ru_ru.iso88595':                       'ru_RU.ISO8859-5',
  1374.     'ru_ru.koi8r':                          'ru_RU.KOI8-R',
  1375.     'ru_ru.microsoftcp1251':                'ru_RU.CP1251',
  1376.     'ru_ua':                                'ru_UA.KOI8-U',
  1377.     'ru_ua.cp1251':                         'ru_UA.CP1251',
  1378.     'ru_ua.koi8u':                          'ru_UA.KOI8-U',
  1379.     'ru_ua.microsoftcp1251':                'ru_UA.CP1251',
  1380.     'rumanian':                             'ro_RO.ISO8859-2',
  1381.     'russian':                              'ru_RU.ISO8859-5',
  1382.     'rw':                                   'rw_RW.ISO8859-1',
  1383.     'rw_rw':                                'rw_RW.ISO8859-1',
  1384.     'rw_rw.iso88591':                       'rw_RW.ISO8859-1',
  1385.     'sd':                                   'sd_IN@devanagari.UTF-8',
  1386.     'se_no':                                'se_NO.UTF-8',
  1387.     'serbocroatian':                        'sr_RS.UTF-8@latin',
  1388.     'sh':                                   'sr_RS.UTF-8@latin',
  1389.     'sh_ba.iso88592@bosnia':                'sr_CS.ISO8859-2',
  1390.     'sh_hr':                                'sh_HR.ISO8859-2',
  1391.     'sh_hr.iso88592':                       'hr_HR.ISO8859-2',
  1392.     'sh_sp':                                'sr_CS.ISO8859-2',
  1393.     'sh_yu':                                'sr_RS.UTF-8@latin',
  1394.     'si':                                   'si_LK.UTF-8',
  1395.     'si_lk':                                'si_LK.UTF-8',
  1396.     'sinhala':                              'si_LK.UTF-8',
  1397.     'sk':                                   'sk_SK.ISO8859-2',
  1398.     'sk_sk':                                'sk_SK.ISO8859-2',
  1399.     'sk_sk.iso88592':                       'sk_SK.ISO8859-2',
  1400.     'sl':                                   'sl_SI.ISO8859-2',
  1401.     'sl_cs':                                'sl_CS.ISO8859-2',
  1402.     'sl_si':                                'sl_SI.ISO8859-2',
  1403.     'sl_si.iso88592':                       'sl_SI.ISO8859-2',
  1404.     'slovak':                               'sk_SK.ISO8859-2',
  1405.     'slovene':                              'sl_SI.ISO8859-2',
  1406.     'slovenian':                            'sl_SI.ISO8859-2',
  1407.     'sp':                                   'sr_CS.ISO8859-5',
  1408.     'sp_yu':                                'sr_CS.ISO8859-5',
  1409.     'spanish':                              'es_ES.ISO8859-1',
  1410.     'spanish.iso88591':                     'es_ES.ISO8859-1',
  1411.     'spanish_spain':                        'es_ES.ISO8859-1',
  1412.     'spanish_spain.8859':                   'es_ES.ISO8859-1',
  1413.     'sq':                                   'sq_AL.ISO8859-2',
  1414.     'sq_al':                                'sq_AL.ISO8859-2',
  1415.     'sq_al.iso88592':                       'sq_AL.ISO8859-2',
  1416.     'sr':                                   'sr_RS.UTF-8',
  1417.     'sr@cyrillic':                          'sr_RS.UTF-8',
  1418.     'sr@latin':                             'sr_RS.UTF-8@latin',
  1419.     'sr@latn':                              'sr_RS.UTF-8@latin',
  1420.     'sr_cs':                                'sr_RS.UTF-8',
  1421.     'sr_cs.iso88592':                       'sr_CS.ISO8859-2',
  1422.     'sr_cs.iso88592@latn':                  'sr_CS.ISO8859-2',
  1423.     'sr_cs.iso88595':                       'sr_CS.ISO8859-5',
  1424.     'sr_cs.utf8@latn':                      'sr_RS.UTF-8@latin',
  1425.     'sr_cs@latn':                           'sr_RS.UTF-8@latin',
  1426.     'sr_me':                                'sr_ME.UTF-8',
  1427.     'sr_rs':                                'sr_RS.UTF-8',
  1428.     'sr_rs.utf8@latn':                      'sr_RS.UTF-8@latin',
  1429.     'sr_rs@latin':                          'sr_RS.UTF-8@latin',
  1430.     'sr_rs@latn':                           'sr_RS.UTF-8@latin',
  1431.     'sr_sp':                                'sr_CS.ISO8859-2',
  1432.     'sr_yu':                                'sr_RS.UTF-8@latin',
  1433.     'sr_yu.cp1251@cyrillic':                'sr_CS.CP1251',
  1434.     'sr_yu.iso88592':                       'sr_CS.ISO8859-2',
  1435.     'sr_yu.iso88595':                       'sr_CS.ISO8859-5',
  1436.     'sr_yu.iso88595@cyrillic':              'sr_CS.ISO8859-5',
  1437.     'sr_yu.microsoftcp1251@cyrillic':       'sr_CS.CP1251',
  1438.     'sr_yu.utf8@cyrillic':                  'sr_RS.UTF-8',
  1439.     'sr_yu@cyrillic':                       'sr_RS.UTF-8',
  1440.     'ss':                                   'ss_ZA.ISO8859-1',
  1441.     'ss_za':                                'ss_ZA.ISO8859-1',
  1442.     'ss_za.iso88591':                       'ss_ZA.ISO8859-1',
  1443.     'st':                                   'st_ZA.ISO8859-1',
  1444.     'st_za':                                'st_ZA.ISO8859-1',
  1445.     'st_za.iso88591':                       'st_ZA.ISO8859-1',
  1446.     'sv':                                   'sv_SE.ISO8859-1',
  1447.     'sv.iso885915':                         'sv_SE.ISO8859-15',
  1448.     'sv_fi':                                'sv_FI.ISO8859-1',
  1449.     'sv_fi.iso88591':                       'sv_FI.ISO8859-1',
  1450.     'sv_fi.iso885915':                      'sv_FI.ISO8859-15',
  1451.     'sv_fi.iso885915@euro':                 'sv_FI.ISO8859-15',
  1452.     'sv_fi.utf8@euro':                      'sv_FI.UTF-8',
  1453.     'sv_fi@euro':                           'sv_FI.ISO8859-15',
  1454.     'sv_se':                                'sv_SE.ISO8859-1',
  1455.     'sv_se.88591':                          'sv_SE.ISO8859-1',
  1456.     'sv_se.iso88591':                       'sv_SE.ISO8859-1',
  1457.     'sv_se.iso885915':                      'sv_SE.ISO8859-15',
  1458.     'sv_se@euro':                           'sv_SE.ISO8859-15',
  1459.     'swedish':                              'sv_SE.ISO8859-1',
  1460.     'swedish.iso88591':                     'sv_SE.ISO8859-1',
  1461.     'ta':                                   'ta_IN.TSCII-0',
  1462.     'ta_in':                                'ta_IN.TSCII-0',
  1463.     'ta_in.tscii':                          'ta_IN.TSCII-0',
  1464.     'ta_in.tscii0':                         'ta_IN.TSCII-0',
  1465.     'te':                                   'te_IN.UTF-8',
  1466.     'tg':                                   'tg_TJ.KOI8-C',
  1467.     'tg_tj':                                'tg_TJ.KOI8-C',
  1468.     'tg_tj.koi8c':                          'tg_TJ.KOI8-C',
  1469.     'th':                                   'th_TH.ISO8859-11',
  1470.     'th_th':                                'th_TH.ISO8859-11',
  1471.     'th_th.iso885911':                      'th_TH.ISO8859-11',
  1472.     'th_th.tactis':                         'th_TH.TIS620',
  1473.     'th_th.tis620':                         'th_TH.TIS620',
  1474.     'thai':                                 'th_TH.ISO8859-11',
  1475.     'tl':                                   'tl_PH.ISO8859-1',
  1476.     'tl_ph':                                'tl_PH.ISO8859-1',
  1477.     'tl_ph.iso88591':                       'tl_PH.ISO8859-1',
  1478.     'tn':                                   'tn_ZA.ISO8859-15',
  1479.     'tn_za':                                'tn_ZA.ISO8859-15',
  1480.     'tn_za.iso885915':                      'tn_ZA.ISO8859-15',
  1481.     'tr':                                   'tr_TR.ISO8859-9',
  1482.     'tr_tr':                                'tr_TR.ISO8859-9',
  1483.     'tr_tr.iso88599':                       'tr_TR.ISO8859-9',
  1484.     'ts':                                   'ts_ZA.ISO8859-1',
  1485.     'ts_za':                                'ts_ZA.ISO8859-1',
  1486.     'ts_za.iso88591':                       'ts_ZA.ISO8859-1',
  1487.     'tt':                                   'tt_RU.TATAR-CYR',
  1488.     'tt_ru':                                'tt_RU.TATAR-CYR',
  1489.     'tt_ru.koi8c':                          'tt_RU.KOI8-C',
  1490.     'tt_ru.tatarcyr':                       'tt_RU.TATAR-CYR',
  1491.     'turkish':                              'tr_TR.ISO8859-9',
  1492.     'turkish.iso88599':                     'tr_TR.ISO8859-9',
  1493.     'uk':                                   'uk_UA.KOI8-U',
  1494.     'uk_ua':                                'uk_UA.KOI8-U',
  1495.     'uk_ua.cp1251':                         'uk_UA.CP1251',
  1496.     'uk_ua.iso88595':                       'uk_UA.ISO8859-5',
  1497.     'uk_ua.koi8u':                          'uk_UA.KOI8-U',
  1498.     'uk_ua.microsoftcp1251':                'uk_UA.CP1251',
  1499.     'univ':                                 'en_US.UTF-8',
  1500.     'universal':                            'en_US.UTF-8',
  1501.     'universal.utf8@ucs4':                  'en_US.UTF-8',
  1502.     'ur':                                   'ur_PK.CP1256',
  1503.     'ur_pk':                                'ur_PK.CP1256',
  1504.     'ur_pk.cp1256':                         'ur_PK.CP1256',
  1505.     'ur_pk.microsoftcp1256':                'ur_PK.CP1256',
  1506.     'uz':                                   'uz_UZ.UTF-8',
  1507.     'uz_uz':                                'uz_UZ.UTF-8',
  1508.     'uz_uz.iso88591':                       'uz_UZ.ISO8859-1',
  1509.     'uz_uz.utf8@cyrillic':                  'uz_UZ.UTF-8',
  1510.     'uz_uz@cyrillic':                       'uz_UZ.UTF-8',
  1511.     've':                                   've_ZA.UTF-8',
  1512.     've_za':                                've_ZA.UTF-8',
  1513.     'vi':                                   'vi_VN.TCVN',
  1514.     'vi_vn':                                'vi_VN.TCVN',
  1515.     'vi_vn.tcvn':                           'vi_VN.TCVN',
  1516.     'vi_vn.tcvn5712':                       'vi_VN.TCVN',
  1517.     'vi_vn.viscii':                         'vi_VN.VISCII',
  1518.     'vi_vn.viscii111':                      'vi_VN.VISCII',
  1519.     'wa':                                   'wa_BE.ISO8859-1',
  1520.     'wa_be':                                'wa_BE.ISO8859-1',
  1521.     'wa_be.iso88591':                       'wa_BE.ISO8859-1',
  1522.     'wa_be.iso885915':                      'wa_BE.ISO8859-15',
  1523.     'wa_be.iso885915@euro':                 'wa_BE.ISO8859-15',
  1524.     'wa_be@euro':                           'wa_BE.ISO8859-15',
  1525.     'xh':                                   'xh_ZA.ISO8859-1',
  1526.     'xh_za':                                'xh_ZA.ISO8859-1',
  1527.     'xh_za.iso88591':                       'xh_ZA.ISO8859-1',
  1528.     'yi':                                   'yi_US.CP1255',
  1529.     'yi_us':                                'yi_US.CP1255',
  1530.     'yi_us.cp1255':                         'yi_US.CP1255',
  1531.     'yi_us.microsoftcp1255':                'yi_US.CP1255',
  1532.     'zh':                                   'zh_CN.eucCN',
  1533.     'zh_cn':                                'zh_CN.gb2312',
  1534.     'zh_cn.big5':                           'zh_TW.big5',
  1535.     'zh_cn.euc':                            'zh_CN.eucCN',
  1536.     'zh_cn.gb18030':                        'zh_CN.gb18030',
  1537.     'zh_cn.gb2312':                         'zh_CN.gb2312',
  1538.     'zh_cn.gbk':                            'zh_CN.gbk',
  1539.     'zh_hk':                                'zh_HK.big5hkscs',
  1540.     'zh_hk.big5':                           'zh_HK.big5',
  1541.     'zh_hk.big5hk':                         'zh_HK.big5hkscs',
  1542.     'zh_hk.big5hkscs':                      'zh_HK.big5hkscs',
  1543.     'zh_tw':                                'zh_TW.big5',
  1544.     'zh_tw.big5':                           'zh_TW.big5',
  1545.     'zh_tw.euc':                            'zh_TW.eucTW',
  1546.     'zh_tw.euctw':                          'zh_TW.eucTW',
  1547.     'zu':                                   'zu_ZA.ISO8859-1',
  1548.     'zu_za':                                'zu_ZA.ISO8859-1',
  1549.     'zu_za.iso88591':                       'zu_ZA.ISO8859-1',
  1550. }
  1551.  
  1552. #
  1553. # This maps Windows language identifiers to locale strings.
  1554. #
  1555. # This list has been updated from
  1556. # http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nls_238z.asp
  1557. # to include every locale up to Windows Vista.
  1558. #
  1559. # NOTE: this mapping is incomplete.  If your language is missing, please
  1560. # submit a bug report to Python bug manager, which you can find via:
  1561. #     http://www.python.org/dev/
  1562. # Make sure you include the missing language identifier and the suggested
  1563. # locale code.
  1564. #
  1565.  
  1566. windows_locale = {
  1567.     0x0436: "af_ZA", # Afrikaans
  1568.     0x041c: "sq_AL", # Albanian
  1569.     0x0484: "gsw_FR",# Alsatian - France
  1570.     0x045e: "am_ET", # Amharic - Ethiopia
  1571.     0x0401: "ar_SA", # Arabic - Saudi Arabia
  1572.     0x0801: "ar_IQ", # Arabic - Iraq
  1573.     0x0c01: "ar_EG", # Arabic - Egypt
  1574.     0x1001: "ar_LY", # Arabic - Libya
  1575.     0x1401: "ar_DZ", # Arabic - Algeria
  1576.     0x1801: "ar_MA", # Arabic - Morocco
  1577.     0x1c01: "ar_TN", # Arabic - Tunisia
  1578.     0x2001: "ar_OM", # Arabic - Oman
  1579.     0x2401: "ar_YE", # Arabic - Yemen
  1580.     0x2801: "ar_SY", # Arabic - Syria
  1581.     0x2c01: "ar_JO", # Arabic - Jordan
  1582.     0x3001: "ar_LB", # Arabic - Lebanon
  1583.     0x3401: "ar_KW", # Arabic - Kuwait
  1584.     0x3801: "ar_AE", # Arabic - United Arab Emirates
  1585.     0x3c01: "ar_BH", # Arabic - Bahrain
  1586.     0x4001: "ar_QA", # Arabic - Qatar
  1587.     0x042b: "hy_AM", # Armenian
  1588.     0x044d: "as_IN", # Assamese - India
  1589.     0x042c: "az_AZ", # Azeri - Latin
  1590.     0x082c: "az_AZ", # Azeri - Cyrillic
  1591.     0x046d: "ba_RU", # Bashkir
  1592.     0x042d: "eu_ES", # Basque - Russia
  1593.     0x0423: "be_BY", # Belarusian
  1594.     0x0445: "bn_IN", # Begali
  1595.     0x201a: "bs_BA", # Bosnian - Cyrillic
  1596.     0x141a: "bs_BA", # Bosnian - Latin
  1597.     0x047e: "br_FR", # Breton - France
  1598.     0x0402: "bg_BG", # Bulgarian
  1599. #    0x0455: "my_MM", # Burmese - Not supported
  1600.     0x0403: "ca_ES", # Catalan
  1601.     0x0004: "zh_CHS",# Chinese - Simplified
  1602.     0x0404: "zh_TW", # Chinese - Taiwan
  1603.     0x0804: "zh_CN", # Chinese - PRC
  1604.     0x0c04: "zh_HK", # Chinese - Hong Kong S.A.R.
  1605.     0x1004: "zh_SG", # Chinese - Singapore
  1606.     0x1404: "zh_MO", # Chinese - Macao S.A.R.
  1607.     0x7c04: "zh_CHT",# Chinese - Traditional
  1608.     0x0483: "co_FR", # Corsican - France
  1609.     0x041a: "hr_HR", # Croatian
  1610.     0x101a: "hr_BA", # Croatian - Bosnia
  1611.     0x0405: "cs_CZ", # Czech
  1612.     0x0406: "da_DK", # Danish
  1613.     0x048c: "gbz_AF",# Dari - Afghanistan
  1614.     0x0465: "div_MV",# Divehi - Maldives
  1615.     0x0413: "nl_NL", # Dutch - The Netherlands
  1616.     0x0813: "nl_BE", # Dutch - Belgium
  1617.     0x0409: "en_US", # English - United States
  1618.     0x0809: "en_GB", # English - United Kingdom
  1619.     0x0c09: "en_AU", # English - Australia
  1620.     0x1009: "en_CA", # English - Canada
  1621.     0x1409: "en_NZ", # English - New Zealand
  1622.     0x1809: "en_IE", # English - Ireland
  1623.     0x1c09: "en_ZA", # English - South Africa
  1624.     0x2009: "en_JA", # English - Jamaica
  1625.     0x2409: "en_CB", # English - Carribbean
  1626.     0x2809: "en_BZ", # English - Belize
  1627.     0x2c09: "en_TT", # English - Trinidad
  1628.     0x3009: "en_ZW", # English - Zimbabwe
  1629.     0x3409: "en_PH", # English - Philippines
  1630.     0x4009: "en_IN", # English - India
  1631.     0x4409: "en_MY", # English - Malaysia
  1632.     0x4809: "en_IN", # English - Singapore
  1633.     0x0425: "et_EE", # Estonian
  1634.     0x0438: "fo_FO", # Faroese
  1635.     0x0464: "fil_PH",# Filipino
  1636.     0x040b: "fi_FI", # Finnish
  1637.     0x040c: "fr_FR", # French - France
  1638.     0x080c: "fr_BE", # French - Belgium
  1639.     0x0c0c: "fr_CA", # French - Canada
  1640.     0x100c: "fr_CH", # French - Switzerland
  1641.     0x140c: "fr_LU", # French - Luxembourg
  1642.     0x180c: "fr_MC", # French - Monaco
  1643.     0x0462: "fy_NL", # Frisian - Netherlands
  1644.     0x0456: "gl_ES", # Galician
  1645.     0x0437: "ka_GE", # Georgian
  1646.     0x0407: "de_DE", # German - Germany
  1647.     0x0807: "de_CH", # German - Switzerland
  1648.     0x0c07: "de_AT", # German - Austria
  1649.     0x1007: "de_LU", # German - Luxembourg
  1650.     0x1407: "de_LI", # German - Liechtenstein
  1651.     0x0408: "el_GR", # Greek
  1652.     0x046f: "kl_GL", # Greenlandic - Greenland
  1653.     0x0447: "gu_IN", # Gujarati
  1654.     0x0468: "ha_NG", # Hausa - Latin
  1655.     0x040d: "he_IL", # Hebrew
  1656.     0x0439: "hi_IN", # Hindi
  1657.     0x040e: "hu_HU", # Hungarian
  1658.     0x040f: "is_IS", # Icelandic
  1659.     0x0421: "id_ID", # Indonesian
  1660.     0x045d: "iu_CA", # Inuktitut - Syllabics
  1661.     0x085d: "iu_CA", # Inuktitut - Latin
  1662.     0x083c: "ga_IE", # Irish - Ireland
  1663.     0x0410: "it_IT", # Italian - Italy
  1664.     0x0810: "it_CH", # Italian - Switzerland
  1665.     0x0411: "ja_JP", # Japanese
  1666.     0x044b: "kn_IN", # Kannada - India
  1667.     0x043f: "kk_KZ", # Kazakh
  1668.     0x0453: "kh_KH", # Khmer - Cambodia
  1669.     0x0486: "qut_GT",# K'iche - Guatemala
  1670.     0x0487: "rw_RW", # Kinyarwanda - Rwanda
  1671.     0x0457: "kok_IN",# Konkani
  1672.     0x0412: "ko_KR", # Korean
  1673.     0x0440: "ky_KG", # Kyrgyz
  1674.     0x0454: "lo_LA", # Lao - Lao PDR
  1675.     0x0426: "lv_LV", # Latvian
  1676.     0x0427: "lt_LT", # Lithuanian
  1677.     0x082e: "dsb_DE",# Lower Sorbian - Germany
  1678.     0x046e: "lb_LU", # Luxembourgish
  1679.     0x042f: "mk_MK", # FYROM Macedonian
  1680.     0x043e: "ms_MY", # Malay - Malaysia
  1681.     0x083e: "ms_BN", # Malay - Brunei Darussalam
  1682.     0x044c: "ml_IN", # Malayalam - India
  1683.     0x043a: "mt_MT", # Maltese
  1684.     0x0481: "mi_NZ", # Maori
  1685.     0x047a: "arn_CL",# Mapudungun
  1686.     0x044e: "mr_IN", # Marathi
  1687.     0x047c: "moh_CA",# Mohawk - Canada
  1688.     0x0450: "mn_MN", # Mongolian - Cyrillic
  1689.     0x0850: "mn_CN", # Mongolian - PRC
  1690.     0x0461: "ne_NP", # Nepali
  1691.     0x0414: "nb_NO", # Norwegian - Bokmal
  1692.     0x0814: "nn_NO", # Norwegian - Nynorsk
  1693.     0x0482: "oc_FR", # Occitan - France
  1694.     0x0448: "or_IN", # Oriya - India
  1695.     0x0463: "ps_AF", # Pashto - Afghanistan
  1696.     0x0429: "fa_IR", # Persian
  1697.     0x0415: "pl_PL", # Polish
  1698.     0x0416: "pt_BR", # Portuguese - Brazil
  1699.     0x0816: "pt_PT", # Portuguese - Portugal
  1700.     0x0446: "pa_IN", # Punjabi
  1701.     0x046b: "quz_BO",# Quechua (Bolivia)
  1702.     0x086b: "quz_EC",# Quechua (Ecuador)
  1703.     0x0c6b: "quz_PE",# Quechua (Peru)
  1704.     0x0418: "ro_RO", # Romanian - Romania
  1705.     0x0417: "rm_CH", # Romansh
  1706.     0x0419: "ru_RU", # Russian
  1707.     0x243b: "smn_FI",# Sami Finland
  1708.     0x103b: "smj_NO",# Sami Norway
  1709.     0x143b: "smj_SE",# Sami Sweden
  1710.     0x043b: "se_NO", # Sami Northern Norway
  1711.     0x083b: "se_SE", # Sami Northern Sweden
  1712.     0x0c3b: "se_FI", # Sami Northern Finland
  1713.     0x203b: "sms_FI",# Sami Skolt
  1714.     0x183b: "sma_NO",# Sami Southern Norway
  1715.     0x1c3b: "sma_SE",# Sami Southern Sweden
  1716.     0x044f: "sa_IN", # Sanskrit
  1717.     0x0c1a: "sr_SP", # Serbian - Cyrillic
  1718.     0x1c1a: "sr_BA", # Serbian - Bosnia Cyrillic
  1719.     0x081a: "sr_SP", # Serbian - Latin
  1720.     0x181a: "sr_BA", # Serbian - Bosnia Latin
  1721.     0x045b: "si_LK", # Sinhala - Sri Lanka
  1722.     0x046c: "ns_ZA", # Northern Sotho
  1723.     0x0432: "tn_ZA", # Setswana - Southern Africa
  1724.     0x041b: "sk_SK", # Slovak
  1725.     0x0424: "sl_SI", # Slovenian
  1726.     0x040a: "es_ES", # Spanish - Spain
  1727.     0x080a: "es_MX", # Spanish - Mexico
  1728.     0x0c0a: "es_ES", # Spanish - Spain (Modern)
  1729.     0x100a: "es_GT", # Spanish - Guatemala
  1730.     0x140a: "es_CR", # Spanish - Costa Rica
  1731.     0x180a: "es_PA", # Spanish - Panama
  1732.     0x1c0a: "es_DO", # Spanish - Dominican Republic
  1733.     0x200a: "es_VE", # Spanish - Venezuela
  1734.     0x240a: "es_CO", # Spanish - Colombia
  1735.     0x280a: "es_PE", # Spanish - Peru
  1736.     0x2c0a: "es_AR", # Spanish - Argentina
  1737.     0x300a: "es_EC", # Spanish - Ecuador
  1738.     0x340a: "es_CL", # Spanish - Chile
  1739.     0x380a: "es_UR", # Spanish - Uruguay
  1740.     0x3c0a: "es_PY", # Spanish - Paraguay
  1741.     0x400a: "es_BO", # Spanish - Bolivia
  1742.     0x440a: "es_SV", # Spanish - El Salvador
  1743.     0x480a: "es_HN", # Spanish - Honduras
  1744.     0x4c0a: "es_NI", # Spanish - Nicaragua
  1745.     0x500a: "es_PR", # Spanish - Puerto Rico
  1746.     0x540a: "es_US", # Spanish - United States
  1747. #    0x0430: "", # Sutu - Not supported
  1748.     0x0441: "sw_KE", # Swahili
  1749.     0x041d: "sv_SE", # Swedish - Sweden
  1750.     0x081d: "sv_FI", # Swedish - Finland
  1751.     0x045a: "syr_SY",# Syriac
  1752.     0x0428: "tg_TJ", # Tajik - Cyrillic
  1753.     0x085f: "tmz_DZ",# Tamazight - Latin
  1754.     0x0449: "ta_IN", # Tamil
  1755.     0x0444: "tt_RU", # Tatar
  1756.     0x044a: "te_IN", # Telugu
  1757.     0x041e: "th_TH", # Thai
  1758.     0x0851: "bo_BT", # Tibetan - Bhutan
  1759.     0x0451: "bo_CN", # Tibetan - PRC
  1760.     0x041f: "tr_TR", # Turkish
  1761.     0x0442: "tk_TM", # Turkmen - Cyrillic
  1762.     0x0480: "ug_CN", # Uighur - Arabic
  1763.     0x0422: "uk_UA", # Ukrainian
  1764.     0x042e: "wen_DE",# Upper Sorbian - Germany
  1765.     0x0420: "ur_PK", # Urdu
  1766.     0x0820: "ur_IN", # Urdu - India
  1767.     0x0443: "uz_UZ", # Uzbek - Latin
  1768.     0x0843: "uz_UZ", # Uzbek - Cyrillic
  1769.     0x042a: "vi_VN", # Vietnamese
  1770.     0x0452: "cy_GB", # Welsh
  1771.     0x0488: "wo_SN", # Wolof - Senegal
  1772.     0x0434: "xh_ZA", # Xhosa - South Africa
  1773.     0x0485: "sah_RU",# Yakut - Cyrillic
  1774.     0x0478: "ii_CN", # Yi - PRC
  1775.     0x046a: "yo_NG", # Yoruba - Nigeria
  1776.     0x0435: "zu_ZA", # Zulu
  1777. }
  1778.  
  1779. def _print_locale():
  1780.  
  1781.     """ Test function.
  1782.     """
  1783.     categories = {}
  1784.     def _init_categories(categories=categories):
  1785.         for k,v in globals().items():
  1786.             if k[:3] == 'LC_':
  1787.                 categories[k] = v
  1788.     _init_categories()
  1789.     del categories['LC_ALL']
  1790.  
  1791.     print 'Locale defaults as determined by getdefaultlocale():'
  1792.     print '-'*72
  1793.     lang, enc = getdefaultlocale()
  1794.     print 'Language: ', lang or '(undefined)'
  1795.     print 'Encoding: ', enc or '(undefined)'
  1796.     print
  1797.  
  1798.     print 'Locale settings on startup:'
  1799.     print '-'*72
  1800.     for name,category in categories.items():
  1801.         print name, '...'
  1802.         lang, enc = getlocale(category)
  1803.         print '   Language: ', lang or '(undefined)'
  1804.         print '   Encoding: ', enc or '(undefined)'
  1805.         print
  1806.  
  1807.     print
  1808.     print 'Locale settings after calling resetlocale():'
  1809.     print '-'*72
  1810.     resetlocale()
  1811.     for name,category in categories.items():
  1812.         print name, '...'
  1813.         lang, enc = getlocale(category)
  1814.         print '   Language: ', lang or '(undefined)'
  1815.         print '   Encoding: ', enc or '(undefined)'
  1816.         print
  1817.  
  1818.     try:
  1819.         setlocale(LC_ALL, "")
  1820.     except:
  1821.         print 'NOTE:'
  1822.         print 'setlocale(LC_ALL, "") does not support the default locale'
  1823.         print 'given in the OS environment variables.'
  1824.     else:
  1825.         print
  1826.         print 'Locale settings after calling setlocale(LC_ALL, ""):'
  1827.         print '-'*72
  1828.         for name,category in categories.items():
  1829.             print name, '...'
  1830.             lang, enc = getlocale(category)
  1831.             print '   Language: ', lang or '(undefined)'
  1832.             print '   Encoding: ', enc or '(undefined)'
  1833.             print
  1834.  
  1835. ###
  1836.  
  1837. try:
  1838.     LC_MESSAGES
  1839. except NameError:
  1840.     pass
  1841. else:
  1842.     __all__.append("LC_MESSAGES")
  1843.  
  1844. if __name__=='__main__':
  1845.     print 'Locale aliasing:'
  1846.     print
  1847.     _print_locale()
  1848.     print
  1849.     print 'Number formatting:'
  1850.     print
  1851.     _test()
  1852.