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