betty.locale module¶
Provide the Locale API.
- class betty.locale.Date(year=None, month=None, day=None, fuzzy=False)[source]¶
Bases:
LinkedDataDumpable- property comparable : bool¶
- property complete : bool¶
- async datey_dump_linked_data(dump, start_schema_org, end_schema_org)[source]¶
- day : --is-rst--:py:class:`int` | :py:obj:`None`¶
- async dump_linked_data(app, schemas_org=None)[source]¶
Dump this instance to JSON-LD.
- Parameters:¶
- Return type:¶
dict[str,typing.Union[bool,int,float,str,None,typing.Sequence[typing.Union[bool,int,float,str,None,typing.Sequence[Dump],typing.Mapping[str, Dump]]],typing.Mapping[str,typing.Union[bool,int,float,str,None,typing.Sequence[Dump],typing.Mapping[str, Dump]]]]]
- fuzzy : --is-rst--:py:class:`bool`¶
- async classmethod linked_data_schema(app)[source]¶
Define the JSON Schema for self.dump_linked_data().
- Parameters:¶
- app¶
- Return type:¶
dict[str,typing.Union[bool,int,float,str,None,typing.Sequence[typing.Union[bool,int,float,str,None,typing.Sequence[Dump],typing.Mapping[str, Dump]]],typing.Mapping[str,typing.Union[bool,int,float,str,None,typing.Sequence[Dump],typing.Mapping[str, Dump]]]]]
- month : --is-rst--:py:class:`int` | :py:obj:`None`¶
- property parts : tuple[int | None, int | None, int | None]¶
- year : --is-rst--:py:class:`int` | :py:obj:`None`¶
- class betty.locale.DateRange(start=None, end=None, start_is_boundary=False, end_is_boundary=False)[source]¶
Bases:
LinkedDataDumpable- property comparable : bool¶
- async datey_dump_linked_data(dump, start_schema_org, end_schema_org)[source]¶
- async dump_linked_data(app, start_schema_org=None, end_schema_org=None)[source]¶
Dump this instance to JSON-LD.
- Parameters:¶
- Return type:¶
dict[str,typing.Union[bool,int,float,str,None,typing.Sequence[typing.Union[bool,int,float,str,None,typing.Sequence[Dump],typing.Mapping[str, Dump]]],typing.Mapping[str,typing.Union[bool,int,float,str,None,typing.Sequence[Dump],typing.Mapping[str, Dump]]]]]
- end : --is-rst--:py:class:`betty.locale.Date` | :py:obj:`None`¶
- end_is_boundary : --is-rst--:py:class:`bool`¶
- async classmethod linked_data_schema(app)[source]¶
Define the JSON Schema for self.dump_linked_data().
- Parameters:¶
- app¶
- Return type:¶
dict[str,typing.Union[bool,int,float,str,None,typing.Sequence[typing.Union[bool,int,float,str,None,typing.Sequence[Dump],typing.Mapping[str, Dump]]],typing.Mapping[str,typing.Union[bool,int,float,str,None,typing.Sequence[Dump],typing.Mapping[str, Dump]]]]]
- start : --is-rst--:py:class:`betty.locale.Date` | :py:obj:`None`¶
- start_is_boundary : --is-rst--:py:class:`bool`¶
- class betty.locale.Localized(*args, locale=None, **kwargs)[source]¶
Bases:
LinkedDataDumpable- async dump_linked_data(app)[source]¶
Dump this instance to JSON-LD.
- Parameters:¶
- app¶
- Return type:¶
dict[str,typing.Union[bool,int,float,str,None,typing.Sequence[typing.Union[bool,int,float,str,None,typing.Sequence[Dump],typing.Mapping[str, Dump]]],typing.Mapping[str,typing.Union[bool,int,float,str,None,typing.Sequence[Dump],typing.Mapping[str, Dump]]]]]
- async classmethod linked_data_schema(app)[source]¶
Define the JSON Schema for self.dump_linked_data().
- Parameters:¶
- app¶
- Return type:¶
dict[str,typing.Union[bool,int,float,str,None,typing.Sequence[typing.Union[bool,int,float,str,None,typing.Sequence[Dump],typing.Mapping[str, Dump]]],typing.Mapping[str,typing.Union[bool,int,float,str,None,typing.Sequence[Dump],typing.Mapping[str, Dump]]]]]
- locale : --is-rst--:py:class:`str` | :py:obj:`None`¶
- class betty.locale.Localizer(locale, translations)[source]¶
Bases:
object- property locale : str¶
- ngettext(message_singular, message_plural, n)[source]¶
- npgettext(context, message_singular, message_plural, n)[source]¶
- class betty.locale.LocalizerRepository(assets)[source]¶
Bases:
object- property locales : Iterator[str]¶
- class betty.locale.Str[source]¶
Bases:
Localizable- classmethod ngettext(message_singular, message_plural, n, **format_kwargs)[source]¶
- classmethod npgettext(context, message_singular, message_plural, n, **format_kwargs)[source]¶
- classmethod pgettext(context, message, **format_kwargs)[source]¶
- betty.locale.get_display_name(locale, display_locale=None)[source]¶
Return a locale’s human-readable display name.
- betty.locale.negotiate_locale(preferred_locales, available_locales)[source]¶
Negotiate the preferred locale from a sequence.
- betty.locale.negotiate_localizeds(preferred_locales, localizeds)[source]¶
Negotiate the preferred localized value from a sequence.
- Parameters:¶
- Return type:¶
betty.locale.Localized|None
- async betty.locale.ref_date(root_schema, app)[source]¶
Reference the Date schema.
- Parameters:¶
- Return type:¶
dict[str,typing.Union[bool,int,float,str,None,typing.Sequence[typing.Union[bool,int,float,str,None,typing.Sequence[Dump],typing.Mapping[str, Dump]]],typing.Mapping[str,typing.Union[bool,int,float,str,None,typing.Sequence[Dump],typing.Mapping[str, Dump]]]]]
- async betty.locale.ref_date_range(root_schema, app)[source]¶
Reference the DateRange schema.
- Parameters:¶
- Return type:¶
dict[str,typing.Union[bool,int,float,str,None,typing.Sequence[typing.Union[bool,int,float,str,None,typing.Sequence[Dump],typing.Mapping[str, Dump]]],typing.Mapping[str,typing.Union[bool,int,float,str,None,typing.Sequence[Dump],typing.Mapping[str, Dump]]]]]
- async betty.locale.ref_datey(root_schema, app)[source]¶
Reference the Datey schema.
- Parameters:¶
- Return type:¶
dict[str,typing.Union[bool,int,float,str,None,typing.Sequence[typing.Union[bool,int,float,str,None,typing.Sequence[Dump],typing.Mapping[str, Dump]]],typing.Mapping[str,typing.Union[bool,int,float,str,None,typing.Sequence[Dump],typing.Mapping[str, Dump]]]]]
- betty.locale.to_babel_identifier(locale)[source]¶
Convert a locale or locale metadata to a Babel locale identifier.
- async betty.locale.update_translations(_output_assets_directory_path=PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/betty/envs/0.3.5/lib/python3.12/site-packages/betty/assets'))[source]¶
Update all existing translations based on changes in translatable strings.