• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1"""Locale support module.
2
3The module provides low-level access to the C lib's locale APIs and adds high
4level number formatting APIs as well as a locale aliasing engine to complement
5these.
6
7The aliasing engine includes support for many commonly used locale names and
8maps them to values suitable for passing to the C lib's setlocale() function. It
9also includes default encodings for all supported locale names.
10"""
11
12import sys
13import encodings
14import encodings.aliases
15import re
16import operator
17import functools
18
19# keep a copy of the builtin str type, because 'str' name is overridden
20# in globals by a function below
21_str = str
22
23try:
24    _unicode = unicode
25except NameError:
26    # If Python is built without Unicode support, the unicode type
27    # will not exist. Fake one.
28    class _unicode(object):
29        pass
30
31# Try importing the _locale module.
32#
33# If this fails, fall back on a basic 'C' locale emulation.
34
35# Yuck:  LC_MESSAGES is non-standard:  can't tell whether it exists before
36# trying the import.  So __all__ is also fiddled at the end of the file.
37__all__ = ["getlocale", "getdefaultlocale", "getpreferredencoding", "Error",
38           "setlocale", "resetlocale", "localeconv", "strcoll", "strxfrm",
39           "str", "atof", "atoi", "format", "format_string", "currency",
40           "normalize", "LC_CTYPE", "LC_COLLATE", "LC_TIME", "LC_MONETARY",
41           "LC_NUMERIC", "LC_ALL", "CHAR_MAX"]
42
43try:
44
45    from _locale import *
46
47except ImportError:
48
49    # Locale emulation
50
51    CHAR_MAX = 127
52    LC_ALL = 6
53    LC_COLLATE = 3
54    LC_CTYPE = 0
55    LC_MESSAGES = 5
56    LC_MONETARY = 4
57    LC_NUMERIC = 1
58    LC_TIME = 2
59    Error = ValueError
60
61    def localeconv():
62        """ localeconv() -> dict.
63            Returns numeric and monetary locale-specific parameters.
64        """
65        # 'C' locale default values
66        return {'grouping': [127],
67                'currency_symbol': '',
68                'n_sign_posn': 127,
69                'p_cs_precedes': 127,
70                'n_cs_precedes': 127,
71                'mon_grouping': [],
72                'n_sep_by_space': 127,
73                'decimal_point': '.',
74                'negative_sign': '',
75                'positive_sign': '',
76                'p_sep_by_space': 127,
77                'int_curr_symbol': '',
78                'p_sign_posn': 127,
79                'thousands_sep': '',
80                'mon_thousands_sep': '',
81                'frac_digits': 127,
82                'mon_decimal_point': '',
83                'int_frac_digits': 127}
84
85    def setlocale(category, value=None):
86        """ setlocale(integer,string=None) -> string.
87            Activates/queries locale processing.
88        """
89        if value not in (None, '', 'C'):
90            raise Error, '_locale emulation only supports "C" locale'
91        return 'C'
92
93    def strcoll(a,b):
94        """ strcoll(string,string) -> int.
95            Compares two strings according to the locale.
96        """
97        return cmp(a,b)
98
99    def strxfrm(s):
100        """ strxfrm(string) -> string.
101            Returns a string that behaves for cmp locale-aware.
102        """
103        return s
104
105
106_localeconv = localeconv
107
108# With this dict, you can override some items of localeconv's return value.
109# This is useful for testing purposes.
110_override_localeconv = {}
111
112@functools.wraps(_localeconv)
113def localeconv():
114    d = _localeconv()
115    if _override_localeconv:
116        d.update(_override_localeconv)
117    return d
118
119
120### Number formatting APIs
121
122# Author: Martin von Loewis
123# improved by Georg Brandl
124
125# Iterate over grouping intervals
126def _grouping_intervals(grouping):
127    last_interval = None
128    for interval in grouping:
129        # if grouping is -1, we are done
130        if interval == CHAR_MAX:
131            return
132        # 0: re-use last group ad infinitum
133        if interval == 0:
134            if last_interval is None:
135                raise ValueError("invalid grouping")
136            while True:
137                yield last_interval
138        yield interval
139        last_interval = interval
140
141#perform the grouping from right to left
142def _group(s, monetary=False):
143    conv = localeconv()
144    thousands_sep = conv[monetary and 'mon_thousands_sep' or 'thousands_sep']
145    grouping = conv[monetary and 'mon_grouping' or 'grouping']
146    if not grouping:
147        return (s, 0)
148    if s[-1] == ' ':
149        stripped = s.rstrip()
150        right_spaces = s[len(stripped):]
151        s = stripped
152    else:
153        right_spaces = ''
154    left_spaces = ''
155    groups = []
156    for interval in _grouping_intervals(grouping):
157        if not s or s[-1] not in "0123456789":
158            # only non-digit characters remain (sign, spaces)
159            left_spaces = s
160            s = ''
161            break
162        groups.append(s[-interval:])
163        s = s[:-interval]
164    if s:
165        groups.append(s)
166    groups.reverse()
167    return (
168        left_spaces + thousands_sep.join(groups) + right_spaces,
169        len(thousands_sep) * (len(groups) - 1)
170    )
171
172# Strip a given amount of excess padding from the given string
173def _strip_padding(s, amount):
174    lpos = 0
175    while amount and s[lpos] == ' ':
176        lpos += 1
177        amount -= 1
178    rpos = len(s) - 1
179    while amount and s[rpos] == ' ':
180        rpos -= 1
181        amount -= 1
182    return s[lpos:rpos+1]
183
184_percent_re = re.compile(r'%(?:\((?P<key>.*?)\))?'
185                         r'(?P<modifiers>[-#0-9 +*.hlL]*?)[eEfFgGdiouxXcrs%]')
186
187def format(percent, value, grouping=False, monetary=False, *additional):
188    """Returns the locale-aware substitution of a %? specifier
189    (percent).
190
191    additional is for format strings which contain one or more
192    '*' modifiers."""
193    # this is only for one-percent-specifier strings and this should be checked
194    match = _percent_re.match(percent)
195    if not match or len(match.group())!= len(percent):
196        raise ValueError(("format() must be given exactly one %%char "
197                         "format specifier, %s not valid") % repr(percent))
198    return _format(percent, value, grouping, monetary, *additional)
199
200def _format(percent, value, grouping=False, monetary=False, *additional):
201    if additional:
202        formatted = percent % ((value,) + additional)
203    else:
204        formatted = percent % value
205    # floats and decimal ints need special action!
206    if percent[-1] in 'eEfFgG':
207        seps = 0
208        parts = formatted.split('.')
209        if grouping:
210            parts[0], seps = _group(parts[0], monetary=monetary)
211        decimal_point = localeconv()[monetary and 'mon_decimal_point'
212                                              or 'decimal_point']
213        formatted = decimal_point.join(parts)
214        if seps:
215            formatted = _strip_padding(formatted, seps)
216    elif percent[-1] in 'diu':
217        seps = 0
218        if grouping:
219            formatted, seps = _group(formatted, monetary=monetary)
220        if seps:
221            formatted = _strip_padding(formatted, seps)
222    return formatted
223
224def format_string(f, val, grouping=False):
225    """Formats a string in the same way that the % formatting would use,
226    but takes the current locale into account.
227    Grouping is applied if the third parameter is true."""
228    percents = list(_percent_re.finditer(f))
229    new_f = _percent_re.sub('%s', f)
230
231    if operator.isMappingType(val):
232        new_val = []
233        for perc in percents:
234            if perc.group()[-1]=='%':
235                new_val.append('%')
236            else:
237                new_val.append(format(perc.group(), val, grouping))
238    else:
239        if not isinstance(val, tuple):
240            val = (val,)
241        new_val = []
242        i = 0
243        for perc in percents:
244            if perc.group()[-1]=='%':
245                new_val.append('%')
246            else:
247                starcount = perc.group('modifiers').count('*')
248                new_val.append(_format(perc.group(),
249                                      val[i],
250                                      grouping,
251                                      False,
252                                      *val[i+1:i+1+starcount]))
253                i += (1 + starcount)
254    val = tuple(new_val)
255
256    return new_f % val
257
258def currency(val, symbol=True, grouping=False, international=False):
259    """Formats val according to the currency settings
260    in the current locale."""
261    conv = localeconv()
262
263    # check for illegal values
264    digits = conv[international and 'int_frac_digits' or 'frac_digits']
265    if digits == 127:
266        raise ValueError("Currency formatting is not possible using "
267                         "the 'C' locale.")
268
269    s = format('%%.%if' % digits, abs(val), grouping, monetary=True)
270    # '<' and '>' are markers if the sign must be inserted between symbol and value
271    s = '<' + s + '>'
272
273    if symbol:
274        smb = conv[international and 'int_curr_symbol' or 'currency_symbol']
275        precedes = conv[val<0 and 'n_cs_precedes' or 'p_cs_precedes']
276        separated = conv[val<0 and 'n_sep_by_space' or 'p_sep_by_space']
277
278        if precedes:
279            s = smb + (separated and ' ' or '') + s
280        else:
281            s = s + (separated and ' ' or '') + smb
282
283    sign_pos = conv[val<0 and 'n_sign_posn' or 'p_sign_posn']
284    sign = conv[val<0 and 'negative_sign' or 'positive_sign']
285
286    if sign_pos == 0:
287        s = '(' + s + ')'
288    elif sign_pos == 1:
289        s = sign + s
290    elif sign_pos == 2:
291        s = s + sign
292    elif sign_pos == 3:
293        s = s.replace('<', sign)
294    elif sign_pos == 4:
295        s = s.replace('>', sign)
296    else:
297        # the default if nothing specified;
298        # this should be the most fitting sign position
299        s = sign + s
300
301    return s.replace('<', '').replace('>', '')
302
303def str(val):
304    """Convert float to string, taking the locale into account."""
305    return format("%.12g", val)
306
307def atof(string, func=float):
308    "Parses a string as a float according to the locale settings."
309    #First, get rid of the grouping
310    ts = localeconv()['thousands_sep']
311    if ts:
312        string = string.replace(ts, '')
313    #next, replace the decimal point with a dot
314    dd = localeconv()['decimal_point']
315    if dd:
316        string = string.replace(dd, '.')
317    #finally, parse the string
318    return func(string)
319
320def atoi(str):
321    "Converts a string to an integer according to the locale settings."
322    return atof(str, int)
323
324def _test():
325    setlocale(LC_ALL, "")
326    #do grouping
327    s1 = format("%d", 123456789,1)
328    print s1, "is", atoi(s1)
329    #standard formatting
330    s1 = str(3.14)
331    print s1, "is", atof(s1)
332
333### Locale name aliasing engine
334
335# Author: Marc-Andre Lemburg, mal@lemburg.com
336# Various tweaks by Fredrik Lundh <fredrik@pythonware.com>
337
338# store away the low-level version of setlocale (it's
339# overridden below)
340_setlocale = setlocale
341
342# Avoid relying on the locale-dependent .lower() method
343# (see issue #1813).
344_ascii_lower_map = ''.join(
345    chr(x + 32 if x >= ord('A') and x <= ord('Z') else x)
346    for x in range(256)
347)
348
349def _replace_encoding(code, encoding):
350    if '.' in code:
351        langname = code[:code.index('.')]
352    else:
353        langname = code
354    # Convert the encoding to a C lib compatible encoding string
355    norm_encoding = encodings.normalize_encoding(encoding)
356    #print('norm encoding: %r' % norm_encoding)
357    norm_encoding = encodings.aliases.aliases.get(norm_encoding,
358                                                  norm_encoding)
359    #print('aliased encoding: %r' % norm_encoding)
360    encoding = locale_encoding_alias.get(norm_encoding,
361                                         norm_encoding)
362    #print('found encoding %r' % encoding)
363    return langname + '.' + encoding
364
365def normalize(localename):
366
367    """ Returns a normalized locale code for the given locale
368        name.
369
370        The returned locale code is formatted for use with
371        setlocale().
372
373        If normalization fails, the original name is returned
374        unchanged.
375
376        If the given encoding is not known, the function defaults to
377        the default encoding for the locale code just like setlocale()
378        does.
379
380    """
381    # Normalize the locale name and extract the encoding and modifier
382    if isinstance(localename, _unicode):
383        localename = localename.encode('ascii')
384    code = localename.translate(_ascii_lower_map)
385    if ':' in code:
386        # ':' is sometimes used as encoding delimiter.
387        code = code.replace(':', '.')
388    if '@' in code:
389        code, modifier = code.split('@', 1)
390    else:
391        modifier = ''
392    if '.' in code:
393        langname, encoding = code.split('.')[:2]
394    else:
395        langname = code
396        encoding = ''
397
398    # First lookup: fullname (possibly with encoding and modifier)
399    lang_enc = langname
400    if encoding:
401        norm_encoding = encoding.replace('-', '')
402        norm_encoding = norm_encoding.replace('_', '')
403        lang_enc += '.' + norm_encoding
404    lookup_name = lang_enc
405    if modifier:
406        lookup_name += '@' + modifier
407    code = locale_alias.get(lookup_name, None)
408    if code is not None:
409        return code
410    #print('first lookup failed')
411
412    if modifier:
413        # Second try: fullname without modifier (possibly with encoding)
414        code = locale_alias.get(lang_enc, None)
415        if code is not None:
416            #print('lookup without modifier succeeded')
417            if '@' not in code:
418                return code + '@' + modifier
419            if code.split('@', 1)[1].translate(_ascii_lower_map) == modifier:
420                return code
421        #print('second lookup failed')
422
423    if encoding:
424        # Third try: langname (without encoding, possibly with modifier)
425        lookup_name = langname
426        if modifier:
427            lookup_name += '@' + modifier
428        code = locale_alias.get(lookup_name, None)
429        if code is not None:
430            #print('lookup without encoding succeeded')
431            if '@' not in code:
432                return _replace_encoding(code, encoding)
433            code, modifier = code.split('@', 1)
434            return _replace_encoding(code, encoding) + '@' + modifier
435
436        if modifier:
437            # Fourth try: langname (without encoding and modifier)
438            code = locale_alias.get(langname, None)
439            if code is not None:
440                #print('lookup without modifier and encoding succeeded')
441                if '@' not in code:
442                    return _replace_encoding(code, encoding) + '@' + modifier
443                code, defmod = code.split('@', 1)
444                if defmod.translate(_ascii_lower_map) == modifier:
445                    return _replace_encoding(code, encoding) + '@' + defmod
446
447    return localename
448
449def _parse_localename(localename):
450
451    """ Parses the locale code for localename and returns the
452        result as tuple (language code, encoding).
453
454        The localename is normalized and passed through the locale
455        alias engine. A ValueError is raised in case the locale name
456        cannot be parsed.
457
458        The language code corresponds to RFC 1766.  code and encoding
459        can be None in case the values cannot be determined or are
460        unknown to this implementation.
461
462    """
463    code = normalize(localename)
464    if '@' in code:
465        # Deal with locale modifiers
466        code, modifier = code.split('@', 1)
467        if modifier == 'euro' and '.' not in code:
468            # Assume Latin-9 for @euro locales. This is bogus,
469            # since some systems may use other encodings for these
470            # locales. Also, we ignore other modifiers.
471            return code, 'iso-8859-15'
472
473    if '.' in code:
474        return tuple(code.split('.')[:2])
475    elif code == 'C':
476        return None, None
477    raise ValueError, 'unknown locale: %s' % localename
478
479def _build_localename(localetuple):
480
481    """ Builds a locale code from the given tuple (language code,
482        encoding).
483
484        No aliasing or normalizing takes place.
485
486    """
487    language, encoding = localetuple
488    if language is None:
489        language = 'C'
490    if encoding is None:
491        return language
492    else:
493        return language + '.' + encoding
494
495def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
496
497    """ Tries to determine the default locale settings and returns
498        them as tuple (language code, encoding).
499
500        According to POSIX, a program which has not called
501        setlocale(LC_ALL, "") runs using the portable 'C' locale.
502        Calling setlocale(LC_ALL, "") lets it use the default locale as
503        defined by the LANG variable. Since we don't want to interfere
504        with the current locale setting we thus emulate the behavior
505        in the way described above.
506
507        To maintain compatibility with other platforms, not only the
508        LANG variable is tested, but a list of variables given as
509        envvars parameter. The first found to be defined will be
510        used. envvars defaults to the search path used in GNU gettext;
511        it must always contain the variable name 'LANG'.
512
513        Except for the code 'C', the language code corresponds to RFC
514        1766.  code and encoding can be None in case the values cannot
515        be determined.
516
517    """
518
519    try:
520        # check if it's supported by the _locale module
521        import _locale
522        code, encoding = _locale._getdefaultlocale()
523    except (ImportError, AttributeError):
524        pass
525    else:
526        # make sure the code/encoding values are valid
527        if sys.platform == "win32" and code and code[:2] == "0x":
528            # map windows language identifier to language name
529            code = windows_locale.get(int(code, 0))
530        # ...add other platform-specific processing here, if
531        # necessary...
532        return code, encoding
533
534    # fall back on POSIX behaviour
535    import os
536    lookup = os.environ.get
537    for variable in envvars:
538        localename = lookup(variable,None)
539        if localename:
540            if variable == 'LANGUAGE':
541                localename = localename.split(':')[0]
542            break
543    else:
544        localename = 'C'
545    return _parse_localename(localename)
546
547
548def getlocale(category=LC_CTYPE):
549
550    """ Returns the current setting for the given locale category as
551        tuple (language code, encoding).
552
553        category may be one of the LC_* value except LC_ALL. It
554        defaults to LC_CTYPE.
555
556        Except for the code 'C', the language code corresponds to RFC
557        1766.  code and encoding can be None in case the values cannot
558        be determined.
559
560    """
561    localename = _setlocale(category)
562    if category == LC_ALL and ';' in localename:
563        raise TypeError, 'category LC_ALL is not supported'
564    return _parse_localename(localename)
565
566def setlocale(category, locale=None):
567
568    """ Set the locale for the given category.  The locale can be
569        a string, an iterable of two strings (language code and encoding),
570        or None.
571
572        Iterables are converted to strings using the locale aliasing
573        engine.  Locale strings are passed directly to the C lib.
574
575        category may be given as one of the LC_* values.
576
577    """
578    if locale and not isinstance(locale, (_str, _unicode)):
579        # convert to string
580        locale = normalize(_build_localename(locale))
581    return _setlocale(category, locale)
582
583def resetlocale(category=LC_ALL):
584
585    """ Sets the locale for category to the default setting.
586
587        The default setting is determined by calling
588        getdefaultlocale(). category defaults to LC_ALL.
589
590    """
591    _setlocale(category, _build_localename(getdefaultlocale()))
592
593if sys.platform.startswith("win"):
594    # On Win32, this will return the ANSI code page
595    def getpreferredencoding(do_setlocale = True):
596        """Return the charset that the user is likely using."""
597        import _locale
598        return _locale._getdefaultlocale()[1]
599else:
600    # On Unix, if CODESET is available, use that.
601    try:
602        CODESET
603    except NameError:
604        # Fall back to parsing environment variables :-(
605        def getpreferredencoding(do_setlocale = True):
606            """Return the charset that the user is likely using,
607            by looking at environment variables."""
608            return getdefaultlocale()[1]
609    else:
610        def getpreferredencoding(do_setlocale = True):
611            """Return the charset that the user is likely using,
612            according to the system configuration."""
613            if do_setlocale:
614                oldloc = setlocale(LC_CTYPE)
615                try:
616                    setlocale(LC_CTYPE, "")
617                except Error:
618                    pass
619                result = nl_langinfo(CODESET)
620                setlocale(LC_CTYPE, oldloc)
621            else:
622                result = nl_langinfo(CODESET)
623
624            if not result and sys.platform == 'darwin':
625                # nl_langinfo can return an empty string
626                # when the setting has an invalid value.
627                # Default to UTF-8 in that case because
628                # UTF-8 is the default charset on OSX and
629                # returning nothing will crash the
630                # interpreter.
631                result = 'UTF-8'
632            return result
633
634
635### Database
636#
637# The following data was extracted from the locale.alias file which
638# comes with X11 and then hand edited removing the explicit encoding
639# definitions and adding some more aliases. The file is usually
640# available as /usr/lib/X11/locale/locale.alias.
641#
642
643#
644# The local_encoding_alias table maps lowercase encoding alias names
645# to C locale encoding names (case-sensitive). Note that normalize()
646# first looks up the encoding in the encodings.aliases dictionary and
647# then applies this mapping to find the correct C lib name for the
648# encoding.
649#
650locale_encoding_alias = {
651
652    # Mappings for non-standard encoding names used in locale names
653    '437':                          'C',
654    'c':                            'C',
655    'en':                           'ISO8859-1',
656    'jis':                          'JIS7',
657    'jis7':                         'JIS7',
658    'ajec':                         'eucJP',
659
660    # Mappings from Python codec names to C lib encoding names
661    'ascii':                        'ISO8859-1',
662    'latin_1':                      'ISO8859-1',
663    'iso8859_1':                    'ISO8859-1',
664    'iso8859_10':                   'ISO8859-10',
665    'iso8859_11':                   'ISO8859-11',
666    'iso8859_13':                   'ISO8859-13',
667    'iso8859_14':                   'ISO8859-14',
668    'iso8859_15':                   'ISO8859-15',
669    'iso8859_16':                   'ISO8859-16',
670    'iso8859_2':                    'ISO8859-2',
671    'iso8859_3':                    'ISO8859-3',
672    'iso8859_4':                    'ISO8859-4',
673    'iso8859_5':                    'ISO8859-5',
674    'iso8859_6':                    'ISO8859-6',
675    'iso8859_7':                    'ISO8859-7',
676    'iso8859_8':                    'ISO8859-8',
677    'iso8859_9':                    'ISO8859-9',
678    'iso2022_jp':                   'JIS7',
679    'shift_jis':                    'SJIS',
680    'tactis':                       'TACTIS',
681    'euc_jp':                       'eucJP',
682    'euc_kr':                       'eucKR',
683    'utf_8':                        'UTF-8',
684    'koi8_r':                       'KOI8-R',
685    'koi8_u':                       'KOI8-U',
686    # XXX This list is still incomplete. If you know more
687    # mappings, please file a bug report. Thanks.
688}
689
690#
691# The locale_alias table maps lowercase alias names to C locale names
692# (case-sensitive). Encodings are always separated from the locale
693# name using a dot ('.'); they should only be given in case the
694# language name is needed to interpret the given encoding alias
695# correctly (CJK codes often have this need).
696#
697# Note that the normalize() function which uses this tables
698# removes '_' and '-' characters from the encoding part of the
699# locale name before doing the lookup. This saves a lot of
700# space in the table.
701#
702# MAL 2004-12-10:
703# Updated alias mapping to most recent locale.alias file
704# from X.org distribution using makelocalealias.py.
705#
706# These are the differences compared to the old mapping (Python 2.4
707# and older):
708#
709#    updated 'bg' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
710#    updated 'bg_bg' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
711#    updated 'bulgarian' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
712#    updated 'cz' -> 'cz_CZ.ISO8859-2' to 'cs_CZ.ISO8859-2'
713#    updated 'cz_cz' -> 'cz_CZ.ISO8859-2' to 'cs_CZ.ISO8859-2'
714#    updated 'czech' -> 'cs_CS.ISO8859-2' to 'cs_CZ.ISO8859-2'
715#    updated 'dutch' -> 'nl_BE.ISO8859-1' to 'nl_NL.ISO8859-1'
716#    updated 'et' -> 'et_EE.ISO8859-4' to 'et_EE.ISO8859-15'
717#    updated 'et_ee' -> 'et_EE.ISO8859-4' to 'et_EE.ISO8859-15'
718#    updated 'fi' -> 'fi_FI.ISO8859-1' to 'fi_FI.ISO8859-15'
719#    updated 'fi_fi' -> 'fi_FI.ISO8859-1' to 'fi_FI.ISO8859-15'
720#    updated 'iw' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
721#    updated 'iw_il' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
722#    updated 'japanese' -> 'ja_JP.SJIS' to 'ja_JP.eucJP'
723#    updated 'lt' -> 'lt_LT.ISO8859-4' to 'lt_LT.ISO8859-13'
724#    updated 'lv' -> 'lv_LV.ISO8859-4' to 'lv_LV.ISO8859-13'
725#    updated 'sl' -> 'sl_CS.ISO8859-2' to 'sl_SI.ISO8859-2'
726#    updated 'slovene' -> 'sl_CS.ISO8859-2' to 'sl_SI.ISO8859-2'
727#    updated 'th_th' -> 'th_TH.TACTIS' to 'th_TH.ISO8859-11'
728#    updated 'zh_cn' -> 'zh_CN.eucCN' to 'zh_CN.gb2312'
729#    updated 'zh_cn.big5' -> 'zh_TW.eucTW' to 'zh_TW.big5'
730#    updated 'zh_tw' -> 'zh_TW.eucTW' to 'zh_TW.big5'
731#
732# MAL 2008-05-30:
733# Updated alias mapping to most recent locale.alias file
734# from X.org distribution using makelocalealias.py.
735#
736# These are the differences compared to the old mapping (Python 2.5
737# and older):
738#
739#    updated 'cs_cs.iso88592' -> 'cs_CZ.ISO8859-2' to 'cs_CS.ISO8859-2'
740#    updated 'serbocroatian' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
741#    updated 'sh' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
742#    updated 'sh_hr.iso88592' -> 'sh_HR.ISO8859-2' to 'hr_HR.ISO8859-2'
743#    updated 'sh_sp' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
744#    updated 'sh_yu' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
745#    updated 'sp' -> 'sp_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
746#    updated 'sp_yu' -> 'sp_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
747#    updated 'sr' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
748#    updated 'sr@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
749#    updated 'sr_sp' -> 'sr_SP.ISO8859-2' to 'sr_CS.ISO8859-2'
750#    updated 'sr_yu' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
751#    updated 'sr_yu.cp1251@cyrillic' -> 'sr_YU.CP1251' to 'sr_CS.CP1251'
752#    updated 'sr_yu.iso88592' -> 'sr_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
753#    updated 'sr_yu.iso88595' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
754#    updated 'sr_yu.iso88595@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
755#    updated 'sr_yu.microsoftcp1251@cyrillic' -> 'sr_YU.CP1251' to 'sr_CS.CP1251'
756#    updated 'sr_yu.utf8@cyrillic' -> 'sr_YU.UTF-8' to 'sr_CS.UTF-8'
757#    updated 'sr_yu@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
758#
759# AP 2010-04-12:
760# Updated alias mapping to most recent locale.alias file
761# from X.org distribution using makelocalealias.py.
762#
763# These are the differences compared to the old mapping (Python 2.6.5
764# and older):
765#
766#    updated 'ru' -> 'ru_RU.ISO8859-5' to 'ru_RU.UTF-8'
767#    updated 'ru_ru' -> 'ru_RU.ISO8859-5' to 'ru_RU.UTF-8'
768#    updated 'serbocroatian' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
769#    updated 'sh' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
770#    updated 'sh_yu' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
771#    updated 'sr' -> 'sr_CS.ISO8859-5' to 'sr_RS.UTF-8'
772#    updated 'sr@cyrillic' -> 'sr_CS.ISO8859-5' to 'sr_RS.UTF-8'
773#    updated 'sr@latn' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
774#    updated 'sr_cs.utf8@latn' -> 'sr_CS.UTF-8' to 'sr_RS.UTF-8@latin'
775#    updated 'sr_cs@latn' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
776#    updated 'sr_yu' -> 'sr_CS.ISO8859-5' to 'sr_RS.UTF-8@latin'
777#    updated 'sr_yu.utf8@cyrillic' -> 'sr_CS.UTF-8' to 'sr_RS.UTF-8'
778#    updated 'sr_yu@cyrillic' -> 'sr_CS.ISO8859-5' to 'sr_RS.UTF-8'
779#
780# SS 2013-12-20:
781# Updated alias mapping to most recent locale.alias file
782# from X.org distribution using makelocalealias.py.
783#
784# These are the differences compared to the old mapping (Python 2.7.6
785# and older):
786#
787#    updated 'a3' -> 'a3_AZ.KOI8-C' to 'az_AZ.KOI8-C'
788#    updated 'a3_az' -> 'a3_AZ.KOI8-C' to 'az_AZ.KOI8-C'
789#    updated 'a3_az.koi8c' -> 'a3_AZ.KOI8-C' to 'az_AZ.KOI8-C'
790#    updated 'cs_cs.iso88592' -> 'cs_CS.ISO8859-2' to 'cs_CZ.ISO8859-2'
791#    updated 'hebrew' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
792#    updated 'hebrew.iso88598' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
793#    updated 'sd' -> 'sd_IN@devanagari.UTF-8' to 'sd_IN.UTF-8'
794#    updated 'sr@latn' -> 'sr_RS.UTF-8@latin' to 'sr_CS.UTF-8@latin'
795#    updated 'sr_cs' -> 'sr_RS.UTF-8' to 'sr_CS.UTF-8'
796#    updated 'sr_cs.utf8@latn' -> 'sr_RS.UTF-8@latin' to 'sr_CS.UTF-8@latin'
797#    updated 'sr_cs@latn' -> 'sr_RS.UTF-8@latin' to 'sr_CS.UTF-8@latin'
798#
799# SS 2014-10-01:
800# Updated alias mapping with glibc 2.19 supported locales.
801#
802# SS 2018-05-05:
803# Updated alias mapping with glibc 2.27 supported locales.
804#
805# These are the differences compared to the old mapping (Python 2.7.15
806# and older):
807#
808#    updated 'ca_es@valencia' -> 'ca_ES.ISO8859-15@valencia' to 'ca_ES.UTF-8@valencia'
809#    updated 'english.iso88591' -> 'en_EN.ISO8859-1' to 'en_US.ISO8859-1'
810#    updated 'kk_kz' -> 'kk_KZ.RK1048' to 'kk_KZ.ptcp154'
811#    updated 'russian' -> 'ru_RU.ISO8859-5' to 'ru_RU.KOI8-R'
812
813locale_alias = {
814    'a3':                                   'az_AZ.KOI8-C',
815    'a3_az':                                'az_AZ.KOI8-C',
816    'a3_az.koi8c':                          'az_AZ.KOI8-C',
817    'a3_az.koic':                           'az_AZ.KOI8-C',
818    'aa_dj':                                'aa_DJ.ISO8859-1',
819    'aa_er':                                'aa_ER.UTF-8',
820    'aa_et':                                'aa_ET.UTF-8',
821    'af':                                   'af_ZA.ISO8859-1',
822    'af_za':                                'af_ZA.ISO8859-1',
823    'af_za.iso88591':                       'af_ZA.ISO8859-1',
824    'agr_pe':                               'agr_PE.UTF-8',
825    'ak_gh':                                'ak_GH.UTF-8',
826    'am':                                   'am_ET.UTF-8',
827    'am_et':                                'am_ET.UTF-8',
828    'american':                             'en_US.ISO8859-1',
829    'american.iso88591':                    'en_US.ISO8859-1',
830    'an_es':                                'an_ES.ISO8859-15',
831    'anp_in':                               'anp_IN.UTF-8',
832    'ar':                                   'ar_AA.ISO8859-6',
833    'ar_aa':                                'ar_AA.ISO8859-6',
834    'ar_aa.iso88596':                       'ar_AA.ISO8859-6',
835    'ar_ae':                                'ar_AE.ISO8859-6',
836    'ar_ae.iso88596':                       'ar_AE.ISO8859-6',
837    'ar_bh':                                'ar_BH.ISO8859-6',
838    'ar_bh.iso88596':                       'ar_BH.ISO8859-6',
839    'ar_dz':                                'ar_DZ.ISO8859-6',
840    'ar_dz.iso88596':                       'ar_DZ.ISO8859-6',
841    'ar_eg':                                'ar_EG.ISO8859-6',
842    'ar_eg.iso88596':                       'ar_EG.ISO8859-6',
843    'ar_in':                                'ar_IN.UTF-8',
844    'ar_iq':                                'ar_IQ.ISO8859-6',
845    'ar_iq.iso88596':                       'ar_IQ.ISO8859-6',
846    'ar_jo':                                'ar_JO.ISO8859-6',
847    'ar_jo.iso88596':                       'ar_JO.ISO8859-6',
848    'ar_kw':                                'ar_KW.ISO8859-6',
849    'ar_kw.iso88596':                       'ar_KW.ISO8859-6',
850    'ar_lb':                                'ar_LB.ISO8859-6',
851    'ar_lb.iso88596':                       'ar_LB.ISO8859-6',
852    'ar_ly':                                'ar_LY.ISO8859-6',
853    'ar_ly.iso88596':                       'ar_LY.ISO8859-6',
854    'ar_ma':                                'ar_MA.ISO8859-6',
855    'ar_ma.iso88596':                       'ar_MA.ISO8859-6',
856    'ar_om':                                'ar_OM.ISO8859-6',
857    'ar_om.iso88596':                       'ar_OM.ISO8859-6',
858    'ar_qa':                                'ar_QA.ISO8859-6',
859    'ar_qa.iso88596':                       'ar_QA.ISO8859-6',
860    'ar_sa':                                'ar_SA.ISO8859-6',
861    'ar_sa.iso88596':                       'ar_SA.ISO8859-6',
862    'ar_sd':                                'ar_SD.ISO8859-6',
863    'ar_sd.iso88596':                       'ar_SD.ISO8859-6',
864    'ar_ss':                                'ar_SS.UTF-8',
865    'ar_sy':                                'ar_SY.ISO8859-6',
866    'ar_sy.iso88596':                       'ar_SY.ISO8859-6',
867    'ar_tn':                                'ar_TN.ISO8859-6',
868    'ar_tn.iso88596':                       'ar_TN.ISO8859-6',
869    'ar_ye':                                'ar_YE.ISO8859-6',
870    'ar_ye.iso88596':                       'ar_YE.ISO8859-6',
871    'arabic':                               'ar_AA.ISO8859-6',
872    'arabic.iso88596':                      'ar_AA.ISO8859-6',
873    'as':                                   'as_IN.UTF-8',
874    'as_in':                                'as_IN.UTF-8',
875    'ast_es':                               'ast_ES.ISO8859-15',
876    'ayc_pe':                               'ayc_PE.UTF-8',
877    'az':                                   'az_AZ.ISO8859-9E',
878    'az_az':                                'az_AZ.ISO8859-9E',
879    'az_az.iso88599e':                      'az_AZ.ISO8859-9E',
880    'az_ir':                                'az_IR.UTF-8',
881    'be':                                   'be_BY.CP1251',
882    'be@latin':                             'be_BY.UTF-8@latin',
883    'be_bg.utf8':                           'bg_BG.UTF-8',
884    'be_by':                                'be_BY.CP1251',
885    'be_by.cp1251':                         'be_BY.CP1251',
886    'be_by.microsoftcp1251':                'be_BY.CP1251',
887    'be_by.utf8@latin':                     'be_BY.UTF-8@latin',
888    'be_by@latin':                          'be_BY.UTF-8@latin',
889    'bem_zm':                               'bem_ZM.UTF-8',
890    'ber_dz':                               'ber_DZ.UTF-8',
891    'ber_ma':                               'ber_MA.UTF-8',
892    'bg':                                   'bg_BG.CP1251',
893    'bg_bg':                                'bg_BG.CP1251',
894    'bg_bg.cp1251':                         'bg_BG.CP1251',
895    'bg_bg.iso88595':                       'bg_BG.ISO8859-5',
896    'bg_bg.koi8r':                          'bg_BG.KOI8-R',
897    'bg_bg.microsoftcp1251':                'bg_BG.CP1251',
898    'bhb_in.utf8':                          'bhb_IN.UTF-8',
899    'bho_in':                               'bho_IN.UTF-8',
900    'bho_np':                               'bho_NP.UTF-8',
901    'bi_vu':                                'bi_VU.UTF-8',
902    'bn_bd':                                'bn_BD.UTF-8',
903    'bn_in':                                'bn_IN.UTF-8',
904    'bo_cn':                                'bo_CN.UTF-8',
905    'bo_in':                                'bo_IN.UTF-8',
906    'bokmal':                               'nb_NO.ISO8859-1',
907    'bokm\xe5l':                            'nb_NO.ISO8859-1',
908    'br':                                   'br_FR.ISO8859-1',
909    'br_fr':                                'br_FR.ISO8859-1',
910    'br_fr.iso88591':                       'br_FR.ISO8859-1',
911    'br_fr.iso885914':                      'br_FR.ISO8859-14',
912    'br_fr.iso885915':                      'br_FR.ISO8859-15',
913    'br_fr.iso885915@euro':                 'br_FR.ISO8859-15',
914    'br_fr.utf8@euro':                      'br_FR.UTF-8',
915    'br_fr@euro':                           'br_FR.ISO8859-15',
916    'brx_in':                               'brx_IN.UTF-8',
917    'bs':                                   'bs_BA.ISO8859-2',
918    'bs_ba':                                'bs_BA.ISO8859-2',
919    'bs_ba.iso88592':                       'bs_BA.ISO8859-2',
920    'bulgarian':                            'bg_BG.CP1251',
921    'byn_er':                               'byn_ER.UTF-8',
922    'c':                                    'C',
923    'c-french':                             'fr_CA.ISO8859-1',
924    'c-french.iso88591':                    'fr_CA.ISO8859-1',
925    'c.ascii':                              'C',
926    'c.en':                                 'C',
927    'c.iso88591':                           'en_US.ISO8859-1',
928    'c.utf8':                               'en_US.UTF-8',
929    'c_c':                                  'C',
930    'c_c.c':                                'C',
931    'ca':                                   'ca_ES.ISO8859-1',
932    'ca_ad':                                'ca_AD.ISO8859-1',
933    'ca_ad.iso88591':                       'ca_AD.ISO8859-1',
934    'ca_ad.iso885915':                      'ca_AD.ISO8859-15',
935    'ca_ad.iso885915@euro':                 'ca_AD.ISO8859-15',
936    'ca_ad.utf8@euro':                      'ca_AD.UTF-8',
937    'ca_ad@euro':                           'ca_AD.ISO8859-15',
938    'ca_es':                                'ca_ES.ISO8859-1',
939    'ca_es.iso88591':                       'ca_ES.ISO8859-1',
940    'ca_es.iso885915':                      'ca_ES.ISO8859-15',
941    'ca_es.iso885915@euro':                 'ca_ES.ISO8859-15',
942    'ca_es.utf8@euro':                      'ca_ES.UTF-8',
943    'ca_es@euro':                           'ca_ES.ISO8859-15',
944    'ca_es@valencia':                       'ca_ES.UTF-8@valencia',
945    'ca_fr':                                'ca_FR.ISO8859-1',
946    'ca_fr.iso88591':                       'ca_FR.ISO8859-1',
947    'ca_fr.iso885915':                      'ca_FR.ISO8859-15',
948    'ca_fr.iso885915@euro':                 'ca_FR.ISO8859-15',
949    'ca_fr.utf8@euro':                      'ca_FR.UTF-8',
950    'ca_fr@euro':                           'ca_FR.ISO8859-15',
951    'ca_it':                                'ca_IT.ISO8859-1',
952    'ca_it.iso88591':                       'ca_IT.ISO8859-1',
953    'ca_it.iso885915':                      'ca_IT.ISO8859-15',
954    'ca_it.iso885915@euro':                 'ca_IT.ISO8859-15',
955    'ca_it.utf8@euro':                      'ca_IT.UTF-8',
956    'ca_it@euro':                           'ca_IT.ISO8859-15',
957    'catalan':                              'ca_ES.ISO8859-1',
958    'ce_ru':                                'ce_RU.UTF-8',
959    'cextend':                              'en_US.ISO8859-1',
960    'cextend.en':                           'en_US.ISO8859-1',
961    'chinese-s':                            'zh_CN.eucCN',
962    'chinese-t':                            'zh_TW.eucTW',
963    'chr_us':                               'chr_US.UTF-8',
964    'ckb_iq':                               'ckb_IQ.UTF-8',
965    'cmn_tw':                               'cmn_TW.UTF-8',
966    'crh_ua':                               'crh_UA.UTF-8',
967    'croatian':                             'hr_HR.ISO8859-2',
968    'cs':                                   'cs_CZ.ISO8859-2',
969    'cs_cs':                                'cs_CZ.ISO8859-2',
970    'cs_cs.iso88592':                       'cs_CZ.ISO8859-2',
971    'cs_cz':                                'cs_CZ.ISO8859-2',
972    'cs_cz.iso88592':                       'cs_CZ.ISO8859-2',
973    'csb_pl':                               'csb_PL.UTF-8',
974    'cv_ru':                                'cv_RU.UTF-8',
975    'cy':                                   'cy_GB.ISO8859-1',
976    'cy_gb':                                'cy_GB.ISO8859-1',
977    'cy_gb.iso88591':                       'cy_GB.ISO8859-1',
978    'cy_gb.iso885914':                      'cy_GB.ISO8859-14',
979    'cy_gb.iso885915':                      'cy_GB.ISO8859-15',
980    'cy_gb@euro':                           'cy_GB.ISO8859-15',
981    'cz':                                   'cs_CZ.ISO8859-2',
982    'cz_cz':                                'cs_CZ.ISO8859-2',
983    'czech':                                'cs_CZ.ISO8859-2',
984    'da':                                   'da_DK.ISO8859-1',
985    'da.iso885915':                         'da_DK.ISO8859-15',
986    'da_dk':                                'da_DK.ISO8859-1',
987    'da_dk.88591':                          'da_DK.ISO8859-1',
988    'da_dk.885915':                         'da_DK.ISO8859-15',
989    'da_dk.iso88591':                       'da_DK.ISO8859-1',
990    'da_dk.iso885915':                      'da_DK.ISO8859-15',
991    'da_dk@euro':                           'da_DK.ISO8859-15',
992    'danish':                               'da_DK.ISO8859-1',
993    'danish.iso88591':                      'da_DK.ISO8859-1',
994    'dansk':                                'da_DK.ISO8859-1',
995    'de':                                   'de_DE.ISO8859-1',
996    'de.iso885915':                         'de_DE.ISO8859-15',
997    'de_at':                                'de_AT.ISO8859-1',
998    'de_at.iso88591':                       'de_AT.ISO8859-1',
999    'de_at.iso885915':                      'de_AT.ISO8859-15',
1000    'de_at.iso885915@euro':                 'de_AT.ISO8859-15',
1001    'de_at.utf8@euro':                      'de_AT.UTF-8',
1002    'de_at@euro':                           'de_AT.ISO8859-15',
1003    'de_be':                                'de_BE.ISO8859-1',
1004    'de_be.iso88591':                       'de_BE.ISO8859-1',
1005    'de_be.iso885915':                      'de_BE.ISO8859-15',
1006    'de_be.iso885915@euro':                 'de_BE.ISO8859-15',
1007    'de_be.utf8@euro':                      'de_BE.UTF-8',
1008    'de_be@euro':                           'de_BE.ISO8859-15',
1009    'de_ch':                                'de_CH.ISO8859-1',
1010    'de_ch.iso88591':                       'de_CH.ISO8859-1',
1011    'de_ch.iso885915':                      'de_CH.ISO8859-15',
1012    'de_ch@euro':                           'de_CH.ISO8859-15',
1013    'de_de':                                'de_DE.ISO8859-1',
1014    'de_de.88591':                          'de_DE.ISO8859-1',
1015    'de_de.885915':                         'de_DE.ISO8859-15',
1016    'de_de.885915@euro':                    'de_DE.ISO8859-15',
1017    'de_de.iso88591':                       'de_DE.ISO8859-1',
1018    'de_de.iso885915':                      'de_DE.ISO8859-15',
1019    'de_de.iso885915@euro':                 'de_DE.ISO8859-15',
1020    'de_de.utf8@euro':                      'de_DE.UTF-8',
1021    'de_de@euro':                           'de_DE.ISO8859-15',
1022    'de_it':                                'de_IT.ISO8859-1',
1023    'de_li.utf8':                           'de_LI.UTF-8',
1024    'de_lu':                                'de_LU.ISO8859-1',
1025    'de_lu.iso88591':                       'de_LU.ISO8859-1',
1026    'de_lu.iso885915':                      'de_LU.ISO8859-15',
1027    'de_lu.iso885915@euro':                 'de_LU.ISO8859-15',
1028    'de_lu.utf8@euro':                      'de_LU.UTF-8',
1029    'de_lu@euro':                           'de_LU.ISO8859-15',
1030    'deutsch':                              'de_DE.ISO8859-1',
1031    'doi_in':                               'doi_IN.UTF-8',
1032    'dutch':                                'nl_NL.ISO8859-1',
1033    'dutch.iso88591':                       'nl_BE.ISO8859-1',
1034    'dv_mv':                                'dv_MV.UTF-8',
1035    'dz_bt':                                'dz_BT.UTF-8',
1036    'ee':                                   'ee_EE.ISO8859-4',
1037    'ee_ee':                                'ee_EE.ISO8859-4',
1038    'ee_ee.iso88594':                       'ee_EE.ISO8859-4',
1039    'eesti':                                'et_EE.ISO8859-1',
1040    'el':                                   'el_GR.ISO8859-7',
1041    'el_cy':                                'el_CY.ISO8859-7',
1042    'el_gr':                                'el_GR.ISO8859-7',
1043    'el_gr.iso88597':                       'el_GR.ISO8859-7',
1044    'el_gr@euro':                           'el_GR.ISO8859-15',
1045    'en':                                   'en_US.ISO8859-1',
1046    'en.iso88591':                          'en_US.ISO8859-1',
1047    'en_ag':                                'en_AG.UTF-8',
1048    'en_au':                                'en_AU.ISO8859-1',
1049    'en_au.iso88591':                       'en_AU.ISO8859-1',
1050    'en_be':                                'en_BE.ISO8859-1',
1051    'en_be@euro':                           'en_BE.ISO8859-15',
1052    'en_bw':                                'en_BW.ISO8859-1',
1053    'en_bw.iso88591':                       'en_BW.ISO8859-1',
1054    'en_ca':                                'en_CA.ISO8859-1',
1055    'en_ca.iso88591':                       'en_CA.ISO8859-1',
1056    'en_dk':                                'en_DK.ISO8859-1',
1057    'en_dk.iso88591':                       'en_DK.ISO8859-1',
1058    'en_dk.iso885915':                      'en_DK.ISO8859-15',
1059    'en_dl.utf8':                           'en_DL.UTF-8',
1060    'en_gb':                                'en_GB.ISO8859-1',
1061    'en_gb.88591':                          'en_GB.ISO8859-1',
1062    'en_gb.iso88591':                       'en_GB.ISO8859-1',
1063    'en_gb.iso885915':                      'en_GB.ISO8859-15',
1064    'en_gb@euro':                           'en_GB.ISO8859-15',
1065    'en_hk':                                'en_HK.ISO8859-1',
1066    'en_hk.iso88591':                       'en_HK.ISO8859-1',
1067    'en_ie':                                'en_IE.ISO8859-1',
1068    'en_ie.iso88591':                       'en_IE.ISO8859-1',
1069    'en_ie.iso885915':                      'en_IE.ISO8859-15',
1070    'en_ie.iso885915@euro':                 'en_IE.ISO8859-15',
1071    'en_ie.utf8@euro':                      'en_IE.UTF-8',
1072    'en_ie@euro':                           'en_IE.ISO8859-15',
1073    'en_il':                                'en_IL.UTF-8',
1074    'en_in':                                'en_IN.ISO8859-1',
1075    'en_ng':                                'en_NG.UTF-8',
1076    'en_nz':                                'en_NZ.ISO8859-1',
1077    'en_nz.iso88591':                       'en_NZ.ISO8859-1',
1078    'en_ph':                                'en_PH.ISO8859-1',
1079    'en_ph.iso88591':                       'en_PH.ISO8859-1',
1080    'en_sc.utf8':                           'en_SC.UTF-8',
1081    'en_sg':                                'en_SG.ISO8859-1',
1082    'en_sg.iso88591':                       'en_SG.ISO8859-1',
1083    'en_uk':                                'en_GB.ISO8859-1',
1084    'en_us':                                'en_US.ISO8859-1',
1085    'en_us.88591':                          'en_US.ISO8859-1',
1086    'en_us.885915':                         'en_US.ISO8859-15',
1087    'en_us.iso88591':                       'en_US.ISO8859-1',
1088    'en_us.iso885915':                      'en_US.ISO8859-15',
1089    'en_us.iso885915@euro':                 'en_US.ISO8859-15',
1090    'en_us@euro':                           'en_US.ISO8859-15',
1091    'en_us@euro@euro':                      'en_US.ISO8859-15',
1092    'en_za':                                'en_ZA.ISO8859-1',
1093    'en_za.88591':                          'en_ZA.ISO8859-1',
1094    'en_za.iso88591':                       'en_ZA.ISO8859-1',
1095    'en_za.iso885915':                      'en_ZA.ISO8859-15',
1096    'en_za@euro':                           'en_ZA.ISO8859-15',
1097    'en_zm':                                'en_ZM.UTF-8',
1098    'en_zw':                                'en_ZW.ISO8859-1',
1099    'en_zw.iso88591':                       'en_ZW.ISO8859-1',
1100    'en_zw.utf8':                           'en_ZS.UTF-8',
1101    'eng_gb':                               'en_GB.ISO8859-1',
1102    'eng_gb.8859':                          'en_GB.ISO8859-1',
1103    'english':                              'en_EN.ISO8859-1',
1104    'english.iso88591':                     'en_US.ISO8859-1',
1105    'english_uk':                           'en_GB.ISO8859-1',
1106    'english_uk.8859':                      'en_GB.ISO8859-1',
1107    'english_united-states':                'en_US.ISO8859-1',
1108    'english_united-states.437':            'C',
1109    'english_us':                           'en_US.ISO8859-1',
1110    'english_us.8859':                      'en_US.ISO8859-1',
1111    'english_us.ascii':                     'en_US.ISO8859-1',
1112    'eo':                                   'eo_XX.ISO8859-3',
1113    'eo.utf8':                              'eo.UTF-8',
1114    'eo_eo':                                'eo_EO.ISO8859-3',
1115    'eo_eo.iso88593':                       'eo_EO.ISO8859-3',
1116    'eo_us.utf8':                           'eo_US.UTF-8',
1117    'eo_xx':                                'eo_XX.ISO8859-3',
1118    'eo_xx.iso88593':                       'eo_XX.ISO8859-3',
1119    'es':                                   'es_ES.ISO8859-1',
1120    'es_ar':                                'es_AR.ISO8859-1',
1121    'es_ar.iso88591':                       'es_AR.ISO8859-1',
1122    'es_bo':                                'es_BO.ISO8859-1',
1123    'es_bo.iso88591':                       'es_BO.ISO8859-1',
1124    'es_cl':                                'es_CL.ISO8859-1',
1125    'es_cl.iso88591':                       'es_CL.ISO8859-1',
1126    'es_co':                                'es_CO.ISO8859-1',
1127    'es_co.iso88591':                       'es_CO.ISO8859-1',
1128    'es_cr':                                'es_CR.ISO8859-1',
1129    'es_cr.iso88591':                       'es_CR.ISO8859-1',
1130    'es_cu':                                'es_CU.UTF-8',
1131    'es_do':                                'es_DO.ISO8859-1',
1132    'es_do.iso88591':                       'es_DO.ISO8859-1',
1133    'es_ec':                                'es_EC.ISO8859-1',
1134    'es_ec.iso88591':                       'es_EC.ISO8859-1',
1135    'es_es':                                'es_ES.ISO8859-1',
1136    'es_es.88591':                          'es_ES.ISO8859-1',
1137    'es_es.iso88591':                       'es_ES.ISO8859-1',
1138    'es_es.iso885915':                      'es_ES.ISO8859-15',
1139    'es_es.iso885915@euro':                 'es_ES.ISO8859-15',
1140    'es_es.utf8@euro':                      'es_ES.UTF-8',
1141    'es_es@euro':                           'es_ES.ISO8859-15',
1142    'es_gt':                                'es_GT.ISO8859-1',
1143    'es_gt.iso88591':                       'es_GT.ISO8859-1',
1144    'es_hn':                                'es_HN.ISO8859-1',
1145    'es_hn.iso88591':                       'es_HN.ISO8859-1',
1146    'es_mx':                                'es_MX.ISO8859-1',
1147    'es_mx.iso88591':                       'es_MX.ISO8859-1',
1148    'es_ni':                                'es_NI.ISO8859-1',
1149    'es_ni.iso88591':                       'es_NI.ISO8859-1',
1150    'es_pa':                                'es_PA.ISO8859-1',
1151    'es_pa.iso88591':                       'es_PA.ISO8859-1',
1152    'es_pa.iso885915':                      'es_PA.ISO8859-15',
1153    'es_pa@euro':                           'es_PA.ISO8859-15',
1154    'es_pe':                                'es_PE.ISO8859-1',
1155    'es_pe.iso88591':                       'es_PE.ISO8859-1',
1156    'es_pe.iso885915':                      'es_PE.ISO8859-15',
1157    'es_pe@euro':                           'es_PE.ISO8859-15',
1158    'es_pr':                                'es_PR.ISO8859-1',
1159    'es_pr.iso88591':                       'es_PR.ISO8859-1',
1160    'es_py':                                'es_PY.ISO8859-1',
1161    'es_py.iso88591':                       'es_PY.ISO8859-1',
1162    'es_py.iso885915':                      'es_PY.ISO8859-15',
1163    'es_py@euro':                           'es_PY.ISO8859-15',
1164    'es_sv':                                'es_SV.ISO8859-1',
1165    'es_sv.iso88591':                       'es_SV.ISO8859-1',
1166    'es_sv.iso885915':                      'es_SV.ISO8859-15',
1167    'es_sv@euro':                           'es_SV.ISO8859-15',
1168    'es_us':                                'es_US.ISO8859-1',
1169    'es_us.iso88591':                       'es_US.ISO8859-1',
1170    'es_uy':                                'es_UY.ISO8859-1',
1171    'es_uy.iso88591':                       'es_UY.ISO8859-1',
1172    'es_uy.iso885915':                      'es_UY.ISO8859-15',
1173    'es_uy@euro':                           'es_UY.ISO8859-15',
1174    'es_ve':                                'es_VE.ISO8859-1',
1175    'es_ve.iso88591':                       'es_VE.ISO8859-1',
1176    'es_ve.iso885915':                      'es_VE.ISO8859-15',
1177    'es_ve@euro':                           'es_VE.ISO8859-15',
1178    'estonian':                             'et_EE.ISO8859-1',
1179    'et':                                   'et_EE.ISO8859-15',
1180    'et_ee':                                'et_EE.ISO8859-15',
1181    'et_ee.iso88591':                       'et_EE.ISO8859-1',
1182    'et_ee.iso885913':                      'et_EE.ISO8859-13',
1183    'et_ee.iso885915':                      'et_EE.ISO8859-15',
1184    'et_ee.iso88594':                       'et_EE.ISO8859-4',
1185    'et_ee@euro':                           'et_EE.ISO8859-15',
1186    'eu':                                   'eu_ES.ISO8859-1',
1187    'eu_es':                                'eu_ES.ISO8859-1',
1188    'eu_es.iso88591':                       'eu_ES.ISO8859-1',
1189    'eu_es.iso885915':                      'eu_ES.ISO8859-15',
1190    'eu_es.iso885915@euro':                 'eu_ES.ISO8859-15',
1191    'eu_es.utf8@euro':                      'eu_ES.UTF-8',
1192    'eu_es@euro':                           'eu_ES.ISO8859-15',
1193    'eu_fr':                                'eu_FR.ISO8859-1',
1194    'fa':                                   'fa_IR.UTF-8',
1195    'fa_ir':                                'fa_IR.UTF-8',
1196    'fa_ir.isiri3342':                      'fa_IR.ISIRI-3342',
1197    'ff_sn':                                'ff_SN.UTF-8',
1198    'fi':                                   'fi_FI.ISO8859-15',
1199    'fi.iso885915':                         'fi_FI.ISO8859-15',
1200    'fi_fi':                                'fi_FI.ISO8859-15',
1201    'fi_fi.88591':                          'fi_FI.ISO8859-1',
1202    'fi_fi.iso88591':                       'fi_FI.ISO8859-1',
1203    'fi_fi.iso885915':                      'fi_FI.ISO8859-15',
1204    'fi_fi.iso885915@euro':                 'fi_FI.ISO8859-15',
1205    'fi_fi.utf8@euro':                      'fi_FI.UTF-8',
1206    'fi_fi@euro':                           'fi_FI.ISO8859-15',
1207    'fil_ph':                               'fil_PH.UTF-8',
1208    'finnish':                              'fi_FI.ISO8859-1',
1209    'finnish.iso88591':                     'fi_FI.ISO8859-1',
1210    'fo':                                   'fo_FO.ISO8859-1',
1211    'fo_fo':                                'fo_FO.ISO8859-1',
1212    'fo_fo.iso88591':                       'fo_FO.ISO8859-1',
1213    'fo_fo.iso885915':                      'fo_FO.ISO8859-15',
1214    'fo_fo@euro':                           'fo_FO.ISO8859-15',
1215    'fr':                                   'fr_FR.ISO8859-1',
1216    'fr.iso885915':                         'fr_FR.ISO8859-15',
1217    'fr_be':                                'fr_BE.ISO8859-1',
1218    'fr_be.88591':                          'fr_BE.ISO8859-1',
1219    'fr_be.iso88591':                       'fr_BE.ISO8859-1',
1220    'fr_be.iso885915':                      'fr_BE.ISO8859-15',
1221    'fr_be.iso885915@euro':                 'fr_BE.ISO8859-15',
1222    'fr_be.utf8@euro':                      'fr_BE.UTF-8',
1223    'fr_be@euro':                           'fr_BE.ISO8859-15',
1224    'fr_ca':                                'fr_CA.ISO8859-1',
1225    'fr_ca.88591':                          'fr_CA.ISO8859-1',
1226    'fr_ca.iso88591':                       'fr_CA.ISO8859-1',
1227    'fr_ca.iso885915':                      'fr_CA.ISO8859-15',
1228    'fr_ca@euro':                           'fr_CA.ISO8859-15',
1229    'fr_ch':                                'fr_CH.ISO8859-1',
1230    'fr_ch.88591':                          'fr_CH.ISO8859-1',
1231    'fr_ch.iso88591':                       'fr_CH.ISO8859-1',
1232    'fr_ch.iso885915':                      'fr_CH.ISO8859-15',
1233    'fr_ch@euro':                           'fr_CH.ISO8859-15',
1234    'fr_fr':                                'fr_FR.ISO8859-1',
1235    'fr_fr.88591':                          'fr_FR.ISO8859-1',
1236    'fr_fr.iso88591':                       'fr_FR.ISO8859-1',
1237    'fr_fr.iso885915':                      'fr_FR.ISO8859-15',
1238    'fr_fr.iso885915@euro':                 'fr_FR.ISO8859-15',
1239    'fr_fr.utf8@euro':                      'fr_FR.UTF-8',
1240    'fr_fr@euro':                           'fr_FR.ISO8859-15',
1241    'fr_lu':                                'fr_LU.ISO8859-1',
1242    'fr_lu.88591':                          'fr_LU.ISO8859-1',
1243    'fr_lu.iso88591':                       'fr_LU.ISO8859-1',
1244    'fr_lu.iso885915':                      'fr_LU.ISO8859-15',
1245    'fr_lu.iso885915@euro':                 'fr_LU.ISO8859-15',
1246    'fr_lu.utf8@euro':                      'fr_LU.UTF-8',
1247    'fr_lu@euro':                           'fr_LU.ISO8859-15',
1248    'fran\xe7ais':                          'fr_FR.ISO8859-1',
1249    'fre_fr':                               'fr_FR.ISO8859-1',
1250    'fre_fr.8859':                          'fr_FR.ISO8859-1',
1251    'french':                               'fr_FR.ISO8859-1',
1252    'french.iso88591':                      'fr_CH.ISO8859-1',
1253    'french_france':                        'fr_FR.ISO8859-1',
1254    'french_france.8859':                   'fr_FR.ISO8859-1',
1255    'fur_it':                               'fur_IT.UTF-8',
1256    'fy_de':                                'fy_DE.UTF-8',
1257    'fy_nl':                                'fy_NL.UTF-8',
1258    'ga':                                   'ga_IE.ISO8859-1',
1259    'ga_ie':                                'ga_IE.ISO8859-1',
1260    'ga_ie.iso88591':                       'ga_IE.ISO8859-1',
1261    'ga_ie.iso885914':                      'ga_IE.ISO8859-14',
1262    'ga_ie.iso885915':                      'ga_IE.ISO8859-15',
1263    'ga_ie.iso885915@euro':                 'ga_IE.ISO8859-15',
1264    'ga_ie.utf8@euro':                      'ga_IE.UTF-8',
1265    'ga_ie@euro':                           'ga_IE.ISO8859-15',
1266    'galego':                               'gl_ES.ISO8859-1',
1267    'galician':                             'gl_ES.ISO8859-1',
1268    'gd':                                   'gd_GB.ISO8859-1',
1269    'gd_gb':                                'gd_GB.ISO8859-1',
1270    'gd_gb.iso88591':                       'gd_GB.ISO8859-1',
1271    'gd_gb.iso885914':                      'gd_GB.ISO8859-14',
1272    'gd_gb.iso885915':                      'gd_GB.ISO8859-15',
1273    'gd_gb@euro':                           'gd_GB.ISO8859-15',
1274    'ger_de':                               'de_DE.ISO8859-1',
1275    'ger_de.8859':                          'de_DE.ISO8859-1',
1276    'german':                               'de_DE.ISO8859-1',
1277    'german.iso88591':                      'de_CH.ISO8859-1',
1278    'german_germany':                       'de_DE.ISO8859-1',
1279    'german_germany.8859':                  'de_DE.ISO8859-1',
1280    'gez_er':                               'gez_ER.UTF-8',
1281    'gez_et':                               'gez_ET.UTF-8',
1282    'gl':                                   'gl_ES.ISO8859-1',
1283    'gl_es':                                'gl_ES.ISO8859-1',
1284    'gl_es.iso88591':                       'gl_ES.ISO8859-1',
1285    'gl_es.iso885915':                      'gl_ES.ISO8859-15',
1286    'gl_es.iso885915@euro':                 'gl_ES.ISO8859-15',
1287    'gl_es.utf8@euro':                      'gl_ES.UTF-8',
1288    'gl_es@euro':                           'gl_ES.ISO8859-15',
1289    'greek':                                'el_GR.ISO8859-7',
1290    'greek.iso88597':                       'el_GR.ISO8859-7',
1291    'gu_in':                                'gu_IN.UTF-8',
1292    'gv':                                   'gv_GB.ISO8859-1',
1293    'gv_gb':                                'gv_GB.ISO8859-1',
1294    'gv_gb.iso88591':                       'gv_GB.ISO8859-1',
1295    'gv_gb.iso885914':                      'gv_GB.ISO8859-14',
1296    'gv_gb.iso885915':                      'gv_GB.ISO8859-15',
1297    'gv_gb@euro':                           'gv_GB.ISO8859-15',
1298    'ha_ng':                                'ha_NG.UTF-8',
1299    'hak_tw':                               'hak_TW.UTF-8',
1300    'he':                                   'he_IL.ISO8859-8',
1301    'he_il':                                'he_IL.ISO8859-8',
1302    'he_il.cp1255':                         'he_IL.CP1255',
1303    'he_il.iso88598':                       'he_IL.ISO8859-8',
1304    'he_il.microsoftcp1255':                'he_IL.CP1255',
1305    'hebrew':                               'he_IL.ISO8859-8',
1306    'hebrew.iso88598':                      'he_IL.ISO8859-8',
1307    'hi':                                   'hi_IN.ISCII-DEV',
1308    'hi_in':                                'hi_IN.ISCII-DEV',
1309    'hi_in.isciidev':                       'hi_IN.ISCII-DEV',
1310    'hif_fj':                               'hif_FJ.UTF-8',
1311    'hne':                                  'hne_IN.UTF-8',
1312    'hne_in':                               'hne_IN.UTF-8',
1313    'hr':                                   'hr_HR.ISO8859-2',
1314    'hr_hr':                                'hr_HR.ISO8859-2',
1315    'hr_hr.iso88592':                       'hr_HR.ISO8859-2',
1316    'hrvatski':                             'hr_HR.ISO8859-2',
1317    'hsb_de':                               'hsb_DE.ISO8859-2',
1318    'ht_ht':                                'ht_HT.UTF-8',
1319    'hu':                                   'hu_HU.ISO8859-2',
1320    'hu_hu':                                'hu_HU.ISO8859-2',
1321    'hu_hu.iso88592':                       'hu_HU.ISO8859-2',
1322    'hungarian':                            'hu_HU.ISO8859-2',
1323    'hy_am':                                'hy_AM.UTF-8',
1324    'hy_am.armscii8':                       'hy_AM.ARMSCII_8',
1325    'ia':                                   'ia.UTF-8',
1326    'ia_fr':                                'ia_FR.UTF-8',
1327    'icelandic':                            'is_IS.ISO8859-1',
1328    'icelandic.iso88591':                   'is_IS.ISO8859-1',
1329    'id':                                   'id_ID.ISO8859-1',
1330    'id_id':                                'id_ID.ISO8859-1',
1331    'ig_ng':                                'ig_NG.UTF-8',
1332    'ik_ca':                                'ik_CA.UTF-8',
1333    'in':                                   'id_ID.ISO8859-1',
1334    'in_id':                                'id_ID.ISO8859-1',
1335    'is':                                   'is_IS.ISO8859-1',
1336    'is_is':                                'is_IS.ISO8859-1',
1337    'is_is.iso88591':                       'is_IS.ISO8859-1',
1338    'is_is.iso885915':                      'is_IS.ISO8859-15',
1339    'is_is@euro':                           'is_IS.ISO8859-15',
1340    'iso-8859-1':                           'en_US.ISO8859-1',
1341    'iso-8859-15':                          'en_US.ISO8859-15',
1342    'iso8859-1':                            'en_US.ISO8859-1',
1343    'iso8859-15':                           'en_US.ISO8859-15',
1344    'iso_8859_1':                           'en_US.ISO8859-1',
1345    'iso_8859_15':                          'en_US.ISO8859-15',
1346    'it':                                   'it_IT.ISO8859-1',
1347    'it.iso885915':                         'it_IT.ISO8859-15',
1348    'it_ch':                                'it_CH.ISO8859-1',
1349    'it_ch.iso88591':                       'it_CH.ISO8859-1',
1350    'it_ch.iso885915':                      'it_CH.ISO8859-15',
1351    'it_ch@euro':                           'it_CH.ISO8859-15',
1352    'it_it':                                'it_IT.ISO8859-1',
1353    'it_it.88591':                          'it_IT.ISO8859-1',
1354    'it_it.iso88591':                       'it_IT.ISO8859-1',
1355    'it_it.iso885915':                      'it_IT.ISO8859-15',
1356    'it_it.iso885915@euro':                 'it_IT.ISO8859-15',
1357    'it_it.utf8@euro':                      'it_IT.UTF-8',
1358    'it_it@euro':                           'it_IT.ISO8859-15',
1359    'italian':                              'it_IT.ISO8859-1',
1360    'italian.iso88591':                     'it_IT.ISO8859-1',
1361    'iu':                                   'iu_CA.NUNACOM-8',
1362    'iu_ca':                                'iu_CA.NUNACOM-8',
1363    'iu_ca.nunacom8':                       'iu_CA.NUNACOM-8',
1364    'iw':                                   'he_IL.ISO8859-8',
1365    'iw_il':                                'he_IL.ISO8859-8',
1366    'iw_il.iso88598':                       'he_IL.ISO8859-8',
1367    'iw_il.utf8':                           'iw_IL.UTF-8',
1368    'ja':                                   'ja_JP.eucJP',
1369    'ja.jis':                               'ja_JP.JIS7',
1370    'ja.sjis':                              'ja_JP.SJIS',
1371    'ja_jp':                                'ja_JP.eucJP',
1372    'ja_jp.ajec':                           'ja_JP.eucJP',
1373    'ja_jp.euc':                            'ja_JP.eucJP',
1374    'ja_jp.eucjp':                          'ja_JP.eucJP',
1375    'ja_jp.iso-2022-jp':                    'ja_JP.JIS7',
1376    'ja_jp.iso2022jp':                      'ja_JP.JIS7',
1377    'ja_jp.jis':                            'ja_JP.JIS7',
1378    'ja_jp.jis7':                           'ja_JP.JIS7',
1379    'ja_jp.mscode':                         'ja_JP.SJIS',
1380    'ja_jp.pck':                            'ja_JP.SJIS',
1381    'ja_jp.sjis':                           'ja_JP.SJIS',
1382    'ja_jp.ujis':                           'ja_JP.eucJP',
1383    'japan':                                'ja_JP.eucJP',
1384    'japanese':                             'ja_JP.eucJP',
1385    'japanese-euc':                         'ja_JP.eucJP',
1386    'japanese.euc':                         'ja_JP.eucJP',
1387    'japanese.sjis':                        'ja_JP.SJIS',
1388    'jp_jp':                                'ja_JP.eucJP',
1389    'ka':                                   'ka_GE.GEORGIAN-ACADEMY',
1390    'ka_ge':                                'ka_GE.GEORGIAN-ACADEMY',
1391    'ka_ge.georgianacademy':                'ka_GE.GEORGIAN-ACADEMY',
1392    'ka_ge.georgianps':                     'ka_GE.GEORGIAN-PS',
1393    'ka_ge.georgianrs':                     'ka_GE.GEORGIAN-ACADEMY',
1394    'kab_dz':                               'kab_DZ.UTF-8',
1395    'kk_kz':                                'kk_KZ.ptcp154',
1396    'kl':                                   'kl_GL.ISO8859-1',
1397    'kl_gl':                                'kl_GL.ISO8859-1',
1398    'kl_gl.iso88591':                       'kl_GL.ISO8859-1',
1399    'kl_gl.iso885915':                      'kl_GL.ISO8859-15',
1400    'kl_gl@euro':                           'kl_GL.ISO8859-15',
1401    'km_kh':                                'km_KH.UTF-8',
1402    'kn':                                   'kn_IN.UTF-8',
1403    'kn_in':                                'kn_IN.UTF-8',
1404    'ko':                                   'ko_KR.eucKR',
1405    'ko_kr':                                'ko_KR.eucKR',
1406    'ko_kr.euc':                            'ko_KR.eucKR',
1407    'ko_kr.euckr':                          'ko_KR.eucKR',
1408    'kok_in':                               'kok_IN.UTF-8',
1409    'korean':                               'ko_KR.eucKR',
1410    'korean.euc':                           'ko_KR.eucKR',
1411    'ks':                                   'ks_IN.UTF-8',
1412    'ks_in':                                'ks_IN.UTF-8',
1413    'ks_in.utf8@devanagari':                'ks_IN.UTF-8@devanagari',
1414    'ks_in@devanagari':                     'ks_IN.UTF-8@devanagari',
1415    'ks_in@devanagari.utf8':                'ks_IN.UTF-8@devanagari',
1416    'ku_tr':                                'ku_TR.ISO8859-9',
1417    'kw':                                   'kw_GB.ISO8859-1',
1418    'kw_gb':                                'kw_GB.ISO8859-1',
1419    'kw_gb.iso88591':                       'kw_GB.ISO8859-1',
1420    'kw_gb.iso885914':                      'kw_GB.ISO8859-14',
1421    'kw_gb.iso885915':                      'kw_GB.ISO8859-15',
1422    'kw_gb@euro':                           'kw_GB.ISO8859-15',
1423    'ky':                                   'ky_KG.UTF-8',
1424    'ky_kg':                                'ky_KG.UTF-8',
1425    'lb_lu':                                'lb_LU.UTF-8',
1426    'lg_ug':                                'lg_UG.ISO8859-10',
1427    'li_be':                                'li_BE.UTF-8',
1428    'li_nl':                                'li_NL.UTF-8',
1429    'lij_it':                               'lij_IT.UTF-8',
1430    'lithuanian':                           'lt_LT.ISO8859-13',
1431    'ln_cd':                                'ln_CD.UTF-8',
1432    'lo':                                   'lo_LA.MULELAO-1',
1433    'lo_la':                                'lo_LA.MULELAO-1',
1434    'lo_la.cp1133':                         'lo_LA.IBM-CP1133',
1435    'lo_la.ibmcp1133':                      'lo_LA.IBM-CP1133',
1436    'lo_la.mulelao1':                       'lo_LA.MULELAO-1',
1437    'lt':                                   'lt_LT.ISO8859-13',
1438    'lt_lt':                                'lt_LT.ISO8859-13',
1439    'lt_lt.iso885913':                      'lt_LT.ISO8859-13',
1440    'lt_lt.iso88594':                       'lt_LT.ISO8859-4',
1441    'lv':                                   'lv_LV.ISO8859-13',
1442    'lv_lv':                                'lv_LV.ISO8859-13',
1443    'lv_lv.iso885913':                      'lv_LV.ISO8859-13',
1444    'lv_lv.iso88594':                       'lv_LV.ISO8859-4',
1445    'lzh_tw':                               'lzh_TW.UTF-8',
1446    'mag_in':                               'mag_IN.UTF-8',
1447    'mai':                                  'mai_IN.UTF-8',
1448    'mai_in':                               'mai_IN.UTF-8',
1449    'mai_np':                               'mai_NP.UTF-8',
1450    'mfe_mu':                               'mfe_MU.UTF-8',
1451    'mg_mg':                                'mg_MG.ISO8859-15',
1452    'mhr_ru':                               'mhr_RU.UTF-8',
1453    'mi':                                   'mi_NZ.ISO8859-1',
1454    'mi_nz':                                'mi_NZ.ISO8859-1',
1455    'mi_nz.iso88591':                       'mi_NZ.ISO8859-1',
1456    'miq_ni':                               'miq_NI.UTF-8',
1457    'mjw_in':                               'mjw_IN.UTF-8',
1458    'mk':                                   'mk_MK.ISO8859-5',
1459    'mk_mk':                                'mk_MK.ISO8859-5',
1460    'mk_mk.cp1251':                         'mk_MK.CP1251',
1461    'mk_mk.iso88595':                       'mk_MK.ISO8859-5',
1462    'mk_mk.microsoftcp1251':                'mk_MK.CP1251',
1463    'ml':                                   'ml_IN.UTF-8',
1464    'ml_in':                                'ml_IN.UTF-8',
1465    'mn_mn':                                'mn_MN.UTF-8',
1466    'mni_in':                               'mni_IN.UTF-8',
1467    'mr':                                   'mr_IN.UTF-8',
1468    'mr_in':                                'mr_IN.UTF-8',
1469    'ms':                                   'ms_MY.ISO8859-1',
1470    'ms_my':                                'ms_MY.ISO8859-1',
1471    'ms_my.iso88591':                       'ms_MY.ISO8859-1',
1472    'mt':                                   'mt_MT.ISO8859-3',
1473    'mt_mt':                                'mt_MT.ISO8859-3',
1474    'mt_mt.iso88593':                       'mt_MT.ISO8859-3',
1475    'my_mm':                                'my_MM.UTF-8',
1476    'nan_tw':                               'nan_TW.UTF-8',
1477    'nb':                                   'nb_NO.ISO8859-1',
1478    'nb_no':                                'nb_NO.ISO8859-1',
1479    'nb_no.88591':                          'nb_NO.ISO8859-1',
1480    'nb_no.iso88591':                       'nb_NO.ISO8859-1',
1481    'nb_no.iso885915':                      'nb_NO.ISO8859-15',
1482    'nb_no@euro':                           'nb_NO.ISO8859-15',
1483    'nds_de':                               'nds_DE.UTF-8',
1484    'nds_nl':                               'nds_NL.UTF-8',
1485    'ne_np':                                'ne_NP.UTF-8',
1486    'nhn_mx':                               'nhn_MX.UTF-8',
1487    'niu_nu':                               'niu_NU.UTF-8',
1488    'niu_nz':                               'niu_NZ.UTF-8',
1489    'nl':                                   'nl_NL.ISO8859-1',
1490    'nl.iso885915':                         'nl_NL.ISO8859-15',
1491    'nl_aw':                                'nl_AW.UTF-8',
1492    'nl_be':                                'nl_BE.ISO8859-1',
1493    'nl_be.88591':                          'nl_BE.ISO8859-1',
1494    'nl_be.iso88591':                       'nl_BE.ISO8859-1',
1495    'nl_be.iso885915':                      'nl_BE.ISO8859-15',
1496    'nl_be.iso885915@euro':                 'nl_BE.ISO8859-15',
1497    'nl_be.utf8@euro':                      'nl_BE.UTF-8',
1498    'nl_be@euro':                           'nl_BE.ISO8859-15',
1499    'nl_nl':                                'nl_NL.ISO8859-1',
1500    'nl_nl.88591':                          'nl_NL.ISO8859-1',
1501    'nl_nl.iso88591':                       'nl_NL.ISO8859-1',
1502    'nl_nl.iso885915':                      'nl_NL.ISO8859-15',
1503    'nl_nl.iso885915@euro':                 'nl_NL.ISO8859-15',
1504    'nl_nl.utf8@euro':                      'nl_NL.UTF-8',
1505    'nl_nl@euro':                           'nl_NL.ISO8859-15',
1506    'nn':                                   'nn_NO.ISO8859-1',
1507    'nn_no':                                'nn_NO.ISO8859-1',
1508    'nn_no.88591':                          'nn_NO.ISO8859-1',
1509    'nn_no.iso88591':                       'nn_NO.ISO8859-1',
1510    'nn_no.iso885915':                      'nn_NO.ISO8859-15',
1511    'nn_no@euro':                           'nn_NO.ISO8859-15',
1512    'no':                                   'no_NO.ISO8859-1',
1513    'no@nynorsk':                           'ny_NO.ISO8859-1',
1514    'no_no':                                'no_NO.ISO8859-1',
1515    'no_no.88591':                          'no_NO.ISO8859-1',
1516    'no_no.iso88591':                       'no_NO.ISO8859-1',
1517    'no_no.iso885915':                      'no_NO.ISO8859-15',
1518    'no_no.iso88591@bokmal':                'no_NO.ISO8859-1',
1519    'no_no.iso88591@nynorsk':               'no_NO.ISO8859-1',
1520    'no_no@euro':                           'no_NO.ISO8859-15',
1521    'norwegian':                            'no_NO.ISO8859-1',
1522    'norwegian.iso88591':                   'no_NO.ISO8859-1',
1523    'nr':                                   'nr_ZA.ISO8859-1',
1524    'nr_za':                                'nr_ZA.ISO8859-1',
1525    'nr_za.iso88591':                       'nr_ZA.ISO8859-1',
1526    'nso':                                  'nso_ZA.ISO8859-15',
1527    'nso_za':                               'nso_ZA.ISO8859-15',
1528    'nso_za.iso885915':                     'nso_ZA.ISO8859-15',
1529    'ny':                                   'ny_NO.ISO8859-1',
1530    'ny_no':                                'ny_NO.ISO8859-1',
1531    'ny_no.88591':                          'ny_NO.ISO8859-1',
1532    'ny_no.iso88591':                       'ny_NO.ISO8859-1',
1533    'ny_no.iso885915':                      'ny_NO.ISO8859-15',
1534    'ny_no@euro':                           'ny_NO.ISO8859-15',
1535    'nynorsk':                              'nn_NO.ISO8859-1',
1536    'oc':                                   'oc_FR.ISO8859-1',
1537    'oc_fr':                                'oc_FR.ISO8859-1',
1538    'oc_fr.iso88591':                       'oc_FR.ISO8859-1',
1539    'oc_fr.iso885915':                      'oc_FR.ISO8859-15',
1540    'oc_fr@euro':                           'oc_FR.ISO8859-15',
1541    'om_et':                                'om_ET.UTF-8',
1542    'om_ke':                                'om_KE.ISO8859-1',
1543    'or':                                   'or_IN.UTF-8',
1544    'or_in':                                'or_IN.UTF-8',
1545    'os_ru':                                'os_RU.UTF-8',
1546    'pa':                                   'pa_IN.UTF-8',
1547    'pa_in':                                'pa_IN.UTF-8',
1548    'pa_pk':                                'pa_PK.UTF-8',
1549    'pap_an':                               'pap_AN.UTF-8',
1550    'pap_aw':                               'pap_AW.UTF-8',
1551    'pap_cw':                               'pap_CW.UTF-8',
1552    'pd':                                   'pd_US.ISO8859-1',
1553    'pd_de':                                'pd_DE.ISO8859-1',
1554    'pd_de.iso88591':                       'pd_DE.ISO8859-1',
1555    'pd_de.iso885915':                      'pd_DE.ISO8859-15',
1556    'pd_de@euro':                           'pd_DE.ISO8859-15',
1557    'pd_us':                                'pd_US.ISO8859-1',
1558    'pd_us.iso88591':                       'pd_US.ISO8859-1',
1559    'pd_us.iso885915':                      'pd_US.ISO8859-15',
1560    'pd_us@euro':                           'pd_US.ISO8859-15',
1561    'ph':                                   'ph_PH.ISO8859-1',
1562    'ph_ph':                                'ph_PH.ISO8859-1',
1563    'ph_ph.iso88591':                       'ph_PH.ISO8859-1',
1564    'pl':                                   'pl_PL.ISO8859-2',
1565    'pl_pl':                                'pl_PL.ISO8859-2',
1566    'pl_pl.iso88592':                       'pl_PL.ISO8859-2',
1567    'polish':                               'pl_PL.ISO8859-2',
1568    'portuguese':                           'pt_PT.ISO8859-1',
1569    'portuguese.iso88591':                  'pt_PT.ISO8859-1',
1570    'portuguese_brazil':                    'pt_BR.ISO8859-1',
1571    'portuguese_brazil.8859':               'pt_BR.ISO8859-1',
1572    'posix':                                'C',
1573    'posix-utf2':                           'C',
1574    'pp':                                   'pp_AN.ISO8859-1',
1575    'pp_an':                                'pp_AN.ISO8859-1',
1576    'pp_an.iso88591':                       'pp_AN.ISO8859-1',
1577    'ps_af':                                'ps_AF.UTF-8',
1578    'pt':                                   'pt_PT.ISO8859-1',
1579    'pt.iso885915':                         'pt_PT.ISO8859-15',
1580    'pt_br':                                'pt_BR.ISO8859-1',
1581    'pt_br.88591':                          'pt_BR.ISO8859-1',
1582    'pt_br.iso88591':                       'pt_BR.ISO8859-1',
1583    'pt_br.iso885915':                      'pt_BR.ISO8859-15',
1584    'pt_br@euro':                           'pt_BR.ISO8859-15',
1585    'pt_pt':                                'pt_PT.ISO8859-1',
1586    'pt_pt.88591':                          'pt_PT.ISO8859-1',
1587    'pt_pt.iso88591':                       'pt_PT.ISO8859-1',
1588    'pt_pt.iso885915':                      'pt_PT.ISO8859-15',
1589    'pt_pt.iso885915@euro':                 'pt_PT.ISO8859-15',
1590    'pt_pt.utf8@euro':                      'pt_PT.UTF-8',
1591    'pt_pt@euro':                           'pt_PT.ISO8859-15',
1592    'quz_pe':                               'quz_PE.UTF-8',
1593    'raj_in':                               'raj_IN.UTF-8',
1594    'ro':                                   'ro_RO.ISO8859-2',
1595    'ro_ro':                                'ro_RO.ISO8859-2',
1596    'ro_ro.iso88592':                       'ro_RO.ISO8859-2',
1597    'romanian':                             'ro_RO.ISO8859-2',
1598    'ru':                                   'ru_RU.UTF-8',
1599    'ru.koi8r':                             'ru_RU.KOI8-R',
1600    'ru_ru':                                'ru_RU.UTF-8',
1601    'ru_ru.cp1251':                         'ru_RU.CP1251',
1602    'ru_ru.iso88595':                       'ru_RU.ISO8859-5',
1603    'ru_ru.koi8r':                          'ru_RU.KOI8-R',
1604    'ru_ru.microsoftcp1251':                'ru_RU.CP1251',
1605    'ru_ua':                                'ru_UA.KOI8-U',
1606    'ru_ua.cp1251':                         'ru_UA.CP1251',
1607    'ru_ua.koi8u':                          'ru_UA.KOI8-U',
1608    'ru_ua.microsoftcp1251':                'ru_UA.CP1251',
1609    'rumanian':                             'ro_RO.ISO8859-2',
1610    'russian':                              'ru_RU.KOI8-R',
1611    'rw':                                   'rw_RW.ISO8859-1',
1612    'rw_rw':                                'rw_RW.ISO8859-1',
1613    'rw_rw.iso88591':                       'rw_RW.ISO8859-1',
1614    'sa_in':                                'sa_IN.UTF-8',
1615    'sat_in':                               'sat_IN.UTF-8',
1616    'sc_it':                                'sc_IT.UTF-8',
1617    'sd':                                   'sd_IN.UTF-8',
1618    'sd@devanagari':                        'sd_IN.UTF-8@devanagari',
1619    'sd_in':                                'sd_IN.UTF-8',
1620    'sd_in.utf8@devanagari':                'sd_IN.UTF-8@devanagari',
1621    'sd_in@devanagari':                     'sd_IN.UTF-8@devanagari',
1622    'sd_in@devanagari.utf8':                'sd_IN.UTF-8@devanagari',
1623    'sd_pk':                                'sd_PK.UTF-8',
1624    'se_no':                                'se_NO.UTF-8',
1625    'serbocroatian':                        'sr_RS.UTF-8@latin',
1626    'sgs_lt':                               'sgs_LT.UTF-8',
1627    'sh':                                   'sr_RS.UTF-8@latin',
1628    'sh_ba.iso88592@bosnia':                'sr_CS.ISO8859-2',
1629    'sh_hr':                                'sh_HR.ISO8859-2',
1630    'sh_hr.iso88592':                       'hr_HR.ISO8859-2',
1631    'sh_sp':                                'sr_CS.ISO8859-2',
1632    'sh_yu':                                'sr_RS.UTF-8@latin',
1633    'shn_mm':                               'shn_MM.UTF-8',
1634    'shs_ca':                               'shs_CA.UTF-8',
1635    'si':                                   'si_LK.UTF-8',
1636    'si_lk':                                'si_LK.UTF-8',
1637    'sid_et':                               'sid_ET.UTF-8',
1638    'sinhala':                              'si_LK.UTF-8',
1639    'sk':                                   'sk_SK.ISO8859-2',
1640    'sk_sk':                                'sk_SK.ISO8859-2',
1641    'sk_sk.iso88592':                       'sk_SK.ISO8859-2',
1642    'sl':                                   'sl_SI.ISO8859-2',
1643    'sl_cs':                                'sl_CS.ISO8859-2',
1644    'sl_si':                                'sl_SI.ISO8859-2',
1645    'sl_si.iso88592':                       'sl_SI.ISO8859-2',
1646    'slovak':                               'sk_SK.ISO8859-2',
1647    'slovene':                              'sl_SI.ISO8859-2',
1648    'slovenian':                            'sl_SI.ISO8859-2',
1649    'sm_ws':                                'sm_WS.UTF-8',
1650    'so_dj':                                'so_DJ.ISO8859-1',
1651    'so_et':                                'so_ET.UTF-8',
1652    'so_ke':                                'so_KE.ISO8859-1',
1653    'so_so':                                'so_SO.ISO8859-1',
1654    'sp':                                   'sr_CS.ISO8859-5',
1655    'sp_yu':                                'sr_CS.ISO8859-5',
1656    'spanish':                              'es_ES.ISO8859-1',
1657    'spanish.iso88591':                     'es_ES.ISO8859-1',
1658    'spanish_spain':                        'es_ES.ISO8859-1',
1659    'spanish_spain.8859':                   'es_ES.ISO8859-1',
1660    'sq':                                   'sq_AL.ISO8859-2',
1661    'sq_al':                                'sq_AL.ISO8859-2',
1662    'sq_al.iso88592':                       'sq_AL.ISO8859-2',
1663    'sq_mk':                                'sq_MK.UTF-8',
1664    'sr':                                   'sr_RS.UTF-8',
1665    'sr@cyrillic':                          'sr_RS.UTF-8',
1666    'sr@latin':                             'sr_RS.UTF-8@latin',
1667    'sr@latn':                              'sr_CS.UTF-8@latin',
1668    'sr_cs':                                'sr_CS.UTF-8',
1669    'sr_cs.iso88592':                       'sr_CS.ISO8859-2',
1670    'sr_cs.iso88592@latn':                  'sr_CS.ISO8859-2',
1671    'sr_cs.iso88595':                       'sr_CS.ISO8859-5',
1672    'sr_cs.utf8@latn':                      'sr_CS.UTF-8@latin',
1673    'sr_cs@latn':                           'sr_CS.UTF-8@latin',
1674    'sr_me':                                'sr_ME.UTF-8',
1675    'sr_rs':                                'sr_RS.UTF-8',
1676    'sr_rs.utf8@latn':                      'sr_RS.UTF-8@latin',
1677    'sr_rs@latin':                          'sr_RS.UTF-8@latin',
1678    'sr_rs@latn':                           'sr_RS.UTF-8@latin',
1679    'sr_sp':                                'sr_CS.ISO8859-2',
1680    'sr_yu':                                'sr_RS.UTF-8@latin',
1681    'sr_yu.cp1251@cyrillic':                'sr_CS.CP1251',
1682    'sr_yu.iso88592':                       'sr_CS.ISO8859-2',
1683    'sr_yu.iso88595':                       'sr_CS.ISO8859-5',
1684    'sr_yu.iso88595@cyrillic':              'sr_CS.ISO8859-5',
1685    'sr_yu.microsoftcp1251@cyrillic':       'sr_CS.CP1251',
1686    'sr_yu.utf8':                           'sr_RS.UTF-8',
1687    'sr_yu.utf8@cyrillic':                  'sr_RS.UTF-8',
1688    'sr_yu@cyrillic':                       'sr_RS.UTF-8',
1689    'ss':                                   'ss_ZA.ISO8859-1',
1690    'ss_za':                                'ss_ZA.ISO8859-1',
1691    'ss_za.iso88591':                       'ss_ZA.ISO8859-1',
1692    'st':                                   'st_ZA.ISO8859-1',
1693    'st_za':                                'st_ZA.ISO8859-1',
1694    'st_za.iso88591':                       'st_ZA.ISO8859-1',
1695    'sv':                                   'sv_SE.ISO8859-1',
1696    'sv.iso885915':                         'sv_SE.ISO8859-15',
1697    'sv_fi':                                'sv_FI.ISO8859-1',
1698    'sv_fi.iso88591':                       'sv_FI.ISO8859-1',
1699    'sv_fi.iso885915':                      'sv_FI.ISO8859-15',
1700    'sv_fi.iso885915@euro':                 'sv_FI.ISO8859-15',
1701    'sv_fi.utf8@euro':                      'sv_FI.UTF-8',
1702    'sv_fi@euro':                           'sv_FI.ISO8859-15',
1703    'sv_se':                                'sv_SE.ISO8859-1',
1704    'sv_se.88591':                          'sv_SE.ISO8859-1',
1705    'sv_se.iso88591':                       'sv_SE.ISO8859-1',
1706    'sv_se.iso885915':                      'sv_SE.ISO8859-15',
1707    'sv_se@euro':                           'sv_SE.ISO8859-15',
1708    'sw_ke':                                'sw_KE.UTF-8',
1709    'sw_tz':                                'sw_TZ.UTF-8',
1710    'swedish':                              'sv_SE.ISO8859-1',
1711    'swedish.iso88591':                     'sv_SE.ISO8859-1',
1712    'szl_pl':                               'szl_PL.UTF-8',
1713    'ta':                                   'ta_IN.TSCII-0',
1714    'ta_in':                                'ta_IN.TSCII-0',
1715    'ta_in.tscii':                          'ta_IN.TSCII-0',
1716    'ta_in.tscii0':                         'ta_IN.TSCII-0',
1717    'ta_lk':                                'ta_LK.UTF-8',
1718    'tcy_in.utf8':                          'tcy_IN.UTF-8',
1719    'te':                                   'te_IN.UTF-8',
1720    'te_in':                                'te_IN.UTF-8',
1721    'tg':                                   'tg_TJ.KOI8-C',
1722    'tg_tj':                                'tg_TJ.KOI8-C',
1723    'tg_tj.koi8c':                          'tg_TJ.KOI8-C',
1724    'th':                                   'th_TH.ISO8859-11',
1725    'th_th':                                'th_TH.ISO8859-11',
1726    'th_th.iso885911':                      'th_TH.ISO8859-11',
1727    'th_th.tactis':                         'th_TH.TIS620',
1728    'th_th.tis620':                         'th_TH.TIS620',
1729    'thai':                                 'th_TH.ISO8859-11',
1730    'the_np':                               'the_NP.UTF-8',
1731    'ti_er':                                'ti_ER.UTF-8',
1732    'ti_et':                                'ti_ET.UTF-8',
1733    'tig_er':                               'tig_ER.UTF-8',
1734    'tk_tm':                                'tk_TM.UTF-8',
1735    'tl':                                   'tl_PH.ISO8859-1',
1736    'tl_ph':                                'tl_PH.ISO8859-1',
1737    'tl_ph.iso88591':                       'tl_PH.ISO8859-1',
1738    'tn':                                   'tn_ZA.ISO8859-15',
1739    'tn_za':                                'tn_ZA.ISO8859-15',
1740    'tn_za.iso885915':                      'tn_ZA.ISO8859-15',
1741    'to_to':                                'to_TO.UTF-8',
1742    'tpi_pg':                               'tpi_PG.UTF-8',
1743    'tr':                                   'tr_TR.ISO8859-9',
1744    'tr_cy':                                'tr_CY.ISO8859-9',
1745    'tr_tr':                                'tr_TR.ISO8859-9',
1746    'tr_tr.iso88599':                       'tr_TR.ISO8859-9',
1747    'ts':                                   'ts_ZA.ISO8859-1',
1748    'ts_za':                                'ts_ZA.ISO8859-1',
1749    'ts_za.iso88591':                       'ts_ZA.ISO8859-1',
1750    'tt':                                   'tt_RU.TATAR-CYR',
1751    'tt_ru':                                'tt_RU.TATAR-CYR',
1752    'tt_ru.koi8c':                          'tt_RU.KOI8-C',
1753    'tt_ru.tatarcyr':                       'tt_RU.TATAR-CYR',
1754    'tt_ru@iqtelif':                        'tt_RU.UTF-8@iqtelif',
1755    'turkish':                              'tr_TR.ISO8859-9',
1756    'turkish.iso88599':                     'tr_TR.ISO8859-9',
1757    'ug_cn':                                'ug_CN.UTF-8',
1758    'uk':                                   'uk_UA.KOI8-U',
1759    'uk_ua':                                'uk_UA.KOI8-U',
1760    'uk_ua.cp1251':                         'uk_UA.CP1251',
1761    'uk_ua.iso88595':                       'uk_UA.ISO8859-5',
1762    'uk_ua.koi8u':                          'uk_UA.KOI8-U',
1763    'uk_ua.microsoftcp1251':                'uk_UA.CP1251',
1764    'univ':                                 'en_US.utf',
1765    'universal':                            'en_US.utf',
1766    'universal.utf8@ucs4':                  'en_US.UTF-8',
1767    'unm_us':                               'unm_US.UTF-8',
1768    'ur':                                   'ur_PK.CP1256',
1769    'ur_in':                                'ur_IN.UTF-8',
1770    'ur_pk':                                'ur_PK.CP1256',
1771    'ur_pk.cp1256':                         'ur_PK.CP1256',
1772    'ur_pk.microsoftcp1256':                'ur_PK.CP1256',
1773    'uz':                                   'uz_UZ.UTF-8',
1774    'uz_uz':                                'uz_UZ.UTF-8',
1775    'uz_uz.iso88591':                       'uz_UZ.ISO8859-1',
1776    'uz_uz.utf8@cyrillic':                  'uz_UZ.UTF-8',
1777    'uz_uz@cyrillic':                       'uz_UZ.UTF-8',
1778    've':                                   've_ZA.UTF-8',
1779    've_za':                                've_ZA.UTF-8',
1780    'vi':                                   'vi_VN.TCVN',
1781    'vi_vn':                                'vi_VN.TCVN',
1782    'vi_vn.tcvn':                           'vi_VN.TCVN',
1783    'vi_vn.tcvn5712':                       'vi_VN.TCVN',
1784    'vi_vn.viscii':                         'vi_VN.VISCII',
1785    'vi_vn.viscii111':                      'vi_VN.VISCII',
1786    'wa':                                   'wa_BE.ISO8859-1',
1787    'wa_be':                                'wa_BE.ISO8859-1',
1788    'wa_be.iso88591':                       'wa_BE.ISO8859-1',
1789    'wa_be.iso885915':                      'wa_BE.ISO8859-15',
1790    'wa_be.iso885915@euro':                 'wa_BE.ISO8859-15',
1791    'wa_be@euro':                           'wa_BE.ISO8859-15',
1792    'wae_ch':                               'wae_CH.UTF-8',
1793    'wal_et':                               'wal_ET.UTF-8',
1794    'wo_sn':                                'wo_SN.UTF-8',
1795    'xh':                                   'xh_ZA.ISO8859-1',
1796    'xh_za':                                'xh_ZA.ISO8859-1',
1797    'xh_za.iso88591':                       'xh_ZA.ISO8859-1',
1798    'yi':                                   'yi_US.CP1255',
1799    'yi_us':                                'yi_US.CP1255',
1800    'yi_us.cp1255':                         'yi_US.CP1255',
1801    'yi_us.microsoftcp1255':                'yi_US.CP1255',
1802    'yo_ng':                                'yo_NG.UTF-8',
1803    'yue_hk':                               'yue_HK.UTF-8',
1804    'yuw_pg':                               'yuw_PG.UTF-8',
1805    'zh':                                   'zh_CN.eucCN',
1806    'zh_cn':                                'zh_CN.gb2312',
1807    'zh_cn.big5':                           'zh_TW.big5',
1808    'zh_cn.euc':                            'zh_CN.eucCN',
1809    'zh_cn.gb18030':                        'zh_CN.gb18030',
1810    'zh_cn.gb2312':                         'zh_CN.gb2312',
1811    'zh_cn.gbk':                            'zh_CN.gbk',
1812    'zh_hk':                                'zh_HK.big5hkscs',
1813    'zh_hk.big5':                           'zh_HK.big5',
1814    'zh_hk.big5hk':                         'zh_HK.big5hkscs',
1815    'zh_hk.big5hkscs':                      'zh_HK.big5hkscs',
1816    'zh_sg':                                'zh_SG.GB2312',
1817    'zh_sg.gbk':                            'zh_SG.GBK',
1818    'zh_tw':                                'zh_TW.big5',
1819    'zh_tw.big5':                           'zh_TW.big5',
1820    'zh_tw.euc':                            'zh_TW.eucTW',
1821    'zh_tw.euctw':                          'zh_TW.eucTW',
1822    'zu':                                   'zu_ZA.ISO8859-1',
1823    'zu_za':                                'zu_ZA.ISO8859-1',
1824    'zu_za.iso88591':                       'zu_ZA.ISO8859-1',
1825}
1826
1827#
1828# This maps Windows language identifiers to locale strings.
1829#
1830# This list has been updated from
1831# http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nls_238z.asp
1832# to include every locale up to Windows Vista.
1833#
1834# NOTE: this mapping is incomplete.  If your language is missing, please
1835# submit a bug report to the Python bug tracker at http://bugs.python.org/
1836# Make sure you include the missing language identifier and the suggested
1837# locale code.
1838#
1839
1840windows_locale = {
1841    0x0436: "af_ZA", # Afrikaans
1842    0x041c: "sq_AL", # Albanian
1843    0x0484: "gsw_FR",# Alsatian - France
1844    0x045e: "am_ET", # Amharic - Ethiopia
1845    0x0401: "ar_SA", # Arabic - Saudi Arabia
1846    0x0801: "ar_IQ", # Arabic - Iraq
1847    0x0c01: "ar_EG", # Arabic - Egypt
1848    0x1001: "ar_LY", # Arabic - Libya
1849    0x1401: "ar_DZ", # Arabic - Algeria
1850    0x1801: "ar_MA", # Arabic - Morocco
1851    0x1c01: "ar_TN", # Arabic - Tunisia
1852    0x2001: "ar_OM", # Arabic - Oman
1853    0x2401: "ar_YE", # Arabic - Yemen
1854    0x2801: "ar_SY", # Arabic - Syria
1855    0x2c01: "ar_JO", # Arabic - Jordan
1856    0x3001: "ar_LB", # Arabic - Lebanon
1857    0x3401: "ar_KW", # Arabic - Kuwait
1858    0x3801: "ar_AE", # Arabic - United Arab Emirates
1859    0x3c01: "ar_BH", # Arabic - Bahrain
1860    0x4001: "ar_QA", # Arabic - Qatar
1861    0x042b: "hy_AM", # Armenian
1862    0x044d: "as_IN", # Assamese - India
1863    0x042c: "az_AZ", # Azeri - Latin
1864    0x082c: "az_AZ", # Azeri - Cyrillic
1865    0x046d: "ba_RU", # Bashkir
1866    0x042d: "eu_ES", # Basque - Russia
1867    0x0423: "be_BY", # Belarusian
1868    0x0445: "bn_IN", # Begali
1869    0x201a: "bs_BA", # Bosnian - Cyrillic
1870    0x141a: "bs_BA", # Bosnian - Latin
1871    0x047e: "br_FR", # Breton - France
1872    0x0402: "bg_BG", # Bulgarian
1873#    0x0455: "my_MM", # Burmese - Not supported
1874    0x0403: "ca_ES", # Catalan
1875    0x0004: "zh_CHS",# Chinese - Simplified
1876    0x0404: "zh_TW", # Chinese - Taiwan
1877    0x0804: "zh_CN", # Chinese - PRC
1878    0x0c04: "zh_HK", # Chinese - Hong Kong S.A.R.
1879    0x1004: "zh_SG", # Chinese - Singapore
1880    0x1404: "zh_MO", # Chinese - Macao S.A.R.
1881    0x7c04: "zh_CHT",# Chinese - Traditional
1882    0x0483: "co_FR", # Corsican - France
1883    0x041a: "hr_HR", # Croatian
1884    0x101a: "hr_BA", # Croatian - Bosnia
1885    0x0405: "cs_CZ", # Czech
1886    0x0406: "da_DK", # Danish
1887    0x048c: "gbz_AF",# Dari - Afghanistan
1888    0x0465: "div_MV",# Divehi - Maldives
1889    0x0413: "nl_NL", # Dutch - The Netherlands
1890    0x0813: "nl_BE", # Dutch - Belgium
1891    0x0409: "en_US", # English - United States
1892    0x0809: "en_GB", # English - United Kingdom
1893    0x0c09: "en_AU", # English - Australia
1894    0x1009: "en_CA", # English - Canada
1895    0x1409: "en_NZ", # English - New Zealand
1896    0x1809: "en_IE", # English - Ireland
1897    0x1c09: "en_ZA", # English - South Africa
1898    0x2009: "en_JA", # English - Jamaica
1899    0x2409: "en_CB", # English - Caribbean
1900    0x2809: "en_BZ", # English - Belize
1901    0x2c09: "en_TT", # English - Trinidad
1902    0x3009: "en_ZW", # English - Zimbabwe
1903    0x3409: "en_PH", # English - Philippines
1904    0x4009: "en_IN", # English - India
1905    0x4409: "en_MY", # English - Malaysia
1906    0x4809: "en_IN", # English - Singapore
1907    0x0425: "et_EE", # Estonian
1908    0x0438: "fo_FO", # Faroese
1909    0x0464: "fil_PH",# Filipino
1910    0x040b: "fi_FI", # Finnish
1911    0x040c: "fr_FR", # French - France
1912    0x080c: "fr_BE", # French - Belgium
1913    0x0c0c: "fr_CA", # French - Canada
1914    0x100c: "fr_CH", # French - Switzerland
1915    0x140c: "fr_LU", # French - Luxembourg
1916    0x180c: "fr_MC", # French - Monaco
1917    0x0462: "fy_NL", # Frisian - Netherlands
1918    0x0456: "gl_ES", # Galician
1919    0x0437: "ka_GE", # Georgian
1920    0x0407: "de_DE", # German - Germany
1921    0x0807: "de_CH", # German - Switzerland
1922    0x0c07: "de_AT", # German - Austria
1923    0x1007: "de_LU", # German - Luxembourg
1924    0x1407: "de_LI", # German - Liechtenstein
1925    0x0408: "el_GR", # Greek
1926    0x046f: "kl_GL", # Greenlandic - Greenland
1927    0x0447: "gu_IN", # Gujarati
1928    0x0468: "ha_NG", # Hausa - Latin
1929    0x040d: "he_IL", # Hebrew
1930    0x0439: "hi_IN", # Hindi
1931    0x040e: "hu_HU", # Hungarian
1932    0x040f: "is_IS", # Icelandic
1933    0x0421: "id_ID", # Indonesian
1934    0x045d: "iu_CA", # Inuktitut - Syllabics
1935    0x085d: "iu_CA", # Inuktitut - Latin
1936    0x083c: "ga_IE", # Irish - Ireland
1937    0x0410: "it_IT", # Italian - Italy
1938    0x0810: "it_CH", # Italian - Switzerland
1939    0x0411: "ja_JP", # Japanese
1940    0x044b: "kn_IN", # Kannada - India
1941    0x043f: "kk_KZ", # Kazakh
1942    0x0453: "kh_KH", # Khmer - Cambodia
1943    0x0486: "qut_GT",# K'iche - Guatemala
1944    0x0487: "rw_RW", # Kinyarwanda - Rwanda
1945    0x0457: "kok_IN",# Konkani
1946    0x0412: "ko_KR", # Korean
1947    0x0440: "ky_KG", # Kyrgyz
1948    0x0454: "lo_LA", # Lao - Lao PDR
1949    0x0426: "lv_LV", # Latvian
1950    0x0427: "lt_LT", # Lithuanian
1951    0x082e: "dsb_DE",# Lower Sorbian - Germany
1952    0x046e: "lb_LU", # Luxembourgish
1953    0x042f: "mk_MK", # FYROM Macedonian
1954    0x043e: "ms_MY", # Malay - Malaysia
1955    0x083e: "ms_BN", # Malay - Brunei Darussalam
1956    0x044c: "ml_IN", # Malayalam - India
1957    0x043a: "mt_MT", # Maltese
1958    0x0481: "mi_NZ", # Maori
1959    0x047a: "arn_CL",# Mapudungun
1960    0x044e: "mr_IN", # Marathi
1961    0x047c: "moh_CA",# Mohawk - Canada
1962    0x0450: "mn_MN", # Mongolian - Cyrillic
1963    0x0850: "mn_CN", # Mongolian - PRC
1964    0x0461: "ne_NP", # Nepali
1965    0x0414: "nb_NO", # Norwegian - Bokmal
1966    0x0814: "nn_NO", # Norwegian - Nynorsk
1967    0x0482: "oc_FR", # Occitan - France
1968    0x0448: "or_IN", # Oriya - India
1969    0x0463: "ps_AF", # Pashto - Afghanistan
1970    0x0429: "fa_IR", # Persian
1971    0x0415: "pl_PL", # Polish
1972    0x0416: "pt_BR", # Portuguese - Brazil
1973    0x0816: "pt_PT", # Portuguese - Portugal
1974    0x0446: "pa_IN", # Punjabi
1975    0x046b: "quz_BO",# Quechua (Bolivia)
1976    0x086b: "quz_EC",# Quechua (Ecuador)
1977    0x0c6b: "quz_PE",# Quechua (Peru)
1978    0x0418: "ro_RO", # Romanian - Romania
1979    0x0417: "rm_CH", # Romansh
1980    0x0419: "ru_RU", # Russian
1981    0x243b: "smn_FI",# Sami Finland
1982    0x103b: "smj_NO",# Sami Norway
1983    0x143b: "smj_SE",# Sami Sweden
1984    0x043b: "se_NO", # Sami Northern Norway
1985    0x083b: "se_SE", # Sami Northern Sweden
1986    0x0c3b: "se_FI", # Sami Northern Finland
1987    0x203b: "sms_FI",# Sami Skolt
1988    0x183b: "sma_NO",# Sami Southern Norway
1989    0x1c3b: "sma_SE",# Sami Southern Sweden
1990    0x044f: "sa_IN", # Sanskrit
1991    0x0c1a: "sr_SP", # Serbian - Cyrillic
1992    0x1c1a: "sr_BA", # Serbian - Bosnia Cyrillic
1993    0x081a: "sr_SP", # Serbian - Latin
1994    0x181a: "sr_BA", # Serbian - Bosnia Latin
1995    0x045b: "si_LK", # Sinhala - Sri Lanka
1996    0x046c: "ns_ZA", # Northern Sotho
1997    0x0432: "tn_ZA", # Setswana - Southern Africa
1998    0x041b: "sk_SK", # Slovak
1999    0x0424: "sl_SI", # Slovenian
2000    0x040a: "es_ES", # Spanish - Spain
2001    0x080a: "es_MX", # Spanish - Mexico
2002    0x0c0a: "es_ES", # Spanish - Spain (Modern)
2003    0x100a: "es_GT", # Spanish - Guatemala
2004    0x140a: "es_CR", # Spanish - Costa Rica
2005    0x180a: "es_PA", # Spanish - Panama
2006    0x1c0a: "es_DO", # Spanish - Dominican Republic
2007    0x200a: "es_VE", # Spanish - Venezuela
2008    0x240a: "es_CO", # Spanish - Colombia
2009    0x280a: "es_PE", # Spanish - Peru
2010    0x2c0a: "es_AR", # Spanish - Argentina
2011    0x300a: "es_EC", # Spanish - Ecuador
2012    0x340a: "es_CL", # Spanish - Chile
2013    0x380a: "es_UR", # Spanish - Uruguay
2014    0x3c0a: "es_PY", # Spanish - Paraguay
2015    0x400a: "es_BO", # Spanish - Bolivia
2016    0x440a: "es_SV", # Spanish - El Salvador
2017    0x480a: "es_HN", # Spanish - Honduras
2018    0x4c0a: "es_NI", # Spanish - Nicaragua
2019    0x500a: "es_PR", # Spanish - Puerto Rico
2020    0x540a: "es_US", # Spanish - United States
2021#    0x0430: "", # Sutu - Not supported
2022    0x0441: "sw_KE", # Swahili
2023    0x041d: "sv_SE", # Swedish - Sweden
2024    0x081d: "sv_FI", # Swedish - Finland
2025    0x045a: "syr_SY",# Syriac
2026    0x0428: "tg_TJ", # Tajik - Cyrillic
2027    0x085f: "tmz_DZ",# Tamazight - Latin
2028    0x0449: "ta_IN", # Tamil
2029    0x0444: "tt_RU", # Tatar
2030    0x044a: "te_IN", # Telugu
2031    0x041e: "th_TH", # Thai
2032    0x0851: "bo_BT", # Tibetan - Bhutan
2033    0x0451: "bo_CN", # Tibetan - PRC
2034    0x041f: "tr_TR", # Turkish
2035    0x0442: "tk_TM", # Turkmen - Cyrillic
2036    0x0480: "ug_CN", # Uighur - Arabic
2037    0x0422: "uk_UA", # Ukrainian
2038    0x042e: "wen_DE",# Upper Sorbian - Germany
2039    0x0420: "ur_PK", # Urdu
2040    0x0820: "ur_IN", # Urdu - India
2041    0x0443: "uz_UZ", # Uzbek - Latin
2042    0x0843: "uz_UZ", # Uzbek - Cyrillic
2043    0x042a: "vi_VN", # Vietnamese
2044    0x0452: "cy_GB", # Welsh
2045    0x0488: "wo_SN", # Wolof - Senegal
2046    0x0434: "xh_ZA", # Xhosa - South Africa
2047    0x0485: "sah_RU",# Yakut - Cyrillic
2048    0x0478: "ii_CN", # Yi - PRC
2049    0x046a: "yo_NG", # Yoruba - Nigeria
2050    0x0435: "zu_ZA", # Zulu
2051}
2052
2053def _print_locale():
2054
2055    """ Test function.
2056    """
2057    categories = {}
2058    def _init_categories(categories=categories):
2059        for k,v in globals().items():
2060            if k[:3] == 'LC_':
2061                categories[k] = v
2062    _init_categories()
2063    del categories['LC_ALL']
2064
2065    print 'Locale defaults as determined by getdefaultlocale():'
2066    print '-'*72
2067    lang, enc = getdefaultlocale()
2068    print 'Language: ', lang or '(undefined)'
2069    print 'Encoding: ', enc or '(undefined)'
2070    print
2071
2072    print 'Locale settings on startup:'
2073    print '-'*72
2074    for name,category in categories.items():
2075        print name, '...'
2076        lang, enc = getlocale(category)
2077        print '   Language: ', lang or '(undefined)'
2078        print '   Encoding: ', enc or '(undefined)'
2079        print
2080
2081    print
2082    print 'Locale settings after calling resetlocale():'
2083    print '-'*72
2084    resetlocale()
2085    for name,category in categories.items():
2086        print name, '...'
2087        lang, enc = getlocale(category)
2088        print '   Language: ', lang or '(undefined)'
2089        print '   Encoding: ', enc or '(undefined)'
2090        print
2091
2092    try:
2093        setlocale(LC_ALL, "")
2094    except:
2095        print 'NOTE:'
2096        print 'setlocale(LC_ALL, "") does not support the default locale'
2097        print 'given in the OS environment variables.'
2098    else:
2099        print
2100        print 'Locale settings after calling setlocale(LC_ALL, ""):'
2101        print '-'*72
2102        for name,category in categories.items():
2103            print name, '...'
2104            lang, enc = getlocale(category)
2105            print '   Language: ', lang or '(undefined)'
2106            print '   Encoding: ', enc or '(undefined)'
2107            print
2108
2109###
2110
2111try:
2112    LC_MESSAGES
2113except NameError:
2114    pass
2115else:
2116    __all__.append("LC_MESSAGES")
2117
2118if __name__=='__main__':
2119    print 'Locale aliasing:'
2120    print
2121    _print_locale()
2122    print
2123    print 'Number formatting:'
2124    print
2125    _test()
2126