betty.locale package¶
Subpackages¶
Submodules¶
Module contents¶
Provide the Locale API.
- class betty.locale.Localized¶
Bases:
ABCA resource that has a locale, e.g. contains information in a specific locale.
- final class betty.locale.LocalizedStr¶
-
A string that has a locale.
- betty.locale.default_locale: Final[Locale] = Locale('en', territory='US')¶
Betty’s default locale (US English).
- betty.locale.default_locale_tag: Final[str] = 'en-US'¶
The IETF BCP 47 language tag for Betty’s default locale (US English).
- betty.locale.from_language_tag(language_tag: str, /) Locale¶
Get a locale from its IETF BCP 47 language tag.
- Raises:
betty.locale.InvalidLocale – Raised if the given identifier is not a valid locale.
betty.locale.LocaleNotFoundError – Raised if the given locale cannot be found.
- betty.locale.negotiate_has_locales(preferred_locales: Locale | Sequence[Locale], has_locales: Sequence[Localized]) Localized | None¶
Negotiate the preferred value from a sequence.
- betty.locale.negotiate_locale(preferred_locales: Locale | Sequence[Locale], available_locales: Sequence[Locale], /) Locale | None¶
Negotiate the preferred locale from a sequence.
- betty.locale.resolve_locale(locale: ResolvableLocale, /) Locale¶
Ensure that the given value is a locale.
- Raises:
betty.locale.InvalidLocale – Raised if the given identifier is not a valid locale.
betty.locale.LocaleNotFoundError – Raised if the given locale cannot be found.
- betty.locale.to_language_tag(locale: Locale | None, /) str¶
Formats a locale as an IETF BCP 47 language tag.