betty.locale.translation module¶
Manage translations of built-in translatable strings.
- final class betty.locale.translation.AssetTranslationRepository¶
Bases:
TranslationRepository,BootstrappableProvide translations from assets.
This is thread-safe, which means you can safely use this between different threads.
- __init__(assets: AssetRepository, cache: BinaryFileCache)¶
- async coverage(locale: ResolvableLocale) tuple[int, int]¶
Get the translation coverage for the given locale.
- Returns:
A 2-tuple of the number of available translations and the number of translatable source strings.
- get(locale: ResolvableLocale) NullTranslations¶
Get the translations for the given locale.
- property locales: Iterable[Locale]¶
The available locales.
- final class betty.locale.translation.StaticTranslationRepository¶
Bases:
TranslationRepositoryProvide static translations.
- __init__(translations: Mapping[Locale, gettext.NullTranslations])¶
- get(locale: ResolvableLocale) NullTranslations¶
Get the translations for the given locale.
- property locales: Iterable[Locale]¶
The available locales.
- class betty.locale.translation.TranslationRepository¶
Bases:
ABCProvide translations.
- abstractmethod get(locale: ResolvableLocale) NullTranslations¶
Get the translations for the given locale.
- abstract property locales: Iterable[Locale]¶
The available locales.
- final exception betty.locale.translation.UntranslatedLocale¶
Bases:
LocaleErrorRaised when no translations exist for a locale.
- __init__(locale: Locale, /)¶
- betty.locale.translation.default_translation_repository: Final[TranslationRepository] = <betty.locale.translation.StaticTranslationRepository object>¶
The translation repository for the default locale.
- async betty.locale.translation.new_translation(output: AssetDirectoryDefinition, locale: Locale, *, user: User) None¶
Create a new translation.