betty.locale package

Submodules

Module contents

Provide the Locale API.

exception betty.locale.LocaleNotFoundError[source]

Bases: RuntimeError

Raise when a locale could not be found.

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

Get locale metadata.

Raises:

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.