betty.gettext module#
Manage translations of built-in translatable strings.
- final class betty.gettext.MoTranslations#
Bases:
TranslationsTranslations from
*.mofile data.- gettext(message: str, /) LocalizedStr | None#
Like
gettext.gettext().Arguments are identical to those of
gettext.gettext().
- ngettext(message_singular: str, message_plural: str, n: int, /) LocalizedStr | None#
Like
gettext.ngettext().Arguments are identical to those of
gettext.ngettext().
- npgettext(context: str, message_singular: str, message_plural: str, n: int, /) LocalizedStr | None#
Like
gettext.npgettext().Arguments are identical to those of
gettext.npgettext().
- pgettext(context: str, message: str, /) LocalizedStr | None#
Like
gettext.pgettext().Arguments are identical to those of
gettext.pgettext().
- class betty.gettext.Translations#
Bases:
ABCA set of translations.
- abstractmethod gettext(message: str, /) LocalizedStr | None#
Like
gettext.gettext().Arguments are identical to those of
gettext.gettext().
- abstractmethod ngettext(message_singular: str, message_plural: str, n: int, /) LocalizedStr | None#
Like
gettext.ngettext().Arguments are identical to those of
gettext.ngettext().
- abstractmethod npgettext(context: str, message_singular: str, message_plural: str, n: int, /) LocalizedStr | None#
Like
gettext.npgettext().Arguments are identical to those of
gettext.npgettext().
- abstractmethod pgettext(context: str, message: str, /) LocalizedStr | None#
Like
gettext.pgettext().Arguments are identical to those of
gettext.pgettext().
- final class betty.gettext.TranslationsRepository#
Bases:
objectExpose translations.
- __init__(*, assets: AssetRepository, cache: TransientBinaryFileStore)#
- async get(locale: ResolvableLocale, /) Iterable[Translations]#
Get the translations for the given locale.
- final class betty.gettext.Translator#
Bases:
TranslationsTranslate strings.
The translator always reliably returns strings. If no translations can be found, the original source strings are returned with the correct locale information.
- __init__(*translations: Translations)#
- gettext(message: str, /) LocalizedStr#
Like
gettext.gettext().Arguments are identical to those of
gettext.gettext().
- 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().
- async betty.gettext.new_translation(output: AssetDirectoryDefinition, locale: Locale, *, user: User) None#
Create a new translation.