Trees | Indices | Help |
|
---|
|
Locale support.
The module provides low-level access to the C lib's locale APIs and adds high level number formatting APIs as well as a locale aliasing engine to complement these.
The aliasing engine includes support for many commonly used locale names and maps them to values suitable for passing to the C lib's setlocale() function. It also includes default encodings for all supported locale names.
|
|||
Error |
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|
|||
CHAR_MAX = 127
|
|||
LC_ALL = 6
|
|||
LC_COLLATE = 3
|
|||
LC_CTYPE = 0
|
|||
LC_MESSAGES = 5
|
|||
LC_MONETARY = 4
|
|||
LC_NUMERIC = 1
|
|||
LC_TIME = 2
|
|||
_percent_re = re.compile(r'%
|
|||
locale_encoding_alias =
|
|||
locale_alias =
|
|||
windows_locale =
|
|||
ABDAY_1 = 131072
|
|||
ABDAY_2 = 131073
|
|||
ABDAY_3 = 131074
|
|||
ABDAY_4 = 131075
|
|||
ABDAY_5 = 131076
|
|||
ABDAY_6 = 131077
|
|||
ABDAY_7 = 131078
|
|||
ABMON_1 = 131086
|
|||
ABMON_10 = 131095
|
|||
ABMON_11 = 131096
|
|||
ABMON_12 = 131097
|
|||
ABMON_2 = 131087
|
|||
ABMON_3 = 131088
|
|||
ABMON_4 = 131089
|
|||
ABMON_5 = 131090
|
|||
ABMON_6 = 131091
|
|||
ABMON_7 = 131092
|
|||
ABMON_8 = 131093
|
|||
ABMON_9 = 131094
|
|||
ALT_DIGITS = 131119
|
|||
AM_STR = 131110
|
|||
CODESET = 14
|
|||
CRNCYSTR = 262159
|
|||
DAY_1 = 131079
|
|||
DAY_2 = 131080
|
|||
DAY_3 = 131081
|
|||
DAY_4 = 131082
|
|||
DAY_5 = 131083
|
|||
DAY_6 = 131084
|
|||
DAY_7 = 131085
|
|||
D_FMT = 131113
|
|||
D_T_FMT = 131112
|
|||
ERA = 131116
|
|||
ERA_D_FMT = 131118
|
|||
ERA_D_T_FMT = 131120
|
|||
ERA_T_FMT = 131121
|
|||
MON_1 = 131098
|
|||
MON_10 = 131107
|
|||
MON_11 = 131108
|
|||
MON_12 = 131109
|
|||
MON_2 = 131099
|
|||
MON_3 = 131100
|
|||
MON_4 = 131101
|
|||
MON_5 = 131102
|
|||
MON_6 = 131103
|
|||
MON_7 = 131104
|
|||
MON_8 = 131105
|
|||
MON_9 = 131106
|
|||
NOEXPR = 327681
|
|||
PM_STR = 131111
|
|||
RADIXCHAR = 65536
|
|||
THOUSEP = 65537
|
|||
T_FMT = 131114
|
|||
T_FMT_AMPM = 131115
|
|||
YESEXPR = 327680
|
Imports: sys, encodings, re, operator, _setlocale, bind_textdomain_codeset, bindtextdomain, dcgettext, dgettext, gettext, nl_langinfo, textdomain
|
() -> dict. Returns numeric and monetary locale-specific parameters. |
string,string -> int. Compares two strings according to the locale. |
string -> string. Returns a string that behaves for cmp locale-aware. |
Returns the locale-aware substitution of a %? specifier (percent). additional is for format strings which contain one or more '*' modifiers. |
Formats a string in the same way that the % formatting would use, but takes the current locale into account. Grouping is applied if the third parameter is true. |
Returns a normalized locale code for the given locale name. The returned locale code is formatted for use with setlocale(). If normalization fails, the original name is returned unchanged. If the given encoding is not known, the function defaults to the default encoding for the locale code just like setlocale() does. |
Parses the locale code for localename and returns the result as tuple (language code, encoding). The localename is normalized and passed through the locale alias engine. A ValueError is raised in case the locale name cannot be parsed. The language code corresponds to RFC 1766. code and encoding can be None in case the values cannot be determined or are unknown to this implementation. |
Builds a locale code from the given tuple (language code, encoding). No aliasing or normalizing takes place. |
Tries to determine the default locale settings and returns them as tuple (language code, encoding). According to POSIX, a program which has not called setlocale(LC_ALL, "") runs using the portable 'C' locale. Calling setlocale(LC_ALL, "") lets it use the default locale as defined by the LANG variable. Since we don't want to interfere with the current locale setting we thus emulate the behavior in the way described above. To maintain compatibility with other platforms, not only the LANG variable is tested, but a list of variables given as envvars parameter. The first found to be defined will be used. envvars defaults to the search path used in GNU gettext; it must always contain the variable name 'LANG'. Except for the code 'C', the language code corresponds to RFC 1766. code and encoding can be None in case the values cannot be determined. |
Returns the current setting for the given locale category as tuple (language code, encoding). category may be one of the LC_* value except LC_ALL. It defaults to LC_CTYPE. Except for the code 'C', the language code corresponds to RFC 1766. code and encoding can be None in case the values cannot be determined. |
Set the locale for the given category. The locale can be a string, a locale tuple (language code, encoding), or None. Locale tuples are converted to strings the locale aliasing engine. Locale strings are passed directly to the C lib. category may be given as one of the LC_* values. |
Sets the locale for category to the default setting. The default setting is determined by calling getdefaultlocale(). category defaults to LC_ALL. |
|
_percent_re
|
locale_encoding_alias
|
locale_alias
|
windows_locale
|
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0 on Tue Jan 29 22:41:02 2008 | http://epydoc.sourceforge.net |