betty.locale.localizable.static package¶
Submodules¶
Module contents¶
Static translations.
- final class betty.locale.localizable.static.CountableStaticTranslations¶
Bases:
CountableLocalizable,PortableA countable localizable backed by static translations.
- __init__(translations: ShorthandCountableStaticTranslations, /)¶
- count(count: LocalizableCount, /) Localizable¶
Create a localizable for the given count (number of things).
Implementations MUST automatically format the returned localizable with a
{count}argument set tocount.
- dump() PortableData¶
Dump the instance to portable data.
- Raises:
betty.portable.error.NotPortable – Raised if any part of the data is not portable.
- classmethod load(portable: PortableData, /) Self¶
Create a new instance from portable data.
- Raises:
betty.exception.HumanFacingException – Raised if the portable data is invalid.
- property translations: CountableStaticTranslationsMapping¶
The translations.
- final class betty.locale.localizable.static.StaticTranslations¶
Bases:
Localizable,PortableA localizable backed by static translations.
All configuration options¶
This configuration is either a single translation as a string, or multiple translations as a key-value mapping.
A single translation¶
Type
string
A single translation can be set that is to be used for all languages.
Example configuration:
"I am a single translation, used for all languages""I am a single translation, used for all languages"Multiple translations¶
Type
- mapping
Keys (string) are IETF BCP 47 language tags, and values (string) are human-readable translations.
Example configuration:
en-US: "I'm the English translation" nl-NL: "Ik ben de Nederlandse vertaling"
{ "en-US": "I'm the English translation", "nl-NL": "Ik ben de Nederlandse vertaling", }
- __init__(translations: ShorthandStaticTranslations, /)¶
- Parameters:
translations – Keys are locales, values are translations.
- dump() PortableData¶
Dump the instance to portable data.
- Raises:
betty.portable.error.NotPortable – Raised if any part of the data is not portable.
- classmethod load(portable: PortableData, /) Self¶
Create a new instance from portable data.
- Raises:
betty.exception.HumanFacingException – Raised if the portable data is invalid.
- localize(localizer: Localizer, /) LocalizedStr¶
Localize
selfto a human-readable string.
- classmethod resolve(other: Localizable, localizers: Iterable[Localizer], /) Self¶
Create a new instance from another :py:class`betty.locale.localizable.Localizable`.
- property translations: StaticTranslationsMapping¶
The translations.