Skip to content

Commit

Permalink
Refactor event types into plugins (#1560)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartfeenstra committed Jul 11, 2024
1 parent 470b933 commit 41187f6
Show file tree
Hide file tree
Showing 21 changed files with 203 additions and 384 deletions.
5 changes: 4 additions & 1 deletion betty/assets/betty.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Betty VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-07-11 21:30+0100\n"
"POT-Creation-Date: 2024-07-12 00:13+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -208,6 +208,9 @@ msgstr ""
msgid "Could not extract {file_path} as a tar (*.tar) file after extracting the outer gzip (*.gz) file."
msgstr ""

msgid "Could not find a plugin \"{plugin_id}\"."
msgstr ""

msgid "Could not find any of the following configuration files in {project_directory_path}: {configuration_file_names}."
msgstr ""

Expand Down
13 changes: 8 additions & 5 deletions betty/assets/locale/de-DE/betty.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Betty VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-07-11 21:30+0100\n"
"POT-Creation-Date: 2024-07-12 00:13+0100\n"
"PO-Revision-Date: 2024-02-08 13:24+0000\n"
"Last-Translator: Bart Feenstra <[email protected]>\n"
"Language: de\n"
Expand Down Expand Up @@ -290,6 +290,9 @@ msgstr ""
"Konnte {file_path} nicht als tar-Datei (*.tar) extrahieren, nachdem die "
"äußere gzip-Datei (*.gz) extrahiert wurde."

msgid "Could not find a plugin \"{plugin_id}\"."
msgstr ""

msgid ""
"Could not find any of the following configuration files in "
"{project_directory_path}: {configuration_file_names}."
Expand Down Expand Up @@ -713,17 +716,17 @@ msgid ""
" at all."
msgstr ""
"Die Entitätsreferenz muss für eine Entität des Typs "
"{expected_entity_type_label} sein, gibt "
"aber stattdessen überhaupt keinen Entitätstyp an."
"{expected_entity_type_label} sein, gibt aber stattdessen überhaupt keinen"
" Entitätstyp an."

msgid ""
"The entity reference must be for an entity of type "
"{expected_entity_type_label}, but instead is for an entity of type "
"{actual_entity_type_label}."
msgstr ""
"Die Entitätsreferenz muss für eine Entität vom Typ "
"{expected_entity_type_label} sein, ist aber"
" stattdessen für eine Entität vom Typ {actual_entity_type_label}"
"{expected_entity_type_label} sein, ist aber stattdessen für eine Entität "
"vom Typ {actual_entity_type_label}"

msgid "The following errors occurred"
msgstr "Die folgenden Fehler sind aufgetreten"
Expand Down
5 changes: 4 additions & 1 deletion betty/assets/locale/fr-FR/betty.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-07-11 21:30+0100\n"
"POT-Creation-Date: 2024-07-12 00:13+0100\n"
"PO-Revision-Date: 2024-02-08 13:24+0000\n"
"Last-Translator: Bart Feenstra <[email protected]>\n"
"Language: fr\n"
Expand Down Expand Up @@ -249,6 +249,9 @@ msgid ""
"outer gzip (*.gz) file."
msgstr ""

msgid "Could not find a plugin \"{plugin_id}\"."
msgstr ""

msgid ""
"Could not find any of the following configuration files in "
"{project_directory_path}: {configuration_file_names}."
Expand Down
12 changes: 7 additions & 5 deletions betty/assets/locale/nl-NL/betty.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-07-11 21:30+0100\n"
"POT-Creation-Date: 2024-07-12 00:13+0100\n"
"PO-Revision-Date: 2024-02-11 15:31+0000\n"
"Last-Translator: Bart Feenstra <[email protected]>\n"
"Language: nl\n"
Expand Down Expand Up @@ -289,6 +289,9 @@ msgstr ""
"Kan het bestand {file_path} niet als een tar-bestand (*.tar) uitpakken, "
"na het uitpakken van het buitenste gzip-bestand (*.gz)."

msgid "Could not find a plugin \"{plugin_id}\"."
msgstr "Kan de plugin \"{plugin_id}\" niet vinden."

msgid ""
"Could not find any of the following configuration files in "
"{project_directory_path}: {configuration_file_names}."
Expand Down Expand Up @@ -720,17 +723,16 @@ msgid ""
" at all."
msgstr ""
"De entiteitsverwijzing moet verwijzen naar een entiteit van het type "
"{expected_entity_type_label}, maar geen "
"entiteitstype is ingesteld."
"{expected_entity_type_label}, maar geen entiteitstype is ingesteld."

msgid ""
"The entity reference must be for an entity of type "
"{expected_entity_type_label}, but instead is for an entity of type "
"{actual_entity_type_label}."
msgstr ""
"De entiteitsverwijzing moet verwijzen naar een entiteit van het type "
"{expected_entity_type_label}, maar verwijst"
" echter naar een entiteit van het type {actual_entity_type_label}"
"{expected_entity_type_label}, maar verwijst echter naar een entiteit van "
"het type {actual_entity_type_label}"

msgid "The following errors occurred"
msgstr "De volgende problemen zijn voorgekomen"
Expand Down
5 changes: 4 additions & 1 deletion betty/assets/locale/uk/betty.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Betty VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-07-11 21:30+0100\n"
"POT-Creation-Date: 2024-07-12 00:13+0100\n"
"PO-Revision-Date: 2024-02-08 13:08+0000\n"
"Last-Translator: Rainer Thieringer <[email protected]>\n"
"Language: uk\n"
Expand Down Expand Up @@ -249,6 +249,9 @@ msgid ""
"outer gzip (*.gz) file."
msgstr ""

msgid "Could not find a plugin \"{plugin_id}\"."
msgstr ""

msgid ""
"Could not find any of the following configuration files in "
"{project_directory_path}: {configuration_file_names}."
Expand Down
4 changes: 2 additions & 2 deletions betty/deriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ async def derive(self) -> None:
"Updated {updated_derivations} {event_type} events based on existing information."
).format(
updated_derivations=str(updated_derivations),
event_type=derivable_event_type.label().localize(
event_type=derivable_event_type.plugin_label().localize(
self._localizer
),
)
Expand All @@ -84,7 +84,7 @@ async def derive(self) -> None:
"Created {created_derivations} additional {event_type} events based on existing information."
).format(
created_derivations=str(created_derivations),
event_type=derivable_event_type.label().localize(
event_type=derivable_event_type.plugin_label().localize(
self._localizer
),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{%- macro person_label(person) -%}
{% include 'entity/label--person.html.j2' %}
{%- endmacro -%}
{%- set formatted_event = event.event_type.label() | localize -%}
{%- set formatted_event = event.event_type.plugin_label() | localize -%}
{%- if event is not has_generated_entity_id and not embedded -%}
{% set formatted_event = ('<a href="' + event | url + '">' + formatted_event + '</a>') | safe %}
{%- endif -%}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
{%- if formatted_start is defined or formatted_end is defined -%}
<dl>
{%- if formatted_start is defined -%}
<div><dt>{{ start_of_life_event.event_type.label() | localize }}</dt><dd>{{ formatted_start }}</dd></div>
<div><dt>{{ start_of_life_event.event_type.plugin_label() | localize }}</dt><dd>{{ formatted_start }}</dd></div>
{%- endif -%}
{%- if formatted_end is defined -%}
<div><dt>{{ end_of_life_event.event_type.label() | localize }}</dt><dd>{{ formatted_end }}</dd></div>
<div><dt>{{ end_of_life_event.event_type.plugin_label() | localize }}</dt><dd>{{ formatted_end }}</dd></div>
{%- endif -%}
</dl>
{%- endif -%}
Expand Down
7 changes: 2 additions & 5 deletions betty/extension/deriver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from betty.extension.privatizer import Privatizer
from betty.load import PostLoader
from betty.locale.localizable import _, Localizable
from betty.model import event_type
from betty.model.event_type import DerivableEventType
from betty.project.extension import Extension
from typing import TYPE_CHECKING
Expand Down Expand Up @@ -40,11 +41,7 @@ async def post_load(self) -> None:
deriver = DeriverApi(
self.project.ancestry,
self.project.configuration.lifetime_threshold,
{
event_type
for event_type in self.project.event_types
if issubclass(event_type, DerivableEventType)
},
set(await event_type.ENTITY_TYPE_REPOSITORY.select(DerivableEventType)),
localizer=self.project.app.localizer,
)
await deriver.derive()
Expand Down
6 changes: 3 additions & 3 deletions betty/extension/gramps/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@

from typing_extensions import override

from betty.config import Configuration
from betty.config.collections.sequence import ConfigurationSequence
from betty.serde.dump import minimize, Dump, VoidableDump
from betty.assertion import (
RequiredField,
OptionalField,
assert_record,
assert_path,
assert_setattr,
)
from betty.config import Configuration
from betty.config.collections.sequence import ConfigurationSequence
from betty.serde.dump import minimize, Dump, VoidableDump


class FamilyTreeConfiguration(Configuration):
Expand Down
4 changes: 3 additions & 1 deletion betty/gramps/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,9 @@ def _load_event(self, element: ElementTree.Element) -> None:
).format(
event_id=event_id,
gramps_event_type=gramps_type,
betty_event_type=event_type.label().localize(self._localizer),
betty_event_type=event_type.plugin_label().localize(
self._localizer
),
)
)

Expand Down
4 changes: 2 additions & 2 deletions betty/model/ancestry.py
Original file line number Diff line number Diff line change
Expand Up @@ -1643,7 +1643,7 @@ def __init__(
@property
def label(self) -> Localizable:
format_kwargs: dict[str, str | Localizable] = {
"event_type": self._event_type.label(),
"event_type": self._event_type.plugin_label(),
}
subjects = [
presence.person
Expand Down Expand Up @@ -1721,7 +1721,7 @@ async def dump_linked_data(self, project: Project) -> DictDump[Dump]:
dump = await super().dump_linked_data(project)
dump_context(dump, presences="performer")
dump["@type"] = "https://schema.org/Event"
dump["type"] = self.event_type.name()
dump["type"] = self.event_type.plugin_id()
dump["eventAttendanceMode"] = "https://schema.org/OfflineEventAttendanceMode"
dump["eventStatus"] = "https://schema.org/EventScheduled"
dump["presences"] = presences = []
Expand Down
Loading

0 comments on commit 41187f6

Please sign in to comment.