From 4a54fafa19b57154ee595093e9e6e342004941ad Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Sun, 29 Oct 2023 16:19:52 +0100 Subject: [PATCH] feat: add extractor for Onboarding Step --- frappe/gettext/extractors/onboarding_step.py | 32 ++++++++++++++++++++ frappe/gettext/translate.py | 1 + 2 files changed, 33 insertions(+) create mode 100644 frappe/gettext/extractors/onboarding_step.py diff --git a/frappe/gettext/extractors/onboarding_step.py b/frappe/gettext/extractors/onboarding_step.py new file mode 100644 index 0000000000..1188b5399e --- /dev/null +++ b/frappe/gettext/extractors/onboarding_step.py @@ -0,0 +1,32 @@ +import json + + +def extract(fileobj, *args, **kwargs): + """ + Extract messages from Onboarding Step JSON files. + + :param fileobj: the file-like object the messages should be extracted from + :rtype: `iterator` + """ + data = json.load(fileobj) + + if isinstance(data, list): + return + + if data.get("doctype") != "Onboarding Step": + return + + step_title = data.get("title") + + yield None, "_", step_title, ["Title of an Onboarding Step"] + + if action_label := data.get("action_label"): + yield None, "_", action_label, [f"Label of an action in the Onboarding Step '{step_title}'"] + + if description := data.get("description"): + yield None, "_", description, [f"Description of the Onboarding Step '{step_title}'"] + + if report_description := data.get("report_description"): + yield None, "_", report_description, [ + f"Description of a report in the Onboarding Step '{step_title}'" + ] diff --git a/frappe/gettext/translate.py b/frappe/gettext/translate.py index 354bbea927..2c6ac3e2a0 100644 --- a/frappe/gettext/translate.py +++ b/frappe/gettext/translate.py @@ -125,6 +125,7 @@ def generate_pot(target_app: str | None = None): ("**.html", "frappe.gettext.extractors.jinja2.extract"), ("hooks.py", "frappe.gettext.extractors.navbar.extract"), ("**/report/*/*.json", "frappe.gettext.extractors.report.extract"), + ("**/onboarding_step/*/*.json", "frappe.gettext.extractors.onboarding_step.extract"), ] for app in apps: