betty.locale package

Subpackages

Submodules

Module contents

Provide the Locale API.

betty.locale.get_data(locale: str | Locale) Locale[source]

Get locale metadata.

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.get_display_name(locale: str | Locale, display_locale: str | Locale | None = None) str | None[source]

Return a locale’s human-readable display name.

betty.locale.negotiate_locale(preferred_locales: str | Locale | Sequence[str | Locale], available_locales: Sequence[str | Locale]) Locale | None[source]

Negotiate the preferred locale from a sequence.

betty.locale.to_babel_identifier(locale: str | Locale) str[source]

Convert a locale or locale metadata to a Babel locale identifier.

betty.locale.to_locale(locale: str | Locale) str[source]

Ensure that a locale or locale metadata is a locale.