feat: add extractor for Onboarding Step

This commit is contained in:
barredterra 2023-10-29 16:19:52 +01:00
parent c38ff0e83f
commit 4a54fafa19
2 changed files with 33 additions and 0 deletions

View file

@ -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}'"
]

View file

@ -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: