From 47650d75ff899154dcea17d46bfa17e8b3bee5f4 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 15 Apr 2025 17:43:52 +0000 Subject: [PATCH] fix: translatable string extraction (#32142) (#32148) Co-authored-by: Raffael Meyer <14891507+barredterra@users.noreply.github.com> --- frappe/gettext/extractors/navbar.py | 2 +- frappe/gettext/extractors/workspace.py | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/frappe/gettext/extractors/navbar.py b/frappe/gettext/extractors/navbar.py index 924d3a4403..20e0cadc84 100644 --- a/frappe/gettext/extractors/navbar.py +++ b/frappe/gettext/extractors/navbar.py @@ -32,7 +32,7 @@ def extract(fileobj, *args, **kwargs): standard_help_items = module.standard_help_items for help_item in standard_help_items: if label := help_item.get("item_label"): - item_type = nav_item.get("item_type") + item_type = help_item.get("item_type") yield ( None, "_", diff --git a/frappe/gettext/extractors/workspace.py b/frappe/gettext/extractors/workspace.py index a9be1dc17c..944bc52941 100644 --- a/frappe/gettext/extractors/workspace.py +++ b/frappe/gettext/extractors/workspace.py @@ -21,10 +21,12 @@ def extract(fileobj, *args, **kwargs): yield from ( (None, "_", chart.get("label"), [f"Label of a chart in the {workspace_name} Workspace"]) for chart in data.get("charts", []) + if chart.get("label") ) yield from ( (None, "_", number_card.get("label"), [f"Label of a number card in the {workspace_name} Workspace"]) for number_card in data.get("number_cards", []) + if number_card.get("label") ) yield from ( ( @@ -34,6 +36,7 @@ def extract(fileobj, *args, **kwargs): [f"Label of a {link.get('type')} in the {workspace_name} Workspace"], ) for link in data.get("links", []) + if link.get("label") ) yield from ( ( @@ -43,6 +46,7 @@ def extract(fileobj, *args, **kwargs): [f"Description of a {link.get('type')} in the {workspace_name} Workspace"], ) for link in data.get("links", []) + if link.get("description") ) yield from ( ( @@ -52,6 +56,7 @@ def extract(fileobj, *args, **kwargs): [f"Label of a shortcut in the {workspace_name} Workspace"], ) for shortcut in data.get("shortcuts", []) + if shortcut.get("label") ) yield from ( ( @@ -61,15 +66,17 @@ def extract(fileobj, *args, **kwargs): [f"Count format of shortcut in the {workspace_name} Workspace"], ) for shortcut in data.get("shortcuts", []) + if shortcut.get("format") ) content = json.loads(data.get("content", "[]")) for item in content: item_type = item.get("type") if item_type in ("header", "paragraph"): - yield ( - None, - "_", - item.get("data", {}).get("text"), - [f"{item_type.title()} text in the {workspace_name} Workspace"], - ) + if text := item.get("data", {}).get("text"): + yield ( + None, + "_", + text, + [f"{item_type.title()} text in the {workspace_name} Workspace"], + )