gws.lib.intl
¶
Intl and localization tools.
Source code: gws.lib.intl
Package Contents¶
- gws.lib.intl.locale(locale_uid: str) gws.Locale | None ¶
Creates a locale object with formatting information about date, time and numbers.
- Parameters:
locale_uid – ID in the format language_territory e.g. de_DE, or de.
- Returns:
Formatting information for that area.
- gws.lib.intl.bibliographic_name(language: str) str ¶
Country abbreviation for a given language
- Parameters:
language – 2 letter abbreviation for a language.
- Returns:
ISO 3166-1 alpha-3 code for the language’s country.
- class gws.lib.intl.DateFormatter(locale_uid)¶
- property short¶
Returns the date in a short format with respect to the locale date format
- property medium¶
Returns the date in a medium format with respect to the locale date format
- property long¶
Returns the date in a long format with respect to the locale date format
- property iso¶
Returns the time and date in the ISO 8601 format.
- format(fmt: gws.DateTimeFormatType, date=None)¶
- class gws.lib.intl.TimeFormatter(locale_uid)¶
- property short¶
Returns the time in a short format with respect to the locale time format
- property medium¶
Returns the time in a medium format with respect to the locale time format
- property long¶
Returns the time in a long format with respect to the locale time format
- property iso¶
Returns the time and date in the ISO 8601 format.
- format(fmt: gws.DateTimeFormatType, time=None) str ¶
- class gws.lib.intl.NumberFormatter(locale_uid)¶
Bases:
gws.NumberFormatter
Used for number formatting
- format(fmt, n, *args, **kwargs)¶
Formats the number with respect to the locale.
- Parameters:
fmt – Format type or a python format string
n – Number.
kwargs – Passes the currency parameter forward.
- Returns:
A formatted number.
- decimal(n, *args, **kwargs)¶
- grouped(n, *args, **kwargs)¶
- currency(n, *args, **kwargs)¶
- percent(n, *args, **kwargs)¶
- gws.lib.intl.date_formatter(locale_uid) DateFormatter ¶
Creates a DateFormatter if there is no other instance of that class to the same locale_uid.
- Parameters:
locale_uid – ID in the format language_territory e.g. de_DE.
- Returns:
DateFormatter object.
- gws.lib.intl.time_formatter(locale_uid) TimeFormatter ¶
Creates a TimeFormatter if there is no other instance of that class to the same locale_uid.
- Parameters:
locale_uid – ID in the format language_territory e.g. de_DE.
- Returns:
TimeFormatter object.
- gws.lib.intl.number_formatter(locale_uid) NumberFormatter ¶
Creates a NumberFormatter if there is no other instance of that class to the same locale_uid.
- Parameters:
locale_uid – ID in the format language_territory e.g. de_DE.
- Returns:
NumberFormatter object.