Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 1 | """ Locale support. |
Guido van Rossum | 4b8c6ea | 2000-02-04 15:39:30 +0000 | [diff] [blame] | 2 | |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 3 | The module provides low-level access to the C lib's locale APIs |
| 4 | and adds high level number formatting APIs as well as a locale |
| 5 | aliasing engine to complement these. |
| 6 | |
| 7 | The aliasing engine includes support for many commonly used locale |
| 8 | names and maps them to values suitable for passing to the C lib's |
| 9 | setlocale() function. It also includes default encodings for all |
| 10 | supported locale names. |
| 11 | |
| 12 | """ |
| 13 | |
R. David Murray | e59482e | 2009-04-01 03:42:00 +0000 | [diff] [blame] | 14 | import sys |
| 15 | import encodings |
| 16 | import encodings.aliases |
| 17 | import re |
| 18 | import collections |
Georg Brandl | 1a3284e | 2007-12-02 09:40:06 +0000 | [diff] [blame] | 19 | from builtins import str as _builtin_str |
Antoine Pitrou | 83d6a87 | 2008-07-25 21:45:08 +0000 | [diff] [blame] | 20 | import functools |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 21 | |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 22 | # Try importing the _locale module. |
| 23 | # |
| 24 | # If this fails, fall back on a basic 'C' locale emulation. |
Guido van Rossum | eef1d4e | 1997-11-19 19:01:43 +0000 | [diff] [blame] | 25 | |
Tim Peters | 1baf829 | 2001-01-24 10:13:46 +0000 | [diff] [blame] | 26 | # Yuck: LC_MESSAGES is non-standard: can't tell whether it exists before |
| 27 | # trying the import. So __all__ is also fiddled at the end of the file. |
Guido van Rossum | 360e4b8 | 2007-05-14 22:51:27 +0000 | [diff] [blame] | 28 | __all__ = ["getlocale", "getdefaultlocale", "getpreferredencoding", "Error", |
| 29 | "setlocale", "resetlocale", "localeconv", "strcoll", "strxfrm", |
| 30 | "str", "atof", "atoi", "format", "format_string", "currency", |
| 31 | "normalize", "LC_CTYPE", "LC_COLLATE", "LC_TIME", "LC_MONETARY", |
| 32 | "LC_NUMERIC", "LC_ALL", "CHAR_MAX"] |
Skip Montanaro | 17ab123 | 2001-01-24 06:27:27 +0000 | [diff] [blame] | 33 | |
Neal Norwitz | 48b98de | 2008-03-10 04:49:25 +0000 | [diff] [blame] | 34 | def _strcoll(a,b): |
| 35 | """ strcoll(string,string) -> int. |
| 36 | Compares two strings according to the locale. |
| 37 | """ |
Mark Dickinson | a56c467 | 2009-01-27 18:17:45 +0000 | [diff] [blame] | 38 | return (a > b) - (a < b) |
Neal Norwitz | 48b98de | 2008-03-10 04:49:25 +0000 | [diff] [blame] | 39 | |
| 40 | def _strxfrm(s): |
| 41 | """ strxfrm(string) -> string. |
| 42 | Returns a string that behaves for cmp locale-aware. |
| 43 | """ |
| 44 | return s |
| 45 | |
Marc-André Lemburg | 2348114 | 2000-06-08 17:49:41 +0000 | [diff] [blame] | 46 | try: |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 47 | |
Marc-André Lemburg | 2348114 | 2000-06-08 17:49:41 +0000 | [diff] [blame] | 48 | from _locale import * |
| 49 | |
Brett Cannon | cd171c8 | 2013-07-04 17:43:24 -0400 | [diff] [blame] | 50 | except ImportError: |
Marc-André Lemburg | 2348114 | 2000-06-08 17:49:41 +0000 | [diff] [blame] | 51 | |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 52 | # Locale emulation |
| 53 | |
Marc-André Lemburg | 2348114 | 2000-06-08 17:49:41 +0000 | [diff] [blame] | 54 | CHAR_MAX = 127 |
| 55 | LC_ALL = 6 |
| 56 | LC_COLLATE = 3 |
| 57 | LC_CTYPE = 0 |
| 58 | LC_MESSAGES = 5 |
| 59 | LC_MONETARY = 4 |
| 60 | LC_NUMERIC = 1 |
| 61 | LC_TIME = 2 |
| 62 | Error = ValueError |
| 63 | |
| 64 | def localeconv(): |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 65 | """ localeconv() -> dict. |
Marc-André Lemburg | 2348114 | 2000-06-08 17:49:41 +0000 | [diff] [blame] | 66 | Returns numeric and monetary locale-specific parameters. |
| 67 | """ |
| 68 | # 'C' locale default values |
| 69 | return {'grouping': [127], |
| 70 | 'currency_symbol': '', |
| 71 | 'n_sign_posn': 127, |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 72 | 'p_cs_precedes': 127, |
| 73 | 'n_cs_precedes': 127, |
| 74 | 'mon_grouping': [], |
Marc-André Lemburg | 2348114 | 2000-06-08 17:49:41 +0000 | [diff] [blame] | 75 | 'n_sep_by_space': 127, |
| 76 | 'decimal_point': '.', |
| 77 | 'negative_sign': '', |
| 78 | 'positive_sign': '', |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 79 | 'p_sep_by_space': 127, |
Marc-André Lemburg | 2348114 | 2000-06-08 17:49:41 +0000 | [diff] [blame] | 80 | 'int_curr_symbol': '', |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 81 | 'p_sign_posn': 127, |
Marc-André Lemburg | 2348114 | 2000-06-08 17:49:41 +0000 | [diff] [blame] | 82 | 'thousands_sep': '', |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 83 | 'mon_thousands_sep': '', |
| 84 | 'frac_digits': 127, |
Marc-André Lemburg | 2348114 | 2000-06-08 17:49:41 +0000 | [diff] [blame] | 85 | 'mon_decimal_point': '', |
| 86 | 'int_frac_digits': 127} |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 87 | |
Marc-André Lemburg | 2348114 | 2000-06-08 17:49:41 +0000 | [diff] [blame] | 88 | def setlocale(category, value=None): |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 89 | """ setlocale(integer,string=None) -> string. |
Marc-André Lemburg | 2348114 | 2000-06-08 17:49:41 +0000 | [diff] [blame] | 90 | Activates/queries locale processing. |
| 91 | """ |
Martin v. Löwis | 103d6e7 | 2003-03-30 15:42:13 +0000 | [diff] [blame] | 92 | if value not in (None, '', 'C'): |
Collin Winter | ce36ad8 | 2007-08-30 01:19:48 +0000 | [diff] [blame] | 93 | raise Error('_locale emulation only supports "C" locale') |
Marc-André Lemburg | 2348114 | 2000-06-08 17:49:41 +0000 | [diff] [blame] | 94 | return 'C' |
| 95 | |
Neal Norwitz | 48b98de | 2008-03-10 04:49:25 +0000 | [diff] [blame] | 96 | # These may or may not exist in _locale, so be sure to set them. |
| 97 | if 'strxfrm' not in globals(): |
| 98 | strxfrm = _strxfrm |
| 99 | if 'strcoll' not in globals(): |
| 100 | strcoll = _strcoll |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 101 | |
Antoine Pitrou | 83d6a87 | 2008-07-25 21:45:08 +0000 | [diff] [blame] | 102 | |
| 103 | _localeconv = localeconv |
| 104 | |
| 105 | # With this dict, you can override some items of localeconv's return value. |
| 106 | # This is useful for testing purposes. |
| 107 | _override_localeconv = {} |
| 108 | |
| 109 | @functools.wraps(_localeconv) |
| 110 | def localeconv(): |
| 111 | d = _localeconv() |
| 112 | if _override_localeconv: |
| 113 | d.update(_override_localeconv) |
| 114 | return d |
| 115 | |
| 116 | |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 117 | ### Number formatting APIs |
| 118 | |
| 119 | # Author: Martin von Loewis |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 120 | # improved by Georg Brandl |
Guido van Rossum | eef1d4e | 1997-11-19 19:01:43 +0000 | [diff] [blame] | 121 | |
Antoine Pitrou | 350370c | 2009-03-14 00:13:13 +0000 | [diff] [blame] | 122 | # Iterate over grouping intervals |
| 123 | def _grouping_intervals(grouping): |
Mark Dickinson | bbffb25 | 2009-08-04 21:57:18 +0000 | [diff] [blame] | 124 | last_interval = None |
Antoine Pitrou | 350370c | 2009-03-14 00:13:13 +0000 | [diff] [blame] | 125 | for interval in grouping: |
| 126 | # if grouping is -1, we are done |
| 127 | if interval == CHAR_MAX: |
| 128 | return |
| 129 | # 0: re-use last group ad infinitum |
| 130 | if interval == 0: |
Mark Dickinson | bbffb25 | 2009-08-04 21:57:18 +0000 | [diff] [blame] | 131 | if last_interval is None: |
| 132 | raise ValueError("invalid grouping") |
Antoine Pitrou | 350370c | 2009-03-14 00:13:13 +0000 | [diff] [blame] | 133 | while True: |
| 134 | yield last_interval |
| 135 | yield interval |
| 136 | last_interval = interval |
| 137 | |
Guido van Rossum | eef1d4e | 1997-11-19 19:01:43 +0000 | [diff] [blame] | 138 | #perform the grouping from right to left |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 139 | def _group(s, monetary=False): |
| 140 | conv = localeconv() |
| 141 | thousands_sep = conv[monetary and 'mon_thousands_sep' or 'thousands_sep'] |
| 142 | grouping = conv[monetary and 'mon_grouping' or 'grouping'] |
| 143 | if not grouping: |
| 144 | return (s, 0) |
Martin v. Löwis | 88ad12a | 2001-04-13 08:09:50 +0000 | [diff] [blame] | 145 | if s[-1] == ' ': |
Antoine Pitrou | 350370c | 2009-03-14 00:13:13 +0000 | [diff] [blame] | 146 | stripped = s.rstrip() |
| 147 | right_spaces = s[len(stripped):] |
| 148 | s = stripped |
| 149 | else: |
| 150 | right_spaces = '' |
| 151 | left_spaces = '' |
| 152 | groups = [] |
| 153 | for interval in _grouping_intervals(grouping): |
| 154 | if not s or s[-1] not in "0123456789": |
| 155 | # only non-digit characters remain (sign, spaces) |
| 156 | left_spaces = s |
| 157 | s = '' |
Guido van Rossum | 45e2fbc | 1998-03-26 21:13:24 +0000 | [diff] [blame] | 158 | break |
Antoine Pitrou | 350370c | 2009-03-14 00:13:13 +0000 | [diff] [blame] | 159 | groups.append(s[-interval:]) |
| 160 | s = s[:-interval] |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 161 | if s: |
Antoine Pitrou | 350370c | 2009-03-14 00:13:13 +0000 | [diff] [blame] | 162 | groups.append(s) |
| 163 | groups.reverse() |
| 164 | return ( |
| 165 | left_spaces + thousands_sep.join(groups) + right_spaces, |
Antoine Pitrou | 6cf17aa | 2009-03-18 20:26:42 +0000 | [diff] [blame] | 166 | len(thousands_sep) * (len(groups) - 1) |
Antoine Pitrou | 350370c | 2009-03-14 00:13:13 +0000 | [diff] [blame] | 167 | ) |
| 168 | |
| 169 | # Strip a given amount of excess padding from the given string |
| 170 | def _strip_padding(s, amount): |
| 171 | lpos = 0 |
| 172 | while amount and s[lpos] == ' ': |
| 173 | lpos += 1 |
| 174 | amount -= 1 |
| 175 | rpos = len(s) - 1 |
| 176 | while amount and s[rpos] == ' ': |
| 177 | rpos -= 1 |
| 178 | amount -= 1 |
| 179 | return s[lpos:rpos+1] |
Guido van Rossum | eef1d4e | 1997-11-19 19:01:43 +0000 | [diff] [blame] | 180 | |
R. David Murray | e59482e | 2009-04-01 03:42:00 +0000 | [diff] [blame] | 181 | _percent_re = re.compile(r'%(?:\((?P<key>.*?)\))?' |
| 182 | r'(?P<modifiers>[-#0-9 +*.hlL]*?)[eEfFgGdiouxXcrs%]') |
| 183 | |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 184 | def format(percent, value, grouping=False, monetary=False, *additional): |
| 185 | """Returns the locale-aware substitution of a %? specifier |
| 186 | (percent). |
| 187 | |
| 188 | additional is for format strings which contain one or more |
| 189 | '*' modifiers.""" |
| 190 | # this is only for one-percent-specifier strings and this should be checked |
R. David Murray | e59482e | 2009-04-01 03:42:00 +0000 | [diff] [blame] | 191 | match = _percent_re.match(percent) |
| 192 | if not match or len(match.group())!= len(percent): |
| 193 | raise ValueError(("format() must be given exactly one %%char " |
| 194 | "format specifier, %s not valid") % repr(percent)) |
| 195 | return _format(percent, value, grouping, monetary, *additional) |
| 196 | |
| 197 | def _format(percent, value, grouping=False, monetary=False, *additional): |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 198 | if additional: |
| 199 | formatted = percent % ((value,) + additional) |
| 200 | else: |
| 201 | formatted = percent % value |
| 202 | # floats and decimal ints need special action! |
| 203 | if percent[-1] in 'eEfFgG': |
| 204 | seps = 0 |
| 205 | parts = formatted.split('.') |
| 206 | if grouping: |
| 207 | parts[0], seps = _group(parts[0], monetary=monetary) |
| 208 | decimal_point = localeconv()[monetary and 'mon_decimal_point' |
| 209 | or 'decimal_point'] |
| 210 | formatted = decimal_point.join(parts) |
Antoine Pitrou | 350370c | 2009-03-14 00:13:13 +0000 | [diff] [blame] | 211 | if seps: |
| 212 | formatted = _strip_padding(formatted, seps) |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 213 | elif percent[-1] in 'diu': |
Antoine Pitrou | 350370c | 2009-03-14 00:13:13 +0000 | [diff] [blame] | 214 | seps = 0 |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 215 | if grouping: |
Antoine Pitrou | 350370c | 2009-03-14 00:13:13 +0000 | [diff] [blame] | 216 | formatted, seps = _group(formatted, monetary=monetary) |
| 217 | if seps: |
| 218 | formatted = _strip_padding(formatted, seps) |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 219 | return formatted |
| 220 | |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 221 | def format_string(f, val, grouping=False): |
| 222 | """Formats a string in the same way that the % formatting would use, |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 223 | but takes the current locale into account. |
Guido van Rossum | eef1d4e | 1997-11-19 19:01:43 +0000 | [diff] [blame] | 224 | Grouping is applied if the third parameter is true.""" |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 225 | percents = list(_percent_re.finditer(f)) |
| 226 | new_f = _percent_re.sub('%s', f) |
| 227 | |
R. David Murray | ad78d15 | 2010-04-27 02:45:53 +0000 | [diff] [blame] | 228 | if isinstance(val, collections.Mapping): |
| 229 | new_val = [] |
| 230 | for perc in percents: |
| 231 | if perc.group()[-1]=='%': |
| 232 | new_val.append('%') |
| 233 | else: |
| 234 | new_val.append(format(perc.group(), val, grouping)) |
| 235 | else: |
| 236 | if not isinstance(val, tuple): |
| 237 | val = (val,) |
| 238 | new_val = [] |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 239 | i = 0 |
| 240 | for perc in percents: |
R. David Murray | ad78d15 | 2010-04-27 02:45:53 +0000 | [diff] [blame] | 241 | if perc.group()[-1]=='%': |
| 242 | new_val.append('%') |
| 243 | else: |
| 244 | starcount = perc.group('modifiers').count('*') |
| 245 | new_val.append(_format(perc.group(), |
| 246 | val[i], |
| 247 | grouping, |
| 248 | False, |
| 249 | *val[i+1:i+1+starcount])) |
| 250 | i += (1 + starcount) |
| 251 | val = tuple(new_val) |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 252 | |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 253 | return new_f % val |
Martin v. Löwis | 88ad12a | 2001-04-13 08:09:50 +0000 | [diff] [blame] | 254 | |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 255 | def currency(val, symbol=True, grouping=False, international=False): |
| 256 | """Formats val according to the currency settings |
| 257 | in the current locale.""" |
| 258 | conv = localeconv() |
| 259 | |
| 260 | # check for illegal values |
| 261 | digits = conv[international and 'int_frac_digits' or 'frac_digits'] |
| 262 | if digits == 127: |
| 263 | raise ValueError("Currency formatting is not possible using " |
| 264 | "the 'C' locale.") |
| 265 | |
| 266 | s = format('%%.%if' % digits, abs(val), grouping, monetary=True) |
| 267 | # '<' and '>' are markers if the sign must be inserted between symbol and value |
| 268 | s = '<' + s + '>' |
| 269 | |
| 270 | if symbol: |
| 271 | smb = conv[international and 'int_curr_symbol' or 'currency_symbol'] |
| 272 | precedes = conv[val<0 and 'n_cs_precedes' or 'p_cs_precedes'] |
| 273 | separated = conv[val<0 and 'n_sep_by_space' or 'p_sep_by_space'] |
| 274 | |
| 275 | if precedes: |
| 276 | s = smb + (separated and ' ' or '') + s |
| 277 | else: |
| 278 | s = s + (separated and ' ' or '') + smb |
| 279 | |
| 280 | sign_pos = conv[val<0 and 'n_sign_posn' or 'p_sign_posn'] |
| 281 | sign = conv[val<0 and 'negative_sign' or 'positive_sign'] |
| 282 | |
| 283 | if sign_pos == 0: |
| 284 | s = '(' + s + ')' |
| 285 | elif sign_pos == 1: |
| 286 | s = sign + s |
| 287 | elif sign_pos == 2: |
| 288 | s = s + sign |
| 289 | elif sign_pos == 3: |
| 290 | s = s.replace('<', sign) |
| 291 | elif sign_pos == 4: |
| 292 | s = s.replace('>', sign) |
| 293 | else: |
| 294 | # the default if nothing specified; |
| 295 | # this should be the most fitting sign position |
| 296 | s = sign + s |
| 297 | |
| 298 | return s.replace('<', '').replace('>', '') |
Martin v. Löwis | db78687 | 2001-01-21 18:52:33 +0000 | [diff] [blame] | 299 | |
Guido van Rossum | eef1d4e | 1997-11-19 19:01:43 +0000 | [diff] [blame] | 300 | def str(val): |
| 301 | """Convert float to integer, taking the locale into account.""" |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 302 | return format("%.12g", val) |
Guido van Rossum | eef1d4e | 1997-11-19 19:01:43 +0000 | [diff] [blame] | 303 | |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 304 | def atof(string, func=float): |
Guido van Rossum | eef1d4e | 1997-11-19 19:01:43 +0000 | [diff] [blame] | 305 | "Parses a string as a float according to the locale settings." |
| 306 | #First, get rid of the grouping |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 307 | ts = localeconv()['thousands_sep'] |
| 308 | if ts: |
Skip Montanaro | 249369c | 2004-04-10 16:39:32 +0000 | [diff] [blame] | 309 | string = string.replace(ts, '') |
Guido van Rossum | eef1d4e | 1997-11-19 19:01:43 +0000 | [diff] [blame] | 310 | #next, replace the decimal point with a dot |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 311 | dd = localeconv()['decimal_point'] |
| 312 | if dd: |
Skip Montanaro | 249369c | 2004-04-10 16:39:32 +0000 | [diff] [blame] | 313 | string = string.replace(dd, '.') |
Guido van Rossum | eef1d4e | 1997-11-19 19:01:43 +0000 | [diff] [blame] | 314 | #finally, parse the string |
Skip Montanaro | 249369c | 2004-04-10 16:39:32 +0000 | [diff] [blame] | 315 | return func(string) |
Guido van Rossum | eef1d4e | 1997-11-19 19:01:43 +0000 | [diff] [blame] | 316 | |
| 317 | def atoi(str): |
| 318 | "Converts a string to an integer according to the locale settings." |
Eric S. Raymond | be9b507 | 2001-02-09 10:48:30 +0000 | [diff] [blame] | 319 | return atof(str, int) |
Guido van Rossum | eef1d4e | 1997-11-19 19:01:43 +0000 | [diff] [blame] | 320 | |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 321 | def _test(): |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 322 | setlocale(LC_ALL, "") |
Guido van Rossum | eef1d4e | 1997-11-19 19:01:43 +0000 | [diff] [blame] | 323 | #do grouping |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 324 | s1 = format("%d", 123456789,1) |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 325 | print(s1, "is", atoi(s1)) |
Guido van Rossum | eef1d4e | 1997-11-19 19:01:43 +0000 | [diff] [blame] | 326 | #standard formatting |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 327 | s1 = str(3.14) |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 328 | print(s1, "is", atof(s1)) |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 329 | |
| 330 | ### Locale name aliasing engine |
| 331 | |
| 332 | # Author: Marc-Andre Lemburg, mal@lemburg.com |
Fredrik Lundh | 37a0982 | 2002-10-19 20:19:10 +0000 | [diff] [blame] | 333 | # Various tweaks by Fredrik Lundh <fredrik@pythonware.com> |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 334 | |
| 335 | # store away the low-level version of setlocale (it's |
| 336 | # overridden below) |
| 337 | _setlocale = setlocale |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 338 | |
Serhiy Storchaka | 16f02d2 | 2013-12-19 21:21:40 +0200 | [diff] [blame] | 339 | def _replace_encoding(code, encoding): |
| 340 | if '.' in code: |
| 341 | langname = code[:code.index('.')] |
| 342 | else: |
| 343 | langname = code |
| 344 | # Convert the encoding to a C lib compatible encoding string |
| 345 | norm_encoding = encodings.normalize_encoding(encoding) |
| 346 | #print('norm encoding: %r' % norm_encoding) |
Serhiy Storchaka | 8c4f57d | 2013-12-27 00:56:53 +0200 | [diff] [blame] | 347 | norm_encoding = encodings.aliases.aliases.get(norm_encoding.lower(), |
Serhiy Storchaka | 16f02d2 | 2013-12-19 21:21:40 +0200 | [diff] [blame] | 348 | norm_encoding) |
| 349 | #print('aliased encoding: %r' % norm_encoding) |
Serhiy Storchaka | 8c4f57d | 2013-12-27 00:56:53 +0200 | [diff] [blame] | 350 | encoding = norm_encoding |
| 351 | norm_encoding = norm_encoding.lower() |
| 352 | if norm_encoding in locale_encoding_alias: |
| 353 | encoding = locale_encoding_alias[norm_encoding] |
| 354 | else: |
| 355 | norm_encoding = norm_encoding.replace('_', '') |
| 356 | norm_encoding = norm_encoding.replace('-', '') |
| 357 | if norm_encoding in locale_encoding_alias: |
| 358 | encoding = locale_encoding_alias[norm_encoding] |
Serhiy Storchaka | 16f02d2 | 2013-12-19 21:21:40 +0200 | [diff] [blame] | 359 | #print('found encoding %r' % encoding) |
| 360 | return langname + '.' + encoding |
| 361 | |
Serhiy Storchaka | 8c4f57d | 2013-12-27 00:56:53 +0200 | [diff] [blame] | 362 | def _append_modifier(code, modifier): |
| 363 | if modifier == 'euro': |
| 364 | if '.' not in code: |
| 365 | return code + '.ISO8859-15' |
| 366 | _, _, encoding = code.partition('.') |
| 367 | if encoding in ('ISO8859-15', 'UTF-8'): |
| 368 | return code |
| 369 | if encoding == 'ISO8859-1': |
| 370 | return _replace_encoding(code, 'ISO8859-15') |
| 371 | return code + '@' + modifier |
| 372 | |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 373 | def normalize(localename): |
| 374 | |
| 375 | """ Returns a normalized locale code for the given locale |
| 376 | name. |
| 377 | |
| 378 | The returned locale code is formatted for use with |
| 379 | setlocale(). |
| 380 | |
| 381 | If normalization fails, the original name is returned |
| 382 | unchanged. |
| 383 | |
| 384 | If the given encoding is not known, the function defaults to |
| 385 | the default encoding for the locale code just like setlocale() |
| 386 | does. |
| 387 | |
| 388 | """ |
Serhiy Storchaka | 16f02d2 | 2013-12-19 21:21:40 +0200 | [diff] [blame] | 389 | # Normalize the locale name and extract the encoding and modifier |
| 390 | code = localename.lower() |
| 391 | if ':' in code: |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 392 | # ':' is sometimes used as encoding delimiter. |
Serhiy Storchaka | 16f02d2 | 2013-12-19 21:21:40 +0200 | [diff] [blame] | 393 | code = code.replace(':', '.') |
| 394 | if '@' in code: |
| 395 | code, modifier = code.split('@', 1) |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 396 | else: |
Serhiy Storchaka | 16f02d2 | 2013-12-19 21:21:40 +0200 | [diff] [blame] | 397 | modifier = '' |
| 398 | if '.' in code: |
| 399 | langname, encoding = code.split('.')[:2] |
| 400 | else: |
| 401 | langname = code |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 402 | encoding = '' |
| 403 | |
Serhiy Storchaka | 16f02d2 | 2013-12-19 21:21:40 +0200 | [diff] [blame] | 404 | # First lookup: fullname (possibly with encoding and modifier) |
| 405 | lang_enc = langname |
| 406 | if encoding: |
| 407 | norm_encoding = encoding.replace('-', '') |
| 408 | norm_encoding = norm_encoding.replace('_', '') |
| 409 | lang_enc += '.' + norm_encoding |
| 410 | lookup_name = lang_enc |
| 411 | if modifier: |
| 412 | lookup_name += '@' + modifier |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 413 | code = locale_alias.get(lookup_name, None) |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 414 | if code is not None: |
| 415 | return code |
Serhiy Storchaka | 16f02d2 | 2013-12-19 21:21:40 +0200 | [diff] [blame] | 416 | #print('first lookup failed') |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 417 | |
Serhiy Storchaka | 16f02d2 | 2013-12-19 21:21:40 +0200 | [diff] [blame] | 418 | if modifier: |
| 419 | # Second try: fullname without modifier (possibly with encoding) |
| 420 | code = locale_alias.get(lang_enc, None) |
| 421 | if code is not None: |
| 422 | #print('lookup without modifier succeeded') |
| 423 | if '@' not in code: |
Serhiy Storchaka | 8c4f57d | 2013-12-27 00:56:53 +0200 | [diff] [blame] | 424 | return _append_modifier(code, modifier) |
Serhiy Storchaka | 16f02d2 | 2013-12-19 21:21:40 +0200 | [diff] [blame] | 425 | if code.split('@', 1)[1].lower() == modifier: |
| 426 | return code |
| 427 | #print('second lookup failed') |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 428 | |
Serhiy Storchaka | 16f02d2 | 2013-12-19 21:21:40 +0200 | [diff] [blame] | 429 | if encoding: |
| 430 | # Third try: langname (without encoding, possibly with modifier) |
| 431 | lookup_name = langname |
| 432 | if modifier: |
| 433 | lookup_name += '@' + modifier |
| 434 | code = locale_alias.get(lookup_name, None) |
| 435 | if code is not None: |
| 436 | #print('lookup without encoding succeeded') |
| 437 | if '@' not in code: |
| 438 | return _replace_encoding(code, encoding) |
| 439 | code, modifier = code.split('@', 1) |
| 440 | return _replace_encoding(code, encoding) + '@' + modifier |
| 441 | |
| 442 | if modifier: |
| 443 | # Fourth try: langname (without encoding and modifier) |
| 444 | code = locale_alias.get(langname, None) |
| 445 | if code is not None: |
| 446 | #print('lookup without modifier and encoding succeeded') |
| 447 | if '@' not in code: |
Serhiy Storchaka | 8c4f57d | 2013-12-27 00:56:53 +0200 | [diff] [blame] | 448 | code = _replace_encoding(code, encoding) |
| 449 | return _append_modifier(code, modifier) |
Serhiy Storchaka | 16f02d2 | 2013-12-19 21:21:40 +0200 | [diff] [blame] | 450 | code, defmod = code.split('@', 1) |
| 451 | if defmod.lower() == modifier: |
| 452 | return _replace_encoding(code, encoding) + '@' + defmod |
| 453 | |
| 454 | return localename |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 455 | |
| 456 | def _parse_localename(localename): |
| 457 | |
| 458 | """ Parses the locale code for localename and returns the |
| 459 | result as tuple (language code, encoding). |
| 460 | |
| 461 | The localename is normalized and passed through the locale |
| 462 | alias engine. A ValueError is raised in case the locale name |
| 463 | cannot be parsed. |
| 464 | |
| 465 | The language code corresponds to RFC 1766. code and encoding |
| 466 | can be None in case the values cannot be determined or are |
Jeremy Hylton | a05e293 | 2000-06-28 14:48:01 +0000 | [diff] [blame] | 467 | unknown to this implementation. |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 468 | |
| 469 | """ |
| 470 | code = normalize(localename) |
Georg Brandl | b709c2c | 2006-01-20 09:07:35 +0000 | [diff] [blame] | 471 | if '@' in code: |
Martin v. Löwis | f0a4668 | 2002-11-03 17:20:12 +0000 | [diff] [blame] | 472 | # Deal with locale modifiers |
Serhiy Storchaka | 16f02d2 | 2013-12-19 21:21:40 +0200 | [diff] [blame] | 473 | code, modifier = code.split('@', 1) |
Martin v. Löwis | f0a4668 | 2002-11-03 17:20:12 +0000 | [diff] [blame] | 474 | if modifier == 'euro' and '.' not in code: |
| 475 | # Assume Latin-9 for @euro locales. This is bogus, |
| 476 | # since some systems may use other encodings for these |
| 477 | # locales. Also, we ignore other modifiers. |
| 478 | return code, 'iso-8859-15' |
Tim Peters | 230a60c | 2002-11-09 05:08:07 +0000 | [diff] [blame] | 479 | |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 480 | if '.' in code: |
Raymond Hettinger | 346e67f | 2005-01-01 06:10:26 +0000 | [diff] [blame] | 481 | return tuple(code.split('.')[:2]) |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 482 | elif code == 'C': |
| 483 | return None, None |
Collin Winter | ce36ad8 | 2007-08-30 01:19:48 +0000 | [diff] [blame] | 484 | raise ValueError('unknown locale: %s' % localename) |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 485 | |
| 486 | def _build_localename(localetuple): |
| 487 | |
| 488 | """ Builds a locale code from the given tuple (language code, |
| 489 | encoding). |
| 490 | |
| 491 | No aliasing or normalizing takes place. |
| 492 | |
| 493 | """ |
Petri Lehtinen | 3c85fe0 | 2011-11-04 21:35:07 +0200 | [diff] [blame] | 494 | try: |
| 495 | language, encoding = localetuple |
| 496 | |
| 497 | if language is None: |
| 498 | language = 'C' |
| 499 | if encoding is None: |
| 500 | return language |
| 501 | else: |
| 502 | return language + '.' + encoding |
| 503 | except (TypeError, ValueError): |
| 504 | raise TypeError('Locale must be None, a string, or an iterable of two strings -- language code, encoding.') |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 505 | |
Matthias Klose | f3f231f | 2005-09-20 07:02:49 +0000 | [diff] [blame] | 506 | def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')): |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 507 | |
| 508 | """ Tries to determine the default locale settings and returns |
| 509 | them as tuple (language code, encoding). |
| 510 | |
| 511 | According to POSIX, a program which has not called |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 512 | setlocale(LC_ALL, "") runs using the portable 'C' locale. |
| 513 | Calling setlocale(LC_ALL, "") lets it use the default locale as |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 514 | defined by the LANG variable. Since we don't want to interfere |
Thomas Wouters | 7e47402 | 2000-07-16 12:04:32 +0000 | [diff] [blame] | 515 | with the current locale setting we thus emulate the behavior |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 516 | in the way described above. |
| 517 | |
| 518 | To maintain compatibility with other platforms, not only the |
| 519 | LANG variable is tested, but a list of variables given as |
| 520 | envvars parameter. The first found to be defined will be |
| 521 | used. envvars defaults to the search path used in GNU gettext; |
| 522 | it must always contain the variable name 'LANG'. |
| 523 | |
| 524 | Except for the code 'C', the language code corresponds to RFC |
| 525 | 1766. code and encoding can be None in case the values cannot |
| 526 | be determined. |
| 527 | |
| 528 | """ |
Fredrik Lundh | 0466132 | 2000-07-09 23:16:10 +0000 | [diff] [blame] | 529 | |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 530 | try: |
| 531 | # check if it's supported by the _locale module |
| 532 | import _locale |
| 533 | code, encoding = _locale._getdefaultlocale() |
Fredrik Lundh | 0466132 | 2000-07-09 23:16:10 +0000 | [diff] [blame] | 534 | except (ImportError, AttributeError): |
| 535 | pass |
| 536 | else: |
Fredrik Lundh | 663809e | 2000-07-10 19:32:19 +0000 | [diff] [blame] | 537 | # make sure the code/encoding values are valid |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 538 | if sys.platform == "win32" and code and code[:2] == "0x": |
| 539 | # map windows language identifier to language name |
| 540 | code = windows_locale.get(int(code, 0)) |
Fredrik Lundh | 663809e | 2000-07-10 19:32:19 +0000 | [diff] [blame] | 541 | # ...add other platform-specific processing here, if |
| 542 | # necessary... |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 543 | return code, encoding |
Fredrik Lundh | 0466132 | 2000-07-09 23:16:10 +0000 | [diff] [blame] | 544 | |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 545 | # fall back on POSIX behaviour |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 546 | import os |
| 547 | lookup = os.environ.get |
| 548 | for variable in envvars: |
| 549 | localename = lookup(variable,None) |
Martin v. Löwis | c8ae31d | 2004-07-26 12:45:18 +0000 | [diff] [blame] | 550 | if localename: |
Matthias Klose | f3f231f | 2005-09-20 07:02:49 +0000 | [diff] [blame] | 551 | if variable == 'LANGUAGE': |
| 552 | localename = localename.split(':')[0] |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 553 | break |
| 554 | else: |
| 555 | localename = 'C' |
| 556 | return _parse_localename(localename) |
| 557 | |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 558 | |
| 559 | def getlocale(category=LC_CTYPE): |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 560 | |
| 561 | """ Returns the current setting for the given locale category as |
| 562 | tuple (language code, encoding). |
| 563 | |
| 564 | category may be one of the LC_* value except LC_ALL. It |
| 565 | defaults to LC_CTYPE. |
| 566 | |
| 567 | Except for the code 'C', the language code corresponds to RFC |
| 568 | 1766. code and encoding can be None in case the values cannot |
| 569 | be determined. |
| 570 | |
| 571 | """ |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 572 | localename = _setlocale(category) |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 573 | if category == LC_ALL and ';' in localename: |
Collin Winter | ce36ad8 | 2007-08-30 01:19:48 +0000 | [diff] [blame] | 574 | raise TypeError('category LC_ALL is not supported') |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 575 | return _parse_localename(localename) |
| 576 | |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 577 | def setlocale(category, locale=None): |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 578 | |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 579 | """ Set the locale for the given category. The locale can be |
Petri Lehtinen | 395ca72 | 2011-11-05 10:18:50 +0200 | [diff] [blame] | 580 | a string, an iterable of two strings (language code and encoding), |
| 581 | or None. |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 582 | |
Petri Lehtinen | 395ca72 | 2011-11-05 10:18:50 +0200 | [diff] [blame] | 583 | Iterables are converted to strings using the locale aliasing |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 584 | engine. Locale strings are passed directly to the C lib. |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 585 | |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 586 | category may be given as one of the LC_* values. |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 587 | |
| 588 | """ |
Guido van Rossum | 3172c5d | 2007-10-16 18:12:55 +0000 | [diff] [blame] | 589 | if locale and not isinstance(locale, _builtin_str): |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 590 | # convert to string |
| 591 | locale = normalize(_build_localename(locale)) |
| 592 | return _setlocale(category, locale) |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 593 | |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 594 | def resetlocale(category=LC_ALL): |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 595 | |
| 596 | """ Sets the locale for category to the default setting. |
| 597 | |
| 598 | The default setting is determined by calling |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 599 | getdefaultlocale(). category defaults to LC_ALL. |
| 600 | |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 601 | """ |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 602 | _setlocale(category, _build_localename(getdefaultlocale())) |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 603 | |
Ronald Oussoren | fe8a3d6 | 2009-06-07 15:29:46 +0000 | [diff] [blame] | 604 | if sys.platform.startswith("win"): |
Martin v. Löwis | f0a4668 | 2002-11-03 17:20:12 +0000 | [diff] [blame] | 605 | # On Win32, this will return the ANSI code page |
Martin v. Löwis | f0a4668 | 2002-11-03 17:20:12 +0000 | [diff] [blame] | 606 | def getpreferredencoding(do_setlocale = True): |
| 607 | """Return the charset that the user is likely using.""" |
Antoine Pitrou | fd4722c | 2013-10-12 00:13:50 +0200 | [diff] [blame] | 608 | import _bootlocale |
| 609 | return _bootlocale.getpreferredencoding(False) |
Martin v. Löwis | f0a4668 | 2002-11-03 17:20:12 +0000 | [diff] [blame] | 610 | else: |
| 611 | # On Unix, if CODESET is available, use that. |
| 612 | try: |
| 613 | CODESET |
| 614 | except NameError: |
| 615 | # Fall back to parsing environment variables :-( |
| 616 | def getpreferredencoding(do_setlocale = True): |
| 617 | """Return the charset that the user is likely using, |
| 618 | by looking at environment variables.""" |
Martin v. Löwis | 071ef77 | 2008-03-08 11:24:24 +0000 | [diff] [blame] | 619 | res = getdefaultlocale()[1] |
| 620 | if res is None: |
| 621 | # LANG not set, default conservatively to ASCII |
| 622 | res = 'ascii' |
| 623 | return res |
Martin v. Löwis | f0a4668 | 2002-11-03 17:20:12 +0000 | [diff] [blame] | 624 | else: |
| 625 | def getpreferredencoding(do_setlocale = True): |
| 626 | """Return the charset that the user is likely using, |
| 627 | according to the system configuration.""" |
Antoine Pitrou | fd4722c | 2013-10-12 00:13:50 +0200 | [diff] [blame] | 628 | import _bootlocale |
Martin v. Löwis | f0a4668 | 2002-11-03 17:20:12 +0000 | [diff] [blame] | 629 | if do_setlocale: |
| 630 | oldloc = setlocale(LC_CTYPE) |
Jeroen Ruigrok van der Werven | bcf8506 | 2009-05-06 05:33:24 +0000 | [diff] [blame] | 631 | try: |
| 632 | setlocale(LC_CTYPE, "") |
Jeroen Ruigrok van der Werven | 6ca2e0a | 2009-05-06 13:18:35 +0000 | [diff] [blame] | 633 | except Error: |
Jeroen Ruigrok van der Werven | bcf8506 | 2009-05-06 05:33:24 +0000 | [diff] [blame] | 634 | pass |
Antoine Pitrou | fd4722c | 2013-10-12 00:13:50 +0200 | [diff] [blame] | 635 | result = _bootlocale.getpreferredencoding(False) |
| 636 | if do_setlocale: |
Martin v. Löwis | f0a4668 | 2002-11-03 17:20:12 +0000 | [diff] [blame] | 637 | setlocale(LC_CTYPE, oldloc) |
Antoine Pitrou | 6a448d4 | 2009-10-19 19:43:09 +0000 | [diff] [blame] | 638 | return result |
Tim Peters | 230a60c | 2002-11-09 05:08:07 +0000 | [diff] [blame] | 639 | |
Martin v. Löwis | f0a4668 | 2002-11-03 17:20:12 +0000 | [diff] [blame] | 640 | |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 641 | ### Database |
| 642 | # |
| 643 | # The following data was extracted from the locale.alias file which |
| 644 | # comes with X11 and then hand edited removing the explicit encoding |
| 645 | # definitions and adding some more aliases. The file is usually |
| 646 | # available as /usr/lib/X11/locale/locale.alias. |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 647 | # |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 648 | |
| 649 | # |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 650 | # The local_encoding_alias table maps lowercase encoding alias names |
| 651 | # to C locale encoding names (case-sensitive). Note that normalize() |
| 652 | # first looks up the encoding in the encodings.aliases dictionary and |
| 653 | # then applies this mapping to find the correct C lib name for the |
| 654 | # encoding. |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 655 | # |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 656 | locale_encoding_alias = { |
| 657 | |
| 658 | # Mappings for non-standard encoding names used in locale names |
| 659 | '437': 'C', |
| 660 | 'c': 'C', |
| 661 | 'en': 'ISO8859-1', |
| 662 | 'jis': 'JIS7', |
| 663 | 'jis7': 'JIS7', |
| 664 | 'ajec': 'eucJP', |
Serhiy Storchaka | 8c4f57d | 2013-12-27 00:56:53 +0200 | [diff] [blame] | 665 | 'koi8c': 'KOI8-C', |
| 666 | 'microsoftcp1251': 'CP1251', |
| 667 | 'microsoftcp1255': 'CP1255', |
| 668 | 'microsoftcp1256': 'CP1256', |
| 669 | '88591': 'ISO8859-1', |
| 670 | '88592': 'ISO8859-2', |
| 671 | '88595': 'ISO8859-5', |
| 672 | '885915': 'ISO8859-15', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 673 | |
| 674 | # Mappings from Python codec names to C lib encoding names |
| 675 | 'ascii': 'ISO8859-1', |
| 676 | 'latin_1': 'ISO8859-1', |
| 677 | 'iso8859_1': 'ISO8859-1', |
| 678 | 'iso8859_10': 'ISO8859-10', |
| 679 | 'iso8859_11': 'ISO8859-11', |
| 680 | 'iso8859_13': 'ISO8859-13', |
| 681 | 'iso8859_14': 'ISO8859-14', |
| 682 | 'iso8859_15': 'ISO8859-15', |
Jeroen Ruigrok van der Werven | 4072ff3 | 2009-05-08 14:17:00 +0000 | [diff] [blame] | 683 | 'iso8859_16': 'ISO8859-16', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 684 | 'iso8859_2': 'ISO8859-2', |
| 685 | 'iso8859_3': 'ISO8859-3', |
| 686 | 'iso8859_4': 'ISO8859-4', |
| 687 | 'iso8859_5': 'ISO8859-5', |
| 688 | 'iso8859_6': 'ISO8859-6', |
| 689 | 'iso8859_7': 'ISO8859-7', |
| 690 | 'iso8859_8': 'ISO8859-8', |
| 691 | 'iso8859_9': 'ISO8859-9', |
| 692 | 'iso2022_jp': 'JIS7', |
| 693 | 'shift_jis': 'SJIS', |
| 694 | 'tactis': 'TACTIS', |
| 695 | 'euc_jp': 'eucJP', |
| 696 | 'euc_kr': 'eucKR', |
Ronald Oussoren | 02a67ac | 2011-05-17 12:44:54 +0200 | [diff] [blame] | 697 | 'utf_8': 'UTF-8', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 698 | 'koi8_r': 'KOI8-R', |
| 699 | 'koi8_u': 'KOI8-U', |
Serhiy Storchaka | 8c4f57d | 2013-12-27 00:56:53 +0200 | [diff] [blame] | 700 | 'cp1251': 'CP1251', |
| 701 | 'cp1255': 'CP1255', |
| 702 | 'cp1256': 'CP1256', |
| 703 | |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 704 | # XXX This list is still incomplete. If you know more |
| 705 | # mappings, please file a bug report. Thanks. |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 706 | } |
| 707 | |
Serhiy Storchaka | 8c4f57d | 2013-12-27 00:56:53 +0200 | [diff] [blame] | 708 | for k, v in sorted(locale_encoding_alias.items()): |
| 709 | k = k.replace('_', '') |
| 710 | locale_encoding_alias.setdefault(k, v) |
| 711 | |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 712 | # |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 713 | # The locale_alias table maps lowercase alias names to C locale names |
| 714 | # (case-sensitive). Encodings are always separated from the locale |
| 715 | # name using a dot ('.'); they should only be given in case the |
| 716 | # language name is needed to interpret the given encoding alias |
| 717 | # correctly (CJK codes often have this need). |
| 718 | # |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 719 | # Note that the normalize() function which uses this tables |
| 720 | # removes '_' and '-' characters from the encoding part of the |
| 721 | # locale name before doing the lookup. This saves a lot of |
| 722 | # space in the table. |
| 723 | # |
| 724 | # MAL 2004-12-10: |
| 725 | # Updated alias mapping to most recent locale.alias file |
| 726 | # from X.org distribution using makelocalealias.py. |
| 727 | # |
| 728 | # These are the differences compared to the old mapping (Python 2.4 |
| 729 | # and older): |
| 730 | # |
| 731 | # updated 'bg' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251' |
| 732 | # updated 'bg_bg' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251' |
| 733 | # updated 'bulgarian' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251' |
| 734 | # updated 'cz' -> 'cz_CZ.ISO8859-2' to 'cs_CZ.ISO8859-2' |
| 735 | # updated 'cz_cz' -> 'cz_CZ.ISO8859-2' to 'cs_CZ.ISO8859-2' |
| 736 | # updated 'czech' -> 'cs_CS.ISO8859-2' to 'cs_CZ.ISO8859-2' |
| 737 | # updated 'dutch' -> 'nl_BE.ISO8859-1' to 'nl_NL.ISO8859-1' |
| 738 | # updated 'et' -> 'et_EE.ISO8859-4' to 'et_EE.ISO8859-15' |
| 739 | # updated 'et_ee' -> 'et_EE.ISO8859-4' to 'et_EE.ISO8859-15' |
| 740 | # updated 'fi' -> 'fi_FI.ISO8859-1' to 'fi_FI.ISO8859-15' |
| 741 | # updated 'fi_fi' -> 'fi_FI.ISO8859-1' to 'fi_FI.ISO8859-15' |
| 742 | # updated 'iw' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8' |
| 743 | # updated 'iw_il' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8' |
| 744 | # updated 'japanese' -> 'ja_JP.SJIS' to 'ja_JP.eucJP' |
| 745 | # updated 'lt' -> 'lt_LT.ISO8859-4' to 'lt_LT.ISO8859-13' |
| 746 | # updated 'lv' -> 'lv_LV.ISO8859-4' to 'lv_LV.ISO8859-13' |
| 747 | # updated 'sl' -> 'sl_CS.ISO8859-2' to 'sl_SI.ISO8859-2' |
| 748 | # updated 'slovene' -> 'sl_CS.ISO8859-2' to 'sl_SI.ISO8859-2' |
| 749 | # updated 'th_th' -> 'th_TH.TACTIS' to 'th_TH.ISO8859-11' |
| 750 | # updated 'zh_cn' -> 'zh_CN.eucCN' to 'zh_CN.gb2312' |
| 751 | # updated 'zh_cn.big5' -> 'zh_TW.eucTW' to 'zh_TW.big5' |
| 752 | # updated 'zh_tw' -> 'zh_TW.eucTW' to 'zh_TW.big5' |
| 753 | # |
Georg Brandl | f08a9dd | 2008-06-10 16:57:31 +0000 | [diff] [blame] | 754 | # MAL 2008-05-30: |
| 755 | # Updated alias mapping to most recent locale.alias file |
| 756 | # from X.org distribution using makelocalealias.py. |
| 757 | # |
| 758 | # These are the differences compared to the old mapping (Python 2.5 |
| 759 | # and older): |
| 760 | # |
| 761 | # updated 'cs_cs.iso88592' -> 'cs_CZ.ISO8859-2' to 'cs_CS.ISO8859-2' |
| 762 | # updated 'serbocroatian' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2' |
| 763 | # updated 'sh' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2' |
| 764 | # updated 'sh_hr.iso88592' -> 'sh_HR.ISO8859-2' to 'hr_HR.ISO8859-2' |
| 765 | # updated 'sh_sp' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2' |
| 766 | # updated 'sh_yu' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2' |
| 767 | # updated 'sp' -> 'sp_YU.ISO8859-5' to 'sr_CS.ISO8859-5' |
| 768 | # updated 'sp_yu' -> 'sp_YU.ISO8859-5' to 'sr_CS.ISO8859-5' |
| 769 | # updated 'sr' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5' |
| 770 | # updated 'sr@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5' |
| 771 | # updated 'sr_sp' -> 'sr_SP.ISO8859-2' to 'sr_CS.ISO8859-2' |
| 772 | # updated 'sr_yu' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5' |
| 773 | # updated 'sr_yu.cp1251@cyrillic' -> 'sr_YU.CP1251' to 'sr_CS.CP1251' |
| 774 | # updated 'sr_yu.iso88592' -> 'sr_YU.ISO8859-2' to 'sr_CS.ISO8859-2' |
| 775 | # updated 'sr_yu.iso88595' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5' |
| 776 | # updated 'sr_yu.iso88595@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5' |
| 777 | # updated 'sr_yu.microsoftcp1251@cyrillic' -> 'sr_YU.CP1251' to 'sr_CS.CP1251' |
| 778 | # updated 'sr_yu.utf8@cyrillic' -> 'sr_YU.UTF-8' to 'sr_CS.UTF-8' |
| 779 | # updated 'sr_yu@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5' |
Antoine Pitrou | 0c70d2d | 2010-04-11 22:35:34 +0000 | [diff] [blame] | 780 | # |
| 781 | # AP 2010-04-12: |
| 782 | # Updated alias mapping to most recent locale.alias file |
| 783 | # from X.org distribution using makelocalealias.py. |
| 784 | # |
| 785 | # These are the differences compared to the old mapping (Python 2.6.5 |
| 786 | # and older): |
| 787 | # |
| 788 | # updated 'ru' -> 'ru_RU.ISO8859-5' to 'ru_RU.UTF-8' |
| 789 | # updated 'ru_ru' -> 'ru_RU.ISO8859-5' to 'ru_RU.UTF-8' |
| 790 | # updated 'serbocroatian' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin' |
| 791 | # updated 'sh' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin' |
| 792 | # updated 'sh_yu' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin' |
| 793 | # updated 'sr' -> 'sr_CS.ISO8859-5' to 'sr_RS.UTF-8' |
| 794 | # updated 'sr@cyrillic' -> 'sr_CS.ISO8859-5' to 'sr_RS.UTF-8' |
| 795 | # updated 'sr@latn' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin' |
| 796 | # updated 'sr_cs.utf8@latn' -> 'sr_CS.UTF-8' to 'sr_RS.UTF-8@latin' |
| 797 | # updated 'sr_cs@latn' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin' |
| 798 | # updated 'sr_yu' -> 'sr_CS.ISO8859-5' to 'sr_RS.UTF-8@latin' |
| 799 | # updated 'sr_yu.utf8@cyrillic' -> 'sr_CS.UTF-8' to 'sr_RS.UTF-8' |
| 800 | # updated 'sr_yu@cyrillic' -> 'sr_CS.ISO8859-5' to 'sr_RS.UTF-8' |
| 801 | # |
Serhiy Storchaka | 715233c | 2013-12-20 18:23:26 +0200 | [diff] [blame] | 802 | # SS 2013-12-20: |
| 803 | # Updated alias mapping to most recent locale.alias file |
| 804 | # from X.org distribution using makelocalealias.py. |
| 805 | # |
| 806 | # These are the differences compared to the old mapping (Python 3.3.3 |
| 807 | # and older): |
| 808 | # |
| 809 | # updated 'a3' -> 'a3_AZ.KOI8-C' to 'az_AZ.KOI8-C' |
| 810 | # updated 'a3_az' -> 'a3_AZ.KOI8-C' to 'az_AZ.KOI8-C' |
| 811 | # updated 'a3_az.koi8c' -> 'a3_AZ.KOI8-C' to 'az_AZ.KOI8-C' |
| 812 | # updated 'cs_cs.iso88592' -> 'cs_CS.ISO8859-2' to 'cs_CZ.ISO8859-2' |
| 813 | # updated 'hebrew' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8' |
| 814 | # updated 'hebrew.iso88598' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8' |
| 815 | # updated 'sd' -> 'sd_IN@devanagari.UTF-8' to 'sd_IN.UTF-8' |
| 816 | # updated 'sr@latn' -> 'sr_RS.UTF-8@latin' to 'sr_CS.UTF-8@latin' |
| 817 | # updated 'sr_cs' -> 'sr_RS.UTF-8' to 'sr_CS.UTF-8' |
| 818 | # updated 'sr_cs.utf8@latn' -> 'sr_RS.UTF-8@latin' to 'sr_CS.UTF-8@latin' |
| 819 | # updated 'sr_cs@latn' -> 'sr_RS.UTF-8@latin' to 'sr_CS.UTF-8@latin' |
Georg Brandl | f08a9dd | 2008-06-10 16:57:31 +0000 | [diff] [blame] | 820 | |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 821 | locale_alias = { |
Serhiy Storchaka | 715233c | 2013-12-20 18:23:26 +0200 | [diff] [blame] | 822 | 'a3': 'az_AZ.KOI8-C', |
| 823 | 'a3_az': 'az_AZ.KOI8-C', |
Serhiy Storchaka | 715233c | 2013-12-20 18:23:26 +0200 | [diff] [blame] | 824 | 'a3_az.koic': 'az_AZ.KOI8-C', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 825 | 'af': 'af_ZA.ISO8859-1', |
| 826 | 'af_za': 'af_ZA.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 827 | 'am': 'am_ET.UTF-8', |
Georg Brandl | f08a9dd | 2008-06-10 16:57:31 +0000 | [diff] [blame] | 828 | 'am_et': 'am_ET.UTF-8', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 829 | 'american': 'en_US.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 830 | 'ar': 'ar_AA.ISO8859-6', |
| 831 | 'ar_aa': 'ar_AA.ISO8859-6', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 832 | 'ar_ae': 'ar_AE.ISO8859-6', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 833 | 'ar_bh': 'ar_BH.ISO8859-6', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 834 | 'ar_dz': 'ar_DZ.ISO8859-6', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 835 | 'ar_eg': 'ar_EG.ISO8859-6', |
Serhiy Storchaka | 715233c | 2013-12-20 18:23:26 +0200 | [diff] [blame] | 836 | 'ar_in': 'ar_IN.UTF-8', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 837 | 'ar_iq': 'ar_IQ.ISO8859-6', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 838 | 'ar_jo': 'ar_JO.ISO8859-6', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 839 | 'ar_kw': 'ar_KW.ISO8859-6', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 840 | 'ar_lb': 'ar_LB.ISO8859-6', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 841 | 'ar_ly': 'ar_LY.ISO8859-6', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 842 | 'ar_ma': 'ar_MA.ISO8859-6', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 843 | 'ar_om': 'ar_OM.ISO8859-6', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 844 | 'ar_qa': 'ar_QA.ISO8859-6', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 845 | 'ar_sa': 'ar_SA.ISO8859-6', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 846 | 'ar_sd': 'ar_SD.ISO8859-6', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 847 | 'ar_sy': 'ar_SY.ISO8859-6', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 848 | 'ar_tn': 'ar_TN.ISO8859-6', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 849 | 'ar_ye': 'ar_YE.ISO8859-6', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 850 | 'arabic': 'ar_AA.ISO8859-6', |
Antoine Pitrou | 0c70d2d | 2010-04-11 22:35:34 +0000 | [diff] [blame] | 851 | 'as': 'as_IN.UTF-8', |
Serhiy Storchaka | 715233c | 2013-12-20 18:23:26 +0200 | [diff] [blame] | 852 | 'as_in': 'as_IN.UTF-8', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 853 | 'az': 'az_AZ.ISO8859-9E', |
| 854 | 'az_az': 'az_AZ.ISO8859-9E', |
| 855 | 'az_az.iso88599e': 'az_AZ.ISO8859-9E', |
| 856 | 'be': 'be_BY.CP1251', |
Antoine Pitrou | 0c70d2d | 2010-04-11 22:35:34 +0000 | [diff] [blame] | 857 | 'be@latin': 'be_BY.UTF-8@latin', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 858 | 'be_by': 'be_BY.CP1251', |
Antoine Pitrou | 0c70d2d | 2010-04-11 22:35:34 +0000 | [diff] [blame] | 859 | 'be_by@latin': 'be_BY.UTF-8@latin', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 860 | 'bg': 'bg_BG.CP1251', |
| 861 | 'bg_bg': 'bg_BG.CP1251', |
Georg Brandl | f08a9dd | 2008-06-10 16:57:31 +0000 | [diff] [blame] | 862 | 'bn_in': 'bn_IN.UTF-8', |
Serhiy Storchaka | 715233c | 2013-12-20 18:23:26 +0200 | [diff] [blame] | 863 | 'bo_in': 'bo_IN.UTF-8', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 864 | 'bokmal': 'nb_NO.ISO8859-1', |
| 865 | 'bokm\xe5l': 'nb_NO.ISO8859-1', |
| 866 | 'br': 'br_FR.ISO8859-1', |
| 867 | 'br_fr': 'br_FR.ISO8859-1', |
Georg Brandl | f08a9dd | 2008-06-10 16:57:31 +0000 | [diff] [blame] | 868 | 'bs': 'bs_BA.ISO8859-2', |
| 869 | 'bs_ba': 'bs_BA.ISO8859-2', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 870 | 'bulgarian': 'bg_BG.CP1251', |
| 871 | 'c': 'C', |
| 872 | 'c-french': 'fr_CA.ISO8859-1', |
Serhiy Storchaka | 715233c | 2013-12-20 18:23:26 +0200 | [diff] [blame] | 873 | 'c.ascii': 'C', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 874 | 'c.en': 'C', |
| 875 | 'c.iso88591': 'en_US.ISO8859-1', |
| 876 | 'c_c': 'C', |
| 877 | 'c_c.c': 'C', |
| 878 | 'ca': 'ca_ES.ISO8859-1', |
Antoine Pitrou | 0c70d2d | 2010-04-11 22:35:34 +0000 | [diff] [blame] | 879 | 'ca_ad': 'ca_AD.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 880 | 'ca_es': 'ca_ES.ISO8859-1', |
Antoine Pitrou | 0c70d2d | 2010-04-11 22:35:34 +0000 | [diff] [blame] | 881 | 'ca_fr': 'ca_FR.ISO8859-1', |
Antoine Pitrou | 0c70d2d | 2010-04-11 22:35:34 +0000 | [diff] [blame] | 882 | 'ca_it': 'ca_IT.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 883 | 'catalan': 'ca_ES.ISO8859-1', |
| 884 | 'cextend': 'en_US.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 885 | 'chinese-s': 'zh_CN.eucCN', |
| 886 | 'chinese-t': 'zh_TW.eucTW', |
| 887 | 'croatian': 'hr_HR.ISO8859-2', |
| 888 | 'cs': 'cs_CZ.ISO8859-2', |
| 889 | 'cs_cs': 'cs_CZ.ISO8859-2', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 890 | 'cs_cz': 'cs_CZ.ISO8859-2', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 891 | 'cy': 'cy_GB.ISO8859-1', |
| 892 | 'cy_gb': 'cy_GB.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 893 | 'cz': 'cs_CZ.ISO8859-2', |
| 894 | 'cz_cz': 'cs_CZ.ISO8859-2', |
| 895 | 'czech': 'cs_CZ.ISO8859-2', |
| 896 | 'da': 'da_DK.ISO8859-1', |
| 897 | 'da_dk': 'da_DK.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 898 | 'danish': 'da_DK.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 899 | 'dansk': 'da_DK.ISO8859-1', |
| 900 | 'de': 'de_DE.ISO8859-1', |
| 901 | 'de_at': 'de_AT.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 902 | 'de_be': 'de_BE.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 903 | 'de_ch': 'de_CH.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 904 | 'de_de': 'de_DE.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 905 | 'de_lu': 'de_LU.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 906 | 'deutsch': 'de_DE.ISO8859-1', |
| 907 | 'dutch': 'nl_NL.ISO8859-1', |
| 908 | 'dutch.iso88591': 'nl_BE.ISO8859-1', |
| 909 | 'ee': 'ee_EE.ISO8859-4', |
| 910 | 'ee_ee': 'ee_EE.ISO8859-4', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 911 | 'eesti': 'et_EE.ISO8859-1', |
| 912 | 'el': 'el_GR.ISO8859-7', |
| 913 | 'el_gr': 'el_GR.ISO8859-7', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 914 | 'el_gr@euro': 'el_GR.ISO8859-15', |
| 915 | 'en': 'en_US.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 916 | 'en_au': 'en_AU.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 917 | 'en_be': 'en_BE.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 918 | 'en_bw': 'en_BW.ISO8859-1', |
| 919 | 'en_ca': 'en_CA.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 920 | 'en_gb': 'en_GB.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 921 | 'en_hk': 'en_HK.ISO8859-1', |
| 922 | 'en_ie': 'en_IE.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 923 | 'en_in': 'en_IN.ISO8859-1', |
| 924 | 'en_nz': 'en_NZ.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 925 | 'en_ph': 'en_PH.ISO8859-1', |
| 926 | 'en_sg': 'en_SG.ISO8859-1', |
| 927 | 'en_uk': 'en_GB.ISO8859-1', |
| 928 | 'en_us': 'en_US.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 929 | 'en_us@euro@euro': 'en_US.ISO8859-15', |
| 930 | 'en_za': 'en_ZA.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 931 | 'en_zw': 'en_ZW.ISO8859-1', |
| 932 | 'eng_gb': 'en_GB.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 933 | 'english': 'en_EN.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 934 | 'english_uk': 'en_GB.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 935 | 'english_united-states': 'en_US.ISO8859-1', |
| 936 | 'english_united-states.437': 'C', |
| 937 | 'english_us': 'en_US.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 938 | 'eo': 'eo_XX.ISO8859-3', |
| 939 | 'eo_eo': 'eo_EO.ISO8859-3', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 940 | 'eo_xx': 'eo_XX.ISO8859-3', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 941 | 'es': 'es_ES.ISO8859-1', |
| 942 | 'es_ar': 'es_AR.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 943 | 'es_bo': 'es_BO.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 944 | 'es_cl': 'es_CL.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 945 | 'es_co': 'es_CO.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 946 | 'es_cr': 'es_CR.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 947 | 'es_do': 'es_DO.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 948 | 'es_ec': 'es_EC.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 949 | 'es_es': 'es_ES.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 950 | 'es_gt': 'es_GT.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 951 | 'es_hn': 'es_HN.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 952 | 'es_mx': 'es_MX.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 953 | 'es_ni': 'es_NI.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 954 | 'es_pa': 'es_PA.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 955 | 'es_pe': 'es_PE.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 956 | 'es_pr': 'es_PR.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 957 | 'es_py': 'es_PY.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 958 | 'es_sv': 'es_SV.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 959 | 'es_us': 'es_US.ISO8859-1', |
| 960 | 'es_uy': 'es_UY.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 961 | 'es_ve': 'es_VE.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 962 | 'estonian': 'et_EE.ISO8859-1', |
| 963 | 'et': 'et_EE.ISO8859-15', |
| 964 | 'et_ee': 'et_EE.ISO8859-15', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 965 | 'eu': 'eu_ES.ISO8859-1', |
| 966 | 'eu_es': 'eu_ES.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 967 | 'fa': 'fa_IR.UTF-8', |
| 968 | 'fa_ir': 'fa_IR.UTF-8', |
| 969 | 'fa_ir.isiri3342': 'fa_IR.ISIRI-3342', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 970 | 'fi': 'fi_FI.ISO8859-15', |
| 971 | 'fi_fi': 'fi_FI.ISO8859-15', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 972 | 'finnish': 'fi_FI.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 973 | 'fo': 'fo_FO.ISO8859-1', |
| 974 | 'fo_fo': 'fo_FO.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 975 | 'fr': 'fr_FR.ISO8859-1', |
| 976 | 'fr_be': 'fr_BE.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 977 | 'fr_ca': 'fr_CA.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 978 | 'fr_ch': 'fr_CH.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 979 | 'fr_fr': 'fr_FR.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 980 | 'fr_lu': 'fr_LU.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 981 | 'fran\xe7ais': 'fr_FR.ISO8859-1', |
| 982 | 'fre_fr': 'fr_FR.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 983 | 'french': 'fr_FR.ISO8859-1', |
| 984 | 'french.iso88591': 'fr_CH.ISO8859-1', |
| 985 | 'french_france': 'fr_FR.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 986 | 'ga': 'ga_IE.ISO8859-1', |
| 987 | 'ga_ie': 'ga_IE.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 988 | 'galego': 'gl_ES.ISO8859-1', |
| 989 | 'galician': 'gl_ES.ISO8859-1', |
| 990 | 'gd': 'gd_GB.ISO8859-1', |
| 991 | 'gd_gb': 'gd_GB.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 992 | 'ger_de': 'de_DE.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 993 | 'german': 'de_DE.ISO8859-1', |
| 994 | 'german.iso88591': 'de_CH.ISO8859-1', |
| 995 | 'german_germany': 'de_DE.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 996 | 'gl': 'gl_ES.ISO8859-1', |
| 997 | 'gl_es': 'gl_ES.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 998 | 'greek': 'el_GR.ISO8859-7', |
Georg Brandl | f08a9dd | 2008-06-10 16:57:31 +0000 | [diff] [blame] | 999 | 'gu_in': 'gu_IN.UTF-8', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1000 | 'gv': 'gv_GB.ISO8859-1', |
| 1001 | 'gv_gb': 'gv_GB.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1002 | 'he': 'he_IL.ISO8859-8', |
| 1003 | 'he_il': 'he_IL.ISO8859-8', |
Serhiy Storchaka | 715233c | 2013-12-20 18:23:26 +0200 | [diff] [blame] | 1004 | 'hebrew': 'he_IL.ISO8859-8', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1005 | 'hi': 'hi_IN.ISCII-DEV', |
| 1006 | 'hi_in': 'hi_IN.ISCII-DEV', |
| 1007 | 'hi_in.isciidev': 'hi_IN.ISCII-DEV', |
Antoine Pitrou | 0c70d2d | 2010-04-11 22:35:34 +0000 | [diff] [blame] | 1008 | 'hne': 'hne_IN.UTF-8', |
Serhiy Storchaka | 715233c | 2013-12-20 18:23:26 +0200 | [diff] [blame] | 1009 | 'hne_in': 'hne_IN.UTF-8', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1010 | 'hr': 'hr_HR.ISO8859-2', |
| 1011 | 'hr_hr': 'hr_HR.ISO8859-2', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1012 | 'hrvatski': 'hr_HR.ISO8859-2', |
| 1013 | 'hu': 'hu_HU.ISO8859-2', |
| 1014 | 'hu_hu': 'hu_HU.ISO8859-2', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1015 | 'hungarian': 'hu_HU.ISO8859-2', |
| 1016 | 'icelandic': 'is_IS.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1017 | 'id': 'id_ID.ISO8859-1', |
| 1018 | 'id_id': 'id_ID.ISO8859-1', |
| 1019 | 'in': 'id_ID.ISO8859-1', |
| 1020 | 'in_id': 'id_ID.ISO8859-1', |
| 1021 | 'is': 'is_IS.ISO8859-1', |
| 1022 | 'is_is': 'is_IS.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1023 | 'iso-8859-1': 'en_US.ISO8859-1', |
| 1024 | 'iso-8859-15': 'en_US.ISO8859-15', |
| 1025 | 'iso8859-1': 'en_US.ISO8859-1', |
| 1026 | 'iso8859-15': 'en_US.ISO8859-15', |
| 1027 | 'iso_8859_1': 'en_US.ISO8859-1', |
| 1028 | 'iso_8859_15': 'en_US.ISO8859-15', |
| 1029 | 'it': 'it_IT.ISO8859-1', |
| 1030 | 'it_ch': 'it_CH.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1031 | 'it_it': 'it_IT.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1032 | 'italian': 'it_IT.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1033 | 'iu': 'iu_CA.NUNACOM-8', |
| 1034 | 'iu_ca': 'iu_CA.NUNACOM-8', |
| 1035 | 'iu_ca.nunacom8': 'iu_CA.NUNACOM-8', |
| 1036 | 'iw': 'he_IL.ISO8859-8', |
| 1037 | 'iw_il': 'he_IL.ISO8859-8', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1038 | 'ja': 'ja_JP.eucJP', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1039 | 'ja_jp': 'ja_JP.eucJP', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1040 | 'ja_jp.euc': 'ja_JP.eucJP', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1041 | 'ja_jp.mscode': 'ja_JP.SJIS', |
Antoine Pitrou | 0c70d2d | 2010-04-11 22:35:34 +0000 | [diff] [blame] | 1042 | 'ja_jp.pck': 'ja_JP.SJIS', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1043 | 'japan': 'ja_JP.eucJP', |
| 1044 | 'japanese': 'ja_JP.eucJP', |
| 1045 | 'japanese-euc': 'ja_JP.eucJP', |
| 1046 | 'japanese.euc': 'ja_JP.eucJP', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1047 | 'jp_jp': 'ja_JP.eucJP', |
| 1048 | 'ka': 'ka_GE.GEORGIAN-ACADEMY', |
| 1049 | 'ka_ge': 'ka_GE.GEORGIAN-ACADEMY', |
| 1050 | 'ka_ge.georgianacademy': 'ka_GE.GEORGIAN-ACADEMY', |
| 1051 | 'ka_ge.georgianps': 'ka_GE.GEORGIAN-PS', |
| 1052 | 'ka_ge.georgianrs': 'ka_GE.GEORGIAN-ACADEMY', |
| 1053 | 'kl': 'kl_GL.ISO8859-1', |
| 1054 | 'kl_gl': 'kl_GL.ISO8859-1', |
Georg Brandl | f08a9dd | 2008-06-10 16:57:31 +0000 | [diff] [blame] | 1055 | 'km_kh': 'km_KH.UTF-8', |
Antoine Pitrou | 0c70d2d | 2010-04-11 22:35:34 +0000 | [diff] [blame] | 1056 | 'kn': 'kn_IN.UTF-8', |
Georg Brandl | f08a9dd | 2008-06-10 16:57:31 +0000 | [diff] [blame] | 1057 | 'kn_in': 'kn_IN.UTF-8', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1058 | 'ko': 'ko_KR.eucKR', |
| 1059 | 'ko_kr': 'ko_KR.eucKR', |
| 1060 | 'ko_kr.euc': 'ko_KR.eucKR', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1061 | 'korean': 'ko_KR.eucKR', |
| 1062 | 'korean.euc': 'ko_KR.eucKR', |
Antoine Pitrou | 0c70d2d | 2010-04-11 22:35:34 +0000 | [diff] [blame] | 1063 | 'ks': 'ks_IN.UTF-8', |
Serhiy Storchaka | 715233c | 2013-12-20 18:23:26 +0200 | [diff] [blame] | 1064 | 'ks_in': 'ks_IN.UTF-8', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1065 | 'kw': 'kw_GB.ISO8859-1', |
| 1066 | 'kw_gb': 'kw_GB.ISO8859-1', |
Georg Brandl | f08a9dd | 2008-06-10 16:57:31 +0000 | [diff] [blame] | 1067 | 'ky': 'ky_KG.UTF-8', |
| 1068 | 'ky_kg': 'ky_KG.UTF-8', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1069 | 'lithuanian': 'lt_LT.ISO8859-13', |
| 1070 | 'lo': 'lo_LA.MULELAO-1', |
| 1071 | 'lo_la': 'lo_LA.MULELAO-1', |
| 1072 | 'lo_la.cp1133': 'lo_LA.IBM-CP1133', |
| 1073 | 'lo_la.ibmcp1133': 'lo_LA.IBM-CP1133', |
| 1074 | 'lo_la.mulelao1': 'lo_LA.MULELAO-1', |
| 1075 | 'lt': 'lt_LT.ISO8859-13', |
| 1076 | 'lt_lt': 'lt_LT.ISO8859-13', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1077 | 'lv': 'lv_LV.ISO8859-13', |
| 1078 | 'lv_lv': 'lv_LV.ISO8859-13', |
Antoine Pitrou | 0c70d2d | 2010-04-11 22:35:34 +0000 | [diff] [blame] | 1079 | 'mai': 'mai_IN.UTF-8', |
Serhiy Storchaka | 715233c | 2013-12-20 18:23:26 +0200 | [diff] [blame] | 1080 | 'mai_in': 'mai_IN.UTF-8', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1081 | 'mi': 'mi_NZ.ISO8859-1', |
| 1082 | 'mi_nz': 'mi_NZ.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1083 | 'mk': 'mk_MK.ISO8859-5', |
| 1084 | 'mk_mk': 'mk_MK.ISO8859-5', |
Antoine Pitrou | 0c70d2d | 2010-04-11 22:35:34 +0000 | [diff] [blame] | 1085 | 'ml': 'ml_IN.UTF-8', |
Serhiy Storchaka | 715233c | 2013-12-20 18:23:26 +0200 | [diff] [blame] | 1086 | 'ml_in': 'ml_IN.UTF-8', |
Antoine Pitrou | 0c70d2d | 2010-04-11 22:35:34 +0000 | [diff] [blame] | 1087 | 'mr': 'mr_IN.UTF-8', |
Georg Brandl | f08a9dd | 2008-06-10 16:57:31 +0000 | [diff] [blame] | 1088 | 'mr_in': 'mr_IN.UTF-8', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1089 | 'ms': 'ms_MY.ISO8859-1', |
| 1090 | 'ms_my': 'ms_MY.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1091 | 'mt': 'mt_MT.ISO8859-3', |
| 1092 | 'mt_mt': 'mt_MT.ISO8859-3', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1093 | 'nb': 'nb_NO.ISO8859-1', |
| 1094 | 'nb_no': 'nb_NO.ISO8859-1', |
Serhiy Storchaka | 715233c | 2013-12-20 18:23:26 +0200 | [diff] [blame] | 1095 | 'ne_np': 'ne_NP.UTF-8', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1096 | 'nl': 'nl_NL.ISO8859-1', |
| 1097 | 'nl_be': 'nl_BE.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1098 | 'nl_nl': 'nl_NL.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1099 | 'nn': 'nn_NO.ISO8859-1', |
| 1100 | 'nn_no': 'nn_NO.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1101 | 'no': 'no_NO.ISO8859-1', |
| 1102 | 'no@nynorsk': 'ny_NO.ISO8859-1', |
| 1103 | 'no_no': 'no_NO.ISO8859-1', |
Antoine Pitrou | 0c70d2d | 2010-04-11 22:35:34 +0000 | [diff] [blame] | 1104 | 'no_no.iso88591@bokmal': 'no_NO.ISO8859-1', |
| 1105 | 'no_no.iso88591@nynorsk': 'no_NO.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1106 | 'norwegian': 'no_NO.ISO8859-1', |
Georg Brandl | f08a9dd | 2008-06-10 16:57:31 +0000 | [diff] [blame] | 1107 | 'nr': 'nr_ZA.ISO8859-1', |
| 1108 | 'nr_za': 'nr_ZA.ISO8859-1', |
Georg Brandl | f08a9dd | 2008-06-10 16:57:31 +0000 | [diff] [blame] | 1109 | 'nso': 'nso_ZA.ISO8859-15', |
| 1110 | 'nso_za': 'nso_ZA.ISO8859-15', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1111 | 'ny': 'ny_NO.ISO8859-1', |
| 1112 | 'ny_no': 'ny_NO.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1113 | 'nynorsk': 'nn_NO.ISO8859-1', |
| 1114 | 'oc': 'oc_FR.ISO8859-1', |
| 1115 | 'oc_fr': 'oc_FR.ISO8859-1', |
Antoine Pitrou | 0c70d2d | 2010-04-11 22:35:34 +0000 | [diff] [blame] | 1116 | 'or': 'or_IN.UTF-8', |
Serhiy Storchaka | 715233c | 2013-12-20 18:23:26 +0200 | [diff] [blame] | 1117 | 'or_in': 'or_IN.UTF-8', |
Antoine Pitrou | 0c70d2d | 2010-04-11 22:35:34 +0000 | [diff] [blame] | 1118 | 'pa': 'pa_IN.UTF-8', |
Georg Brandl | f08a9dd | 2008-06-10 16:57:31 +0000 | [diff] [blame] | 1119 | 'pa_in': 'pa_IN.UTF-8', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1120 | 'pd': 'pd_US.ISO8859-1', |
| 1121 | 'pd_de': 'pd_DE.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1122 | 'pd_us': 'pd_US.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1123 | 'ph': 'ph_PH.ISO8859-1', |
| 1124 | 'ph_ph': 'ph_PH.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1125 | 'pl': 'pl_PL.ISO8859-2', |
| 1126 | 'pl_pl': 'pl_PL.ISO8859-2', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1127 | 'polish': 'pl_PL.ISO8859-2', |
| 1128 | 'portuguese': 'pt_PT.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1129 | 'portuguese_brazil': 'pt_BR.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1130 | 'posix': 'C', |
| 1131 | 'posix-utf2': 'C', |
| 1132 | 'pp': 'pp_AN.ISO8859-1', |
| 1133 | 'pp_an': 'pp_AN.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1134 | 'pt': 'pt_PT.ISO8859-1', |
| 1135 | 'pt_br': 'pt_BR.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1136 | 'pt_pt': 'pt_PT.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1137 | 'ro': 'ro_RO.ISO8859-2', |
| 1138 | 'ro_ro': 'ro_RO.ISO8859-2', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1139 | 'romanian': 'ro_RO.ISO8859-2', |
Antoine Pitrou | 0c70d2d | 2010-04-11 22:35:34 +0000 | [diff] [blame] | 1140 | 'ru': 'ru_RU.UTF-8', |
Antoine Pitrou | 0c70d2d | 2010-04-11 22:35:34 +0000 | [diff] [blame] | 1141 | 'ru_ru': 'ru_RU.UTF-8', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1142 | 'ru_ua': 'ru_UA.KOI8-U', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1143 | 'rumanian': 'ro_RO.ISO8859-2', |
| 1144 | 'russian': 'ru_RU.ISO8859-5', |
Georg Brandl | f08a9dd | 2008-06-10 16:57:31 +0000 | [diff] [blame] | 1145 | 'rw': 'rw_RW.ISO8859-1', |
| 1146 | 'rw_rw': 'rw_RW.ISO8859-1', |
Serhiy Storchaka | 715233c | 2013-12-20 18:23:26 +0200 | [diff] [blame] | 1147 | 'sd': 'sd_IN.UTF-8', |
Serhiy Storchaka | 5eb0153 | 2013-12-26 21:20:59 +0200 | [diff] [blame] | 1148 | 'sd_in': 'sd_IN.UTF-8', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1149 | 'se_no': 'se_NO.UTF-8', |
Antoine Pitrou | 0c70d2d | 2010-04-11 22:35:34 +0000 | [diff] [blame] | 1150 | 'serbocroatian': 'sr_RS.UTF-8@latin', |
| 1151 | 'sh': 'sr_RS.UTF-8@latin', |
| 1152 | 'sh_ba.iso88592@bosnia': 'sr_CS.ISO8859-2', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1153 | 'sh_hr': 'sh_HR.ISO8859-2', |
Georg Brandl | f08a9dd | 2008-06-10 16:57:31 +0000 | [diff] [blame] | 1154 | 'sh_hr.iso88592': 'hr_HR.ISO8859-2', |
| 1155 | 'sh_sp': 'sr_CS.ISO8859-2', |
Antoine Pitrou | 0c70d2d | 2010-04-11 22:35:34 +0000 | [diff] [blame] | 1156 | 'sh_yu': 'sr_RS.UTF-8@latin', |
Georg Brandl | f08a9dd | 2008-06-10 16:57:31 +0000 | [diff] [blame] | 1157 | 'si': 'si_LK.UTF-8', |
| 1158 | 'si_lk': 'si_LK.UTF-8', |
| 1159 | 'sinhala': 'si_LK.UTF-8', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1160 | 'sk': 'sk_SK.ISO8859-2', |
| 1161 | 'sk_sk': 'sk_SK.ISO8859-2', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1162 | 'sl': 'sl_SI.ISO8859-2', |
| 1163 | 'sl_cs': 'sl_CS.ISO8859-2', |
| 1164 | 'sl_si': 'sl_SI.ISO8859-2', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1165 | 'slovak': 'sk_SK.ISO8859-2', |
| 1166 | 'slovene': 'sl_SI.ISO8859-2', |
| 1167 | 'slovenian': 'sl_SI.ISO8859-2', |
Georg Brandl | f08a9dd | 2008-06-10 16:57:31 +0000 | [diff] [blame] | 1168 | 'sp': 'sr_CS.ISO8859-5', |
| 1169 | 'sp_yu': 'sr_CS.ISO8859-5', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1170 | 'spanish': 'es_ES.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1171 | 'spanish_spain': 'es_ES.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1172 | 'sq': 'sq_AL.ISO8859-2', |
| 1173 | 'sq_al': 'sq_AL.ISO8859-2', |
Antoine Pitrou | 0c70d2d | 2010-04-11 22:35:34 +0000 | [diff] [blame] | 1174 | 'sr': 'sr_RS.UTF-8', |
| 1175 | 'sr@cyrillic': 'sr_RS.UTF-8', |
Serhiy Storchaka | 715233c | 2013-12-20 18:23:26 +0200 | [diff] [blame] | 1176 | 'sr@latn': 'sr_CS.UTF-8@latin', |
| 1177 | 'sr_cs': 'sr_CS.UTF-8', |
Georg Brandl | f08a9dd | 2008-06-10 16:57:31 +0000 | [diff] [blame] | 1178 | 'sr_cs.iso88592@latn': 'sr_CS.ISO8859-2', |
Serhiy Storchaka | 715233c | 2013-12-20 18:23:26 +0200 | [diff] [blame] | 1179 | 'sr_cs@latn': 'sr_CS.UTF-8@latin', |
Antoine Pitrou | 0c70d2d | 2010-04-11 22:35:34 +0000 | [diff] [blame] | 1180 | 'sr_me': 'sr_ME.UTF-8', |
| 1181 | 'sr_rs': 'sr_RS.UTF-8', |
Antoine Pitrou | 0c70d2d | 2010-04-11 22:35:34 +0000 | [diff] [blame] | 1182 | 'sr_rs@latn': 'sr_RS.UTF-8@latin', |
Georg Brandl | f08a9dd | 2008-06-10 16:57:31 +0000 | [diff] [blame] | 1183 | 'sr_sp': 'sr_CS.ISO8859-2', |
Antoine Pitrou | 0c70d2d | 2010-04-11 22:35:34 +0000 | [diff] [blame] | 1184 | 'sr_yu': 'sr_RS.UTF-8@latin', |
Georg Brandl | f08a9dd | 2008-06-10 16:57:31 +0000 | [diff] [blame] | 1185 | 'sr_yu.cp1251@cyrillic': 'sr_CS.CP1251', |
| 1186 | 'sr_yu.iso88592': 'sr_CS.ISO8859-2', |
| 1187 | 'sr_yu.iso88595': 'sr_CS.ISO8859-5', |
| 1188 | 'sr_yu.iso88595@cyrillic': 'sr_CS.ISO8859-5', |
| 1189 | 'sr_yu.microsoftcp1251@cyrillic': 'sr_CS.CP1251', |
Antoine Pitrou | 0c70d2d | 2010-04-11 22:35:34 +0000 | [diff] [blame] | 1190 | 'sr_yu@cyrillic': 'sr_RS.UTF-8', |
Georg Brandl | f08a9dd | 2008-06-10 16:57:31 +0000 | [diff] [blame] | 1191 | 'ss': 'ss_ZA.ISO8859-1', |
| 1192 | 'ss_za': 'ss_ZA.ISO8859-1', |
Georg Brandl | f08a9dd | 2008-06-10 16:57:31 +0000 | [diff] [blame] | 1193 | 'st': 'st_ZA.ISO8859-1', |
| 1194 | 'st_za': 'st_ZA.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1195 | 'sv': 'sv_SE.ISO8859-1', |
| 1196 | 'sv_fi': 'sv_FI.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1197 | 'sv_se': 'sv_SE.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1198 | 'swedish': 'sv_SE.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1199 | 'ta': 'ta_IN.TSCII-0', |
| 1200 | 'ta_in': 'ta_IN.TSCII-0', |
| 1201 | 'ta_in.tscii': 'ta_IN.TSCII-0', |
| 1202 | 'ta_in.tscii0': 'ta_IN.TSCII-0', |
Antoine Pitrou | 0c70d2d | 2010-04-11 22:35:34 +0000 | [diff] [blame] | 1203 | 'te': 'te_IN.UTF-8', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1204 | 'tg': 'tg_TJ.KOI8-C', |
| 1205 | 'tg_tj': 'tg_TJ.KOI8-C', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1206 | 'th': 'th_TH.ISO8859-11', |
| 1207 | 'th_th': 'th_TH.ISO8859-11', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1208 | 'th_th.tactis': 'th_TH.TIS620', |
| 1209 | 'th_th.tis620': 'th_TH.TIS620', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1210 | 'thai': 'th_TH.ISO8859-11', |
| 1211 | 'tl': 'tl_PH.ISO8859-1', |
| 1212 | 'tl_ph': 'tl_PH.ISO8859-1', |
Georg Brandl | f08a9dd | 2008-06-10 16:57:31 +0000 | [diff] [blame] | 1213 | 'tn': 'tn_ZA.ISO8859-15', |
| 1214 | 'tn_za': 'tn_ZA.ISO8859-15', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1215 | 'tr': 'tr_TR.ISO8859-9', |
| 1216 | 'tr_tr': 'tr_TR.ISO8859-9', |
Georg Brandl | f08a9dd | 2008-06-10 16:57:31 +0000 | [diff] [blame] | 1217 | 'ts': 'ts_ZA.ISO8859-1', |
| 1218 | 'ts_za': 'ts_ZA.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1219 | 'tt': 'tt_RU.TATAR-CYR', |
| 1220 | 'tt_ru': 'tt_RU.TATAR-CYR', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1221 | 'tt_ru.tatarcyr': 'tt_RU.TATAR-CYR', |
| 1222 | 'turkish': 'tr_TR.ISO8859-9', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1223 | 'uk': 'uk_UA.KOI8-U', |
| 1224 | 'uk_ua': 'uk_UA.KOI8-U', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1225 | 'univ': 'en_US.utf', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1226 | 'universal': 'en_US.utf', |
| 1227 | 'universal.utf8@ucs4': 'en_US.UTF-8', |
| 1228 | 'ur': 'ur_PK.CP1256', |
Serhiy Storchaka | 715233c | 2013-12-20 18:23:26 +0200 | [diff] [blame] | 1229 | 'ur_in': 'ur_IN.UTF-8', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1230 | 'ur_pk': 'ur_PK.CP1256', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1231 | 'uz': 'uz_UZ.UTF-8', |
| 1232 | 'uz_uz': 'uz_UZ.UTF-8', |
Georg Brandl | f08a9dd | 2008-06-10 16:57:31 +0000 | [diff] [blame] | 1233 | 'uz_uz@cyrillic': 'uz_UZ.UTF-8', |
| 1234 | 've': 've_ZA.UTF-8', |
| 1235 | 've_za': 've_ZA.UTF-8', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1236 | 'vi': 'vi_VN.TCVN', |
| 1237 | 'vi_vn': 'vi_VN.TCVN', |
| 1238 | 'vi_vn.tcvn': 'vi_VN.TCVN', |
| 1239 | 'vi_vn.tcvn5712': 'vi_VN.TCVN', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1240 | 'vi_vn.viscii': 'vi_VN.VISCII', |
| 1241 | 'vi_vn.viscii111': 'vi_VN.VISCII', |
| 1242 | 'wa': 'wa_BE.ISO8859-1', |
| 1243 | 'wa_be': 'wa_BE.ISO8859-1', |
Georg Brandl | f08a9dd | 2008-06-10 16:57:31 +0000 | [diff] [blame] | 1244 | 'xh': 'xh_ZA.ISO8859-1', |
| 1245 | 'xh_za': 'xh_ZA.ISO8859-1', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1246 | 'yi': 'yi_US.CP1255', |
| 1247 | 'yi_us': 'yi_US.CP1255', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1248 | 'zh': 'zh_CN.eucCN', |
| 1249 | 'zh_cn': 'zh_CN.gb2312', |
| 1250 | 'zh_cn.big5': 'zh_TW.big5', |
| 1251 | 'zh_cn.euc': 'zh_CN.eucCN', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1252 | 'zh_hk': 'zh_HK.big5hkscs', |
Antoine Pitrou | 0c70d2d | 2010-04-11 22:35:34 +0000 | [diff] [blame] | 1253 | 'zh_hk.big5hk': 'zh_HK.big5hkscs', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1254 | 'zh_tw': 'zh_TW.big5', |
Marc-André Lemburg | bb4f1bd | 2004-12-10 21:58:14 +0000 | [diff] [blame] | 1255 | 'zh_tw.euc': 'zh_TW.eucTW', |
Georg Brandl | f08a9dd | 2008-06-10 16:57:31 +0000 | [diff] [blame] | 1256 | 'zh_tw.euctw': 'zh_TW.eucTW', |
| 1257 | 'zu': 'zu_ZA.ISO8859-1', |
| 1258 | 'zu_za': 'zu_ZA.ISO8859-1', |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 1259 | } |
| 1260 | |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 1261 | # |
Georg Brandl | b709c2c | 2006-01-20 09:07:35 +0000 | [diff] [blame] | 1262 | # This maps Windows language identifiers to locale strings. |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 1263 | # |
Tim Peters | 777f108 | 2006-01-20 20:03:24 +0000 | [diff] [blame] | 1264 | # This list has been updated from |
Georg Brandl | b709c2c | 2006-01-20 09:07:35 +0000 | [diff] [blame] | 1265 | # http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nls_238z.asp |
Jeroen Ruigrok van der Werven | 0a86694 | 2009-05-08 14:18:00 +0000 | [diff] [blame] | 1266 | # to include every locale up to Windows Vista. |
Fredrik Lundh | 37a0982 | 2002-10-19 20:19:10 +0000 | [diff] [blame] | 1267 | # |
Georg Brandl | 5035c1c | 2006-01-20 13:38:26 +0000 | [diff] [blame] | 1268 | # NOTE: this mapping is incomplete. If your language is missing, please |
Éric Araujo | a2b89e3 | 2011-11-29 16:36:17 +0100 | [diff] [blame] | 1269 | # submit a bug report to the Python bug tracker at http://bugs.python.org/ |
Georg Brandl | 5035c1c | 2006-01-20 13:38:26 +0000 | [diff] [blame] | 1270 | # Make sure you include the missing language identifier and the suggested |
| 1271 | # locale code. |
| 1272 | # |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 1273 | |
| 1274 | windows_locale = { |
Georg Brandl | b709c2c | 2006-01-20 09:07:35 +0000 | [diff] [blame] | 1275 | 0x0436: "af_ZA", # Afrikaans |
| 1276 | 0x041c: "sq_AL", # Albanian |
Jeroen Ruigrok van der Werven | 0a86694 | 2009-05-08 14:18:00 +0000 | [diff] [blame] | 1277 | 0x0484: "gsw_FR",# Alsatian - France |
| 1278 | 0x045e: "am_ET", # Amharic - Ethiopia |
Georg Brandl | b709c2c | 2006-01-20 09:07:35 +0000 | [diff] [blame] | 1279 | 0x0401: "ar_SA", # Arabic - Saudi Arabia |
| 1280 | 0x0801: "ar_IQ", # Arabic - Iraq |
| 1281 | 0x0c01: "ar_EG", # Arabic - Egypt |
| 1282 | 0x1001: "ar_LY", # Arabic - Libya |
| 1283 | 0x1401: "ar_DZ", # Arabic - Algeria |
| 1284 | 0x1801: "ar_MA", # Arabic - Morocco |
| 1285 | 0x1c01: "ar_TN", # Arabic - Tunisia |
| 1286 | 0x2001: "ar_OM", # Arabic - Oman |
| 1287 | 0x2401: "ar_YE", # Arabic - Yemen |
| 1288 | 0x2801: "ar_SY", # Arabic - Syria |
| 1289 | 0x2c01: "ar_JO", # Arabic - Jordan |
| 1290 | 0x3001: "ar_LB", # Arabic - Lebanon |
| 1291 | 0x3401: "ar_KW", # Arabic - Kuwait |
| 1292 | 0x3801: "ar_AE", # Arabic - United Arab Emirates |
| 1293 | 0x3c01: "ar_BH", # Arabic - Bahrain |
| 1294 | 0x4001: "ar_QA", # Arabic - Qatar |
| 1295 | 0x042b: "hy_AM", # Armenian |
Jeroen Ruigrok van der Werven | 0a86694 | 2009-05-08 14:18:00 +0000 | [diff] [blame] | 1296 | 0x044d: "as_IN", # Assamese - India |
| 1297 | 0x042c: "az_AZ", # Azeri - Latin |
Georg Brandl | b709c2c | 2006-01-20 09:07:35 +0000 | [diff] [blame] | 1298 | 0x082c: "az_AZ", # Azeri - Cyrillic |
Jeroen Ruigrok van der Werven | 0a86694 | 2009-05-08 14:18:00 +0000 | [diff] [blame] | 1299 | 0x046d: "ba_RU", # Bashkir |
| 1300 | 0x042d: "eu_ES", # Basque - Russia |
Georg Brandl | b709c2c | 2006-01-20 09:07:35 +0000 | [diff] [blame] | 1301 | 0x0423: "be_BY", # Belarusian |
| 1302 | 0x0445: "bn_IN", # Begali |
Jeroen Ruigrok van der Werven | 0a86694 | 2009-05-08 14:18:00 +0000 | [diff] [blame] | 1303 | 0x201a: "bs_BA", # Bosnian - Cyrillic |
| 1304 | 0x141a: "bs_BA", # Bosnian - Latin |
Georg Brandl | b709c2c | 2006-01-20 09:07:35 +0000 | [diff] [blame] | 1305 | 0x047e: "br_FR", # Breton - France |
| 1306 | 0x0402: "bg_BG", # Bulgarian |
Jeroen Ruigrok van der Werven | 0a86694 | 2009-05-08 14:18:00 +0000 | [diff] [blame] | 1307 | # 0x0455: "my_MM", # Burmese - Not supported |
Georg Brandl | b709c2c | 2006-01-20 09:07:35 +0000 | [diff] [blame] | 1308 | 0x0403: "ca_ES", # Catalan |
| 1309 | 0x0004: "zh_CHS",# Chinese - Simplified |
| 1310 | 0x0404: "zh_TW", # Chinese - Taiwan |
| 1311 | 0x0804: "zh_CN", # Chinese - PRC |
| 1312 | 0x0c04: "zh_HK", # Chinese - Hong Kong S.A.R. |
| 1313 | 0x1004: "zh_SG", # Chinese - Singapore |
| 1314 | 0x1404: "zh_MO", # Chinese - Macao S.A.R. |
| 1315 | 0x7c04: "zh_CHT",# Chinese - Traditional |
Jeroen Ruigrok van der Werven | 0a86694 | 2009-05-08 14:18:00 +0000 | [diff] [blame] | 1316 | 0x0483: "co_FR", # Corsican - France |
Georg Brandl | b709c2c | 2006-01-20 09:07:35 +0000 | [diff] [blame] | 1317 | 0x041a: "hr_HR", # Croatian |
| 1318 | 0x101a: "hr_BA", # Croatian - Bosnia |
| 1319 | 0x0405: "cs_CZ", # Czech |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 1320 | 0x0406: "da_DK", # Danish |
Georg Brandl | b709c2c | 2006-01-20 09:07:35 +0000 | [diff] [blame] | 1321 | 0x048c: "gbz_AF",# Dari - Afghanistan |
| 1322 | 0x0465: "div_MV",# Divehi - Maldives |
| 1323 | 0x0413: "nl_NL", # Dutch - The Netherlands |
| 1324 | 0x0813: "nl_BE", # Dutch - Belgium |
| 1325 | 0x0409: "en_US", # English - United States |
| 1326 | 0x0809: "en_GB", # English - United Kingdom |
| 1327 | 0x0c09: "en_AU", # English - Australia |
| 1328 | 0x1009: "en_CA", # English - Canada |
| 1329 | 0x1409: "en_NZ", # English - New Zealand |
| 1330 | 0x1809: "en_IE", # English - Ireland |
| 1331 | 0x1c09: "en_ZA", # English - South Africa |
| 1332 | 0x2009: "en_JA", # English - Jamaica |
| 1333 | 0x2409: "en_CB", # English - Carribbean |
| 1334 | 0x2809: "en_BZ", # English - Belize |
| 1335 | 0x2c09: "en_TT", # English - Trinidad |
| 1336 | 0x3009: "en_ZW", # English - Zimbabwe |
Jeroen Ruigrok van der Werven | 0a86694 | 2009-05-08 14:18:00 +0000 | [diff] [blame] | 1337 | 0x3409: "en_PH", # English - Philippines |
| 1338 | 0x4009: "en_IN", # English - India |
| 1339 | 0x4409: "en_MY", # English - Malaysia |
| 1340 | 0x4809: "en_IN", # English - Singapore |
Georg Brandl | b709c2c | 2006-01-20 09:07:35 +0000 | [diff] [blame] | 1341 | 0x0425: "et_EE", # Estonian |
| 1342 | 0x0438: "fo_FO", # Faroese |
| 1343 | 0x0464: "fil_PH",# Filipino |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 1344 | 0x040b: "fi_FI", # Finnish |
Georg Brandl | b709c2c | 2006-01-20 09:07:35 +0000 | [diff] [blame] | 1345 | 0x040c: "fr_FR", # French - France |
| 1346 | 0x080c: "fr_BE", # French - Belgium |
| 1347 | 0x0c0c: "fr_CA", # French - Canada |
| 1348 | 0x100c: "fr_CH", # French - Switzerland |
| 1349 | 0x140c: "fr_LU", # French - Luxembourg |
| 1350 | 0x180c: "fr_MC", # French - Monaco |
| 1351 | 0x0462: "fy_NL", # Frisian - Netherlands |
| 1352 | 0x0456: "gl_ES", # Galician |
| 1353 | 0x0437: "ka_GE", # Georgian |
| 1354 | 0x0407: "de_DE", # German - Germany |
| 1355 | 0x0807: "de_CH", # German - Switzerland |
| 1356 | 0x0c07: "de_AT", # German - Austria |
| 1357 | 0x1007: "de_LU", # German - Luxembourg |
| 1358 | 0x1407: "de_LI", # German - Liechtenstein |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 1359 | 0x0408: "el_GR", # Greek |
Jeroen Ruigrok van der Werven | 0a86694 | 2009-05-08 14:18:00 +0000 | [diff] [blame] | 1360 | 0x046f: "kl_GL", # Greenlandic - Greenland |
Georg Brandl | b709c2c | 2006-01-20 09:07:35 +0000 | [diff] [blame] | 1361 | 0x0447: "gu_IN", # Gujarati |
Jeroen Ruigrok van der Werven | 0a86694 | 2009-05-08 14:18:00 +0000 | [diff] [blame] | 1362 | 0x0468: "ha_NG", # Hausa - Latin |
Georg Brandl | b709c2c | 2006-01-20 09:07:35 +0000 | [diff] [blame] | 1363 | 0x040d: "he_IL", # Hebrew |
| 1364 | 0x0439: "hi_IN", # Hindi |
| 1365 | 0x040e: "hu_HU", # Hungarian |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 1366 | 0x040f: "is_IS", # Icelandic |
Georg Brandl | b709c2c | 2006-01-20 09:07:35 +0000 | [diff] [blame] | 1367 | 0x0421: "id_ID", # Indonesian |
Jeroen Ruigrok van der Werven | 0a86694 | 2009-05-08 14:18:00 +0000 | [diff] [blame] | 1368 | 0x045d: "iu_CA", # Inuktitut - Syllabics |
Georg Brandl | b709c2c | 2006-01-20 09:07:35 +0000 | [diff] [blame] | 1369 | 0x085d: "iu_CA", # Inuktitut - Latin |
| 1370 | 0x083c: "ga_IE", # Irish - Ireland |
Georg Brandl | b709c2c | 2006-01-20 09:07:35 +0000 | [diff] [blame] | 1371 | 0x0410: "it_IT", # Italian - Italy |
| 1372 | 0x0810: "it_CH", # Italian - Switzerland |
| 1373 | 0x0411: "ja_JP", # Japanese |
| 1374 | 0x044b: "kn_IN", # Kannada - India |
| 1375 | 0x043f: "kk_KZ", # Kazakh |
Jeroen Ruigrok van der Werven | 0a86694 | 2009-05-08 14:18:00 +0000 | [diff] [blame] | 1376 | 0x0453: "kh_KH", # Khmer - Cambodia |
| 1377 | 0x0486: "qut_GT",# K'iche - Guatemala |
| 1378 | 0x0487: "rw_RW", # Kinyarwanda - Rwanda |
Georg Brandl | b709c2c | 2006-01-20 09:07:35 +0000 | [diff] [blame] | 1379 | 0x0457: "kok_IN",# Konkani |
| 1380 | 0x0412: "ko_KR", # Korean |
| 1381 | 0x0440: "ky_KG", # Kyrgyz |
Jeroen Ruigrok van der Werven | 0a86694 | 2009-05-08 14:18:00 +0000 | [diff] [blame] | 1382 | 0x0454: "lo_LA", # Lao - Lao PDR |
Georg Brandl | b709c2c | 2006-01-20 09:07:35 +0000 | [diff] [blame] | 1383 | 0x0426: "lv_LV", # Latvian |
| 1384 | 0x0427: "lt_LT", # Lithuanian |
Jeroen Ruigrok van der Werven | 0a86694 | 2009-05-08 14:18:00 +0000 | [diff] [blame] | 1385 | 0x082e: "dsb_DE",# Lower Sorbian - Germany |
Georg Brandl | b709c2c | 2006-01-20 09:07:35 +0000 | [diff] [blame] | 1386 | 0x046e: "lb_LU", # Luxembourgish |
Jeroen Ruigrok van der Werven | 0a86694 | 2009-05-08 14:18:00 +0000 | [diff] [blame] | 1387 | 0x042f: "mk_MK", # FYROM Macedonian |
Georg Brandl | b709c2c | 2006-01-20 09:07:35 +0000 | [diff] [blame] | 1388 | 0x043e: "ms_MY", # Malay - Malaysia |
Jeroen Ruigrok van der Werven | 0a86694 | 2009-05-08 14:18:00 +0000 | [diff] [blame] | 1389 | 0x083e: "ms_BN", # Malay - Brunei Darussalam |
Georg Brandl | b709c2c | 2006-01-20 09:07:35 +0000 | [diff] [blame] | 1390 | 0x044c: "ml_IN", # Malayalam - India |
| 1391 | 0x043a: "mt_MT", # Maltese |
| 1392 | 0x0481: "mi_NZ", # Maori |
| 1393 | 0x047a: "arn_CL",# Mapudungun |
| 1394 | 0x044e: "mr_IN", # Marathi |
| 1395 | 0x047c: "moh_CA",# Mohawk - Canada |
Jeroen Ruigrok van der Werven | 0a86694 | 2009-05-08 14:18:00 +0000 | [diff] [blame] | 1396 | 0x0450: "mn_MN", # Mongolian - Cyrillic |
| 1397 | 0x0850: "mn_CN", # Mongolian - PRC |
Georg Brandl | b709c2c | 2006-01-20 09:07:35 +0000 | [diff] [blame] | 1398 | 0x0461: "ne_NP", # Nepali |
| 1399 | 0x0414: "nb_NO", # Norwegian - Bokmal |
| 1400 | 0x0814: "nn_NO", # Norwegian - Nynorsk |
| 1401 | 0x0482: "oc_FR", # Occitan - France |
| 1402 | 0x0448: "or_IN", # Oriya - India |
| 1403 | 0x0463: "ps_AF", # Pashto - Afghanistan |
| 1404 | 0x0429: "fa_IR", # Persian |
| 1405 | 0x0415: "pl_PL", # Polish |
| 1406 | 0x0416: "pt_BR", # Portuguese - Brazil |
| 1407 | 0x0816: "pt_PT", # Portuguese - Portugal |
| 1408 | 0x0446: "pa_IN", # Punjabi |
| 1409 | 0x046b: "quz_BO",# Quechua (Bolivia) |
| 1410 | 0x086b: "quz_EC",# Quechua (Ecuador) |
| 1411 | 0x0c6b: "quz_PE",# Quechua (Peru) |
| 1412 | 0x0418: "ro_RO", # Romanian - Romania |
Jeroen Ruigrok van der Werven | 0a86694 | 2009-05-08 14:18:00 +0000 | [diff] [blame] | 1413 | 0x0417: "rm_CH", # Romansh |
Georg Brandl | b709c2c | 2006-01-20 09:07:35 +0000 | [diff] [blame] | 1414 | 0x0419: "ru_RU", # Russian |
| 1415 | 0x243b: "smn_FI",# Sami Finland |
| 1416 | 0x103b: "smj_NO",# Sami Norway |
| 1417 | 0x143b: "smj_SE",# Sami Sweden |
| 1418 | 0x043b: "se_NO", # Sami Northern Norway |
| 1419 | 0x083b: "se_SE", # Sami Northern Sweden |
| 1420 | 0x0c3b: "se_FI", # Sami Northern Finland |
| 1421 | 0x203b: "sms_FI",# Sami Skolt |
| 1422 | 0x183b: "sma_NO",# Sami Southern Norway |
| 1423 | 0x1c3b: "sma_SE",# Sami Southern Sweden |
| 1424 | 0x044f: "sa_IN", # Sanskrit |
| 1425 | 0x0c1a: "sr_SP", # Serbian - Cyrillic |
| 1426 | 0x1c1a: "sr_BA", # Serbian - Bosnia Cyrillic |
| 1427 | 0x081a: "sr_SP", # Serbian - Latin |
| 1428 | 0x181a: "sr_BA", # Serbian - Bosnia Latin |
Jeroen Ruigrok van der Werven | 0a86694 | 2009-05-08 14:18:00 +0000 | [diff] [blame] | 1429 | 0x045b: "si_LK", # Sinhala - Sri Lanka |
Georg Brandl | b709c2c | 2006-01-20 09:07:35 +0000 | [diff] [blame] | 1430 | 0x046c: "ns_ZA", # Northern Sotho |
| 1431 | 0x0432: "tn_ZA", # Setswana - Southern Africa |
| 1432 | 0x041b: "sk_SK", # Slovak |
| 1433 | 0x0424: "sl_SI", # Slovenian |
| 1434 | 0x040a: "es_ES", # Spanish - Spain |
| 1435 | 0x080a: "es_MX", # Spanish - Mexico |
| 1436 | 0x0c0a: "es_ES", # Spanish - Spain (Modern) |
| 1437 | 0x100a: "es_GT", # Spanish - Guatemala |
| 1438 | 0x140a: "es_CR", # Spanish - Costa Rica |
| 1439 | 0x180a: "es_PA", # Spanish - Panama |
| 1440 | 0x1c0a: "es_DO", # Spanish - Dominican Republic |
| 1441 | 0x200a: "es_VE", # Spanish - Venezuela |
| 1442 | 0x240a: "es_CO", # Spanish - Colombia |
| 1443 | 0x280a: "es_PE", # Spanish - Peru |
| 1444 | 0x2c0a: "es_AR", # Spanish - Argentina |
| 1445 | 0x300a: "es_EC", # Spanish - Ecuador |
| 1446 | 0x340a: "es_CL", # Spanish - Chile |
| 1447 | 0x380a: "es_UR", # Spanish - Uruguay |
| 1448 | 0x3c0a: "es_PY", # Spanish - Paraguay |
| 1449 | 0x400a: "es_BO", # Spanish - Bolivia |
| 1450 | 0x440a: "es_SV", # Spanish - El Salvador |
| 1451 | 0x480a: "es_HN", # Spanish - Honduras |
| 1452 | 0x4c0a: "es_NI", # Spanish - Nicaragua |
| 1453 | 0x500a: "es_PR", # Spanish - Puerto Rico |
Jeroen Ruigrok van der Werven | 0a86694 | 2009-05-08 14:18:00 +0000 | [diff] [blame] | 1454 | 0x540a: "es_US", # Spanish - United States |
| 1455 | # 0x0430: "", # Sutu - Not supported |
Georg Brandl | b709c2c | 2006-01-20 09:07:35 +0000 | [diff] [blame] | 1456 | 0x0441: "sw_KE", # Swahili |
| 1457 | 0x041d: "sv_SE", # Swedish - Sweden |
| 1458 | 0x081d: "sv_FI", # Swedish - Finland |
| 1459 | 0x045a: "syr_SY",# Syriac |
Jeroen Ruigrok van der Werven | 0a86694 | 2009-05-08 14:18:00 +0000 | [diff] [blame] | 1460 | 0x0428: "tg_TJ", # Tajik - Cyrillic |
| 1461 | 0x085f: "tmz_DZ",# Tamazight - Latin |
Georg Brandl | b709c2c | 2006-01-20 09:07:35 +0000 | [diff] [blame] | 1462 | 0x0449: "ta_IN", # Tamil |
| 1463 | 0x0444: "tt_RU", # Tatar |
| 1464 | 0x044a: "te_IN", # Telugu |
| 1465 | 0x041e: "th_TH", # Thai |
Jeroen Ruigrok van der Werven | 0a86694 | 2009-05-08 14:18:00 +0000 | [diff] [blame] | 1466 | 0x0851: "bo_BT", # Tibetan - Bhutan |
| 1467 | 0x0451: "bo_CN", # Tibetan - PRC |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 1468 | 0x041f: "tr_TR", # Turkish |
Jeroen Ruigrok van der Werven | 0a86694 | 2009-05-08 14:18:00 +0000 | [diff] [blame] | 1469 | 0x0442: "tk_TM", # Turkmen - Cyrillic |
| 1470 | 0x0480: "ug_CN", # Uighur - Arabic |
Georg Brandl | b709c2c | 2006-01-20 09:07:35 +0000 | [diff] [blame] | 1471 | 0x0422: "uk_UA", # Ukrainian |
Jeroen Ruigrok van der Werven | 0a86694 | 2009-05-08 14:18:00 +0000 | [diff] [blame] | 1472 | 0x042e: "wen_DE",# Upper Sorbian - Germany |
Georg Brandl | b709c2c | 2006-01-20 09:07:35 +0000 | [diff] [blame] | 1473 | 0x0420: "ur_PK", # Urdu |
| 1474 | 0x0820: "ur_IN", # Urdu - India |
| 1475 | 0x0443: "uz_UZ", # Uzbek - Latin |
| 1476 | 0x0843: "uz_UZ", # Uzbek - Cyrillic |
| 1477 | 0x042a: "vi_VN", # Vietnamese |
| 1478 | 0x0452: "cy_GB", # Welsh |
Jeroen Ruigrok van der Werven | 0a86694 | 2009-05-08 14:18:00 +0000 | [diff] [blame] | 1479 | 0x0488: "wo_SN", # Wolof - Senegal |
| 1480 | 0x0434: "xh_ZA", # Xhosa - South Africa |
| 1481 | 0x0485: "sah_RU",# Yakut - Cyrillic |
| 1482 | 0x0478: "ii_CN", # Yi - PRC |
| 1483 | 0x046a: "yo_NG", # Yoruba - Nigeria |
| 1484 | 0x0435: "zu_ZA", # Zulu |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 1485 | } |
| 1486 | |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 1487 | def _print_locale(): |
| 1488 | |
| 1489 | """ Test function. |
| 1490 | """ |
| 1491 | categories = {} |
| 1492 | def _init_categories(categories=categories): |
| 1493 | for k,v in globals().items(): |
| 1494 | if k[:3] == 'LC_': |
| 1495 | categories[k] = v |
| 1496 | _init_categories() |
| 1497 | del categories['LC_ALL'] |
| 1498 | |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 1499 | print('Locale defaults as determined by getdefaultlocale():') |
| 1500 | print('-'*72) |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 1501 | lang, enc = getdefaultlocale() |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 1502 | print('Language: ', lang or '(undefined)') |
| 1503 | print('Encoding: ', enc or '(undefined)') |
| 1504 | print() |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 1505 | |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 1506 | print('Locale settings on startup:') |
| 1507 | print('-'*72) |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 1508 | for name,category in categories.items(): |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 1509 | print(name, '...') |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 1510 | lang, enc = getlocale(category) |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 1511 | print(' Language: ', lang or '(undefined)') |
| 1512 | print(' Encoding: ', enc or '(undefined)') |
| 1513 | print() |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 1514 | |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 1515 | print() |
| 1516 | print('Locale settings after calling resetlocale():') |
| 1517 | print('-'*72) |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 1518 | resetlocale() |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 1519 | for name,category in categories.items(): |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 1520 | print(name, '...') |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 1521 | lang, enc = getlocale(category) |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 1522 | print(' Language: ', lang or '(undefined)') |
| 1523 | print(' Encoding: ', enc or '(undefined)') |
| 1524 | print() |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 1525 | |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 1526 | try: |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 1527 | setlocale(LC_ALL, "") |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 1528 | except: |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 1529 | print('NOTE:') |
| 1530 | print('setlocale(LC_ALL, "") does not support the default locale') |
| 1531 | print('given in the OS environment variables.') |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 1532 | else: |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 1533 | print() |
| 1534 | print('Locale settings after calling setlocale(LC_ALL, ""):') |
| 1535 | print('-'*72) |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 1536 | for name,category in categories.items(): |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 1537 | print(name, '...') |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 1538 | lang, enc = getlocale(category) |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 1539 | print(' Language: ', lang or '(undefined)') |
| 1540 | print(' Encoding: ', enc or '(undefined)') |
| 1541 | print() |
Fredrik Lundh | 6c86b99 | 2000-07-09 17:12:58 +0000 | [diff] [blame] | 1542 | |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 1543 | ### |
Guido van Rossum | eef1d4e | 1997-11-19 19:01:43 +0000 | [diff] [blame] | 1544 | |
Tim Peters | 1baf829 | 2001-01-24 10:13:46 +0000 | [diff] [blame] | 1545 | try: |
| 1546 | LC_MESSAGES |
Skip Montanaro | 0897f0c | 2002-03-25 21:40:36 +0000 | [diff] [blame] | 1547 | except NameError: |
Tim Peters | 1baf829 | 2001-01-24 10:13:46 +0000 | [diff] [blame] | 1548 | pass |
| 1549 | else: |
| 1550 | __all__.append("LC_MESSAGES") |
| 1551 | |
Guido van Rossum | eef1d4e | 1997-11-19 19:01:43 +0000 | [diff] [blame] | 1552 | if __name__=='__main__': |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 1553 | print('Locale aliasing:') |
| 1554 | print() |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 1555 | _print_locale() |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 1556 | print() |
| 1557 | print('Number formatting:') |
| 1558 | print() |
Marc-André Lemburg | 5431bc3 | 2000-06-07 09:11:40 +0000 | [diff] [blame] | 1559 | _test() |