diff --git a/frappe/gettext/extractors/module_onboarding.py b/frappe/gettext/extractors/module_onboarding.py new file mode 100644 index 0000000000..3468501074 --- /dev/null +++ b/frappe/gettext/extractors/module_onboarding.py @@ -0,0 +1,30 @@ +import json + + +def extract(fileobj, *args, **kwargs): + """ + Extract messages from Module Onboarding 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") != "Module Onboarding": + return + + onboarding_name = data.get("name") + + if title := data.get("title"): + yield None, "_", title, [f"Title of the Module Onboarding '{onboarding_name}'"] + + if subtitle := data.get("subtitle"): + yield None, "_", subtitle, [f"Subtitle of the Module Onboarding '{onboarding_name}'"] + + if success_message := data.get("success_message"): + yield None, "_", success_message, [ + f"Success message of the Module Onboarding '{onboarding_name}'" + ] diff --git a/frappe/gettext/translate.py b/frappe/gettext/translate.py index 2c6ac3e2a0..476a4c4e8a 100644 --- a/frappe/gettext/translate.py +++ b/frappe/gettext/translate.py @@ -126,6 +126,7 @@ def generate_pot(target_app: str | None = None): ("hooks.py", "frappe.gettext.extractors.navbar.extract"), ("**/report/*/*.json", "frappe.gettext.extractors.report.extract"), ("**/onboarding_step/*/*.json", "frappe.gettext.extractors.onboarding_step.extract"), + ("**/module_onboarding/*/*.json", "frappe.gettext.extractors.module_onboarding.extract"), ] for app in apps: