betty.locale.localize package

Module contents

Localizers provide a wide range of localization utilities through a single entry point.

final class betty.locale.localize.Localizer

Bases: object

Localize a variety of data into a specific locale.

__init__(locale: ResolvableLocale, translations: NullTranslations, /)
gettext(message: str, /) LocalizedStr

Like gettext.gettext().

Arguments are identical to those of gettext.gettext().

property locale: Locale

The locale.

ngettext(message_singular: str, message_plural: str, n: int, /) LocalizedStr

Like gettext.ngettext().

Arguments are identical to those of gettext.ngettext().

npgettext(context: str, message_singular: str, message_plural: str, n: int, /) LocalizedStr

Like gettext.npgettext().

Arguments are identical to those of gettext.npgettext().

pgettext(context: str, message: str, /) LocalizedStr

Like gettext.pgettext().

Arguments are identical to those of gettext.pgettext().

final class betty.locale.localize.LocalizerRepository

Bases: object

Exposes the available localizers.

This is thread-safe, which means you can safely use this between different threads.

__init__(translations: TranslationRepository, /)
get(locale: ResolvableLocale, /) Localizer

Get the localizer for the given locale.

betty.locale.localize.resolve_localized(localizable: ResolvableLocalizable, *, localizer: Localizer) LocalizedStr

Ensure that a localizable-like value is or is made to be localized.