betty.locale package - Betty documentation

Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
View this page
Toggle table of contents sidebar

# betty.locale package

## Subpackages

- betty.locale.localizable package
  - Submodules
    - betty.locale.localizable.assertion module
      - `assert_static_translations()`
    - betty.locale.localizable.config module
      - `StaticTranslationsLocalizableConfiguration`
        - `StaticTranslationsLocalizableConfiguration.__init__()`
        - `StaticTranslationsLocalizableConfiguration.dump()`
        - `StaticTranslationsLocalizableConfiguration.load()`
        - `StaticTranslationsLocalizableConfiguration.localize()`
        - `StaticTranslationsLocalizableConfiguration.set()`
        - `StaticTranslationsLocalizableConfiguration.update()`
      - `StaticTranslationsLocalizableConfigurationProperty`
        - `StaticTranslationsLocalizableConfigurationProperty.__init__()`
  - Module contents
    - `Localizable`
      - `Localizable.localize()`
    - `ShorthandStaticTranslations`
    - `StaticTranslations`
    - `StaticTranslationsLocalizable`
      - `StaticTranslationsLocalizable.__init__()`
      - `StaticTranslationsLocalizable.localize()`
    - `call()`
    - `format()`
    - `gettext()`
    - `ngettext()`
    - `npgettext()`
    - `pgettext()`
    - `static()`

## Submodules

- betty.locale.babel module
  - `run_babel()`
- betty.locale.date module
  - `Date`
    - `Date.__init__()`
    - `Date.comparable`
    - `Date.complete`
    - `Date.datey_dump_linked_data()`
    - `Date.day`
    - `Date.dump_linked_data()`
    - `Date.fuzzy`
    - `Date.linked_data_schema()`
    - `Date.month`
    - `Date.parts`
    - `Date.to_range()`
    - `Date.year`
  - `DateRange`
    - `DateRange.__init__()`
    - `DateRange.comparable`
    - `DateRange.datey_dump_linked_data()`
    - `DateRange.dump_linked_data()`
    - `DateRange.end`
    - `DateRange.end_is_boundary`
    - `DateRange.linked_data_schema()`
    - `DateRange.start`
    - `DateRange.start_is_boundary`
  - `IncompleteDateError`
  - `ref_date()`
  - `ref_date_range()`
  - `ref_datey()`
- betty.locale.error module
  - `InvalidLocale`
    - `InvalidLocale.__init__()`
  - `LocaleError`
  - `LocaleNotFound`
    - `LocaleNotFound.__init__()`
- betty.locale.localized module
  - `Localized`
    - `Localized.__init__()`
    - `Localized.dump_linked_data()`
    - `Localized.linked_data_schema()`
    - `Localized.locale`
  - `negotiate_localizeds()`
- betty.locale.localizer module
  - `Localizer`
    - `Localizer.__init__()`
    - `Localizer.format_date()`
    - `Localizer.format_date_range()`
    - `Localizer.format_datetime_datetime()`
    - `Localizer.format_datey()`
    - `Localizer.gettext()`
    - `Localizer.locale`
    - `Localizer.ngettext()`
    - `Localizer.npgettext()`
    - `Localizer.pgettext()`
  - `LocalizerRepository`
    - `LocalizerRepository.__init__()`
    - `LocalizerRepository.coverage()`
    - `LocalizerRepository.get()`
    - `LocalizerRepository.get_negotiated()`
    - `LocalizerRepository.locales`
- betty.locale.translation module
  - `new_dev_translation()`
  - `new_project_translation()`
  - `update_dev_translations()`
  - `update_project_translations()`

## Module contents

Provide the Locale API.

betty.locale.get_data(locale: str | Locale) → Locale

  Get locale metadata.

  Raises:

    - betty.locale.InvalidLocale – Raised if the given identifier is not a valid locale.

    - betty.locale.LocaleNotFoundError – Raised if the given locale cannot be found.

betty.locale.get_display_name(locale: str | Locale, display_locale: str | Locale | None = None) → str | None

  Return a locale’s human-readable display name.

betty.locale.negotiate_locale(preferred_locales: str | Locale | Sequence[str | Locale], available_locales: Sequence[str | Locale]) → Locale | None

  Negotiate the preferred locale from a sequence.

betty.locale.to_babel_identifier(locale: str | Locale) → str

  Convert a locale or locale metadata to a Babel locale identifier.

betty.locale.to_locale(locale: str | Locale) → str

  Ensure that a locale or locale metadata is a locale.