locale¶
Locale support module.
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.
Functions¶
atof(string[, func]) |
Parses a string as a float according to the locale settings. |
atoi(str) |
Converts a string to an integer according to the locale settings. |
bind_textdomain_codeset((domain, ...) |
Bind the C library’s domain to codeset. |
bindtextdomain((domain, dir) -> string) |
Bind the C library’s domain to dir. |
currency(val[, symbol, grouping, international]) |
Formats val according to the currency settings in the current locale. |
dcgettext((domain, msg, category) -> string) |
Return translation of msg in domain and category. |
dgettext((domain, msg) -> string) |
Return translation of msg in domain. |
format(percent, value[, grouping, monetary]) |
Returns the locale-aware substitution of a %? specifier (percent). |
format_string(f, val[, grouping]) |
Formats a string in the same way that the % formatting would use, but takes the current locale into account. |
getdefaultlocale([envvars]) |
Tries to determine the default locale settings and returns them as tuple (language code, encoding). |
getlocale([category]) |
Returns the current setting for the given locale category as tuple (language code, encoding). |
getpreferredencoding([do_setlocale]) |
Return the charset that the user is likely using, according to the system configuration. |
gettext((msg) -> string) |
Return translation of msg. |
localeconv() |
() -> dict. Returns numeric and monetary locale-specific parameters. |
nl_langinfo((key) -> string) |
Return the value for the locale information associated with key. |
normalize(localename) |
Returns a normalized locale code for the given locale name. |
resetlocale([category]) |
Sets the locale for category to the default setting. |
setlocale(category[, locale]) |
Set the locale for the given category. |
str(val) |
Convert float to string, taking the locale into account. |
strcoll |
string,string -> int. Compares two strings according to the locale. |
strxfrm |
string -> string. Returns a string that behaves for cmp locale-aware. |
textdomain((domain) -> string) |
Set the C library’s textdmain to domain, returning the new domain. |