betty.locale.localizer module¶
Localizers provide a wide range of localization utilities through a single entry point.
- class betty.locale.localizer.Localizer[source]¶
Bases:
object
Provide localization functionality for a specific locale.
- __init__(locale: str, translations: NullTranslations)[source]¶
- format_date_range(date_range: DateRange) str [source]¶
Format a date range to a human-readable string.
- format_datetime_datetime(datetime_datetime: datetime) str [source]¶
Format a datetime date to a human-readable string.
- format_datey(date: Date | DateRange) str [source]¶
Format a datey value into a human-readable string.
- gettext(message: str) str [source]¶
Like
gettext.gettext()
.Arguments are identical to those of
gettext.gettext()
.
- ngettext(message_singular: str, message_plural: str, n: int) str [source]¶
Like
gettext.ngettext()
.Arguments are identical to those of
gettext.ngettext()
.
- final class betty.locale.localizer.LocalizerRepository[source]¶
Bases:
object
Exposes the available localizers.
- __init__(assets: AssetRepository)[source]¶
- async coverage(locale: str | Locale) tuple[int, int] [source]¶
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.