arelle.Locale
#
This module is a local copy of python locale in order to allow passing in localconv as an argument to functions without affecting system-wide settings. (The system settings can remain in ‘C’ locale.)
See COPYRIGHT.md for copyright information.
Module Contents#
Functions#
Get locale conventions dictionary. May change the global locale if called directly. |
|
Get locale conventions dictionary. Ensures that the locale (global to the process) is reset afterwards. |
|
Sets the locale to C, to be used when running Arelle as a standalone application
(e.g., |
|
Returns the locale-aware substitution of a %? specifier (percent). |
|
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. |
|
Formats val according to the currency settings in the current locale. |
|
Convert float to integer, taking the locale into account. |
|
Parses a string as a float according to the locale settings. |
|
Converts a string to an integer according to the locale settings. |
|
Convert Decimal to a formatted string including currency if any. |
Data#
API#
- arelle.Locale._: arelle.typing.TypeGetText#
None
- arelle.Locale.CHAR_MAX#
127
- arelle.Locale.LC_ALL#
6
- arelle.Locale.LC_COLLATE#
3
- arelle.Locale.LC_CTYPE#
0
- arelle.Locale.LC_MESSAGES#
5
- arelle.Locale.LC_MONETARY#
4
- arelle.Locale.LC_NUMERIC#
1
- arelle.Locale.LC_TIME#
2
- arelle.Locale.defaultLocaleCodes#
None
- arelle.Locale._getUserLocaleUnsafe(localeCode: str = '') tuple[arelle.typing.LocaleDict, str | None] #
Get locale conventions dictionary. May change the global locale if called directly.
- Parameters:
localeCode – The locale code to use to retrieve conventions. Defaults to system default.
- Returns:
Tuple of local conventions dictionary and a user-directed setup message
- arelle.Locale.getUserLocale(localeCode: str = '') tuple[arelle.typing.LocaleDict, str | None] #
Get locale conventions dictionary. Ensures that the locale (global to the process) is reset afterwards.
- Parameters:
localeCode – The locale code to use to retrieve conventions. Defaults to system default.
- Returns:
Tuple of local conventions dictionary and a user-directed setup message
- arelle.Locale.getLanguageCode() str #
- arelle.Locale.getLanguageCodes(lang: str | None = None) list[str] #
- arelle.Locale.iso3region#
None
- arelle.Locale.getLocaleList() list[str] #
- arelle.Locale._availableLocales#
None
- arelle.Locale.availableLocales() set[str] #
- arelle.Locale._languageCodes#
None
- arelle.Locale.languageCodes() dict[str, str] #
- arelle.Locale.setApplicationLocale() None #
Sets the locale to C, to be used when running Arelle as a standalone application (e.g.,
arelleCmdLine
,arelleGUI
.)- Returns:
- arelle.Locale._disableRTL: bool#
False
- arelle.Locale.setDisableRTL(disableRTL: bool) None #
- arelle.Locale.rtlString(source: str, lang: str | None) str #
- arelle.Locale._grouping_intervals(grouping: list[int]) Generator[int, None, None] #
- arelle.Locale._group(conv: arelle.typing.LocaleDict, s: str, monetary: bool = False) tuple[str, int] #
- arelle.Locale._strip_padding(s: str, amount: int) str #
- arelle.Locale._percent_re#
None
- arelle.Locale.format(conv: arelle.typing.LocaleDict, percent: str, value: Any, grouping: bool = False, monetary: bool = False, *additional: str) str #
Returns the locale-aware substitution of a %? specifier (percent).
additional is for format strings which contain one or more ‘*’ modifiers.
- arelle.Locale._format(conv: arelle.typing.LocaleDict, percent: str, value: Any, grouping: bool = False, monetary: bool = False, *additional: str) str #
- arelle.Locale.format_string(conv: arelle.typing.LocaleDict, f: str, val: Any, grouping: bool = False) str #
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.
- arelle.Locale.currency(conv: arelle.typing.LocaleDict, val: int | float, symbol: bool = True, grouping: bool = False, international: bool = False) str #
Formats val according to the currency settings in the current locale.
- arelle.Locale.ftostr(conv: arelle.typing.LocaleDict, val: Any) str #
Convert float to integer, taking the locale into account.
- arelle.Locale.atof(conv: arelle.typing.LocaleDict, string: str, func: Callable[[str], Any] = float) Any #
Parses a string as a float according to the locale settings.
- arelle.Locale.atoi(conv: arelle.typing.LocaleDict, str: arelle.Locale.atoi.str) int #
Converts a string to an integer according to the locale settings.
- arelle.Locale.format_picture(conv: arelle.typing.LocaleDict, value: Any, picture: str) str #
- arelle.Locale.format_decimal(conv: arelle.typing.LocaleDict | None, value: decimal.Decimal, intPlaces: int = 1, fractPlaces: int = 2, curr: str = '', sep: str | None = None, grouping: int | None = None, dp: str | None = None, pos: str | None = None, neg: str | None = None, trailpos: str | None = None, trailneg: str | None = None) str #
Convert Decimal to a formatted string including currency if any.
intPlaces: required number of digits before the decimal point fractPlaces: required number of places after the decimal point curr: optional currency symbol before the sign (may be blank) sep: optional grouping separator (comma, period, space, or blank) dp: decimal point indicator (comma or period) only specify as blank when places is zero pos: optional sign for positive numbers: ‘+’, space or blank neg: optional sign for negative numbers: ‘-’, ‘(’, space or blank trailneg:optional trailing minus indicator: ‘-’, ‘)’, space or blank
d = Decimal(‘-1234567.8901’) format_decimal(getUserLocale()[0], d, curr=’$’) ‘-$1,234,567.89’ format_decimal(getUserLocale()[0], d, fractPlaces=0, sep=’.’, dp=’’, neg=’’, trailneg=’-‘) ‘1.234.568-’ format_decimal(getUserLocale()[0], d, curr=’$’, neg=’(’, trailneg=’)’) ‘($1,234,567.89)’ format_decimal(getUserLocale()[0], Decimal(123456789), sep=’ ‘) ‘123 456 789.00’ format_decimal(getUserLocale()[0], Decimal(‘-0.02’), neg=’<’, trailneg=’>’) ‘<0.02>’