feat: add extractors for Workspace Sidebar and Desktop Icon (#37085)
* feat: add desktop icon extractor * feat: add workspace sidebar extractor * feat: add desktop icon extractor * fix: resolve merge conflict in babel_extractors.csv * docs: fix typo in docstring --------- Co-authored-by: barredterra <14891507+barredterra@users.noreply.github.com>
This commit is contained in:
parent
69e655d08b
commit
06c8217c99
3 changed files with 46 additions and 0 deletions
|
|
@ -1,5 +1,7 @@
|
|||
**/hooks.py,frappe.gettext.extractors.navbar.extract
|
||||
**/doctype/*/*.json,frappe.gettext.extractors.doctype.extract
|
||||
**/desktop_icon/*.json,frappe.gettext.extractors.desktop_icon.extract
|
||||
**/workspace_sidebar/*.json,frappe.gettext.extractors.workspace_sidebar.extract
|
||||
**/workspace/*/*.json,frappe.gettext.extractors.workspace.extract
|
||||
**/web_form/*/*.json,frappe.gettext.extractors.web_form.extract
|
||||
**/onboarding_step/*/*.json,frappe.gettext.extractors.onboarding_step.extract
|
||||
|
|
|
|||
|
18
frappe/gettext/extractors/desktop_icon.py
Normal file
18
frappe/gettext/extractors/desktop_icon.py
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import json
|
||||
|
||||
|
||||
def extract(fileobj, *args, **kwargs):
|
||||
"""Extract messages from Desktop Icon JSON files. To be used by babel extractor.
|
||||
|
||||
:param fileobj: the file-like object the messages should be extracted from
|
||||
:rtype: `iterator`
|
||||
"""
|
||||
data = json.load(fileobj)
|
||||
|
||||
if isinstance(data, list):
|
||||
return
|
||||
|
||||
# Extract the label field (main translatable field for Desktop Icons)
|
||||
label = data.get("label")
|
||||
if label:
|
||||
yield None, "_", label, ["Label of a Desktop Icon"]
|
||||
26
frappe/gettext/extractors/workspace_sidebar.py
Normal file
26
frappe/gettext/extractors/workspace_sidebar.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import json
|
||||
|
||||
|
||||
def extract(fileobj, *args, **kwargs):
|
||||
"""Extract messages from Workspace Sidebar JSON files. To be used by babel extractor.
|
||||
|
||||
:param fileobj: the file-like object the messages should be extracted from
|
||||
:rtype: `iterator`
|
||||
"""
|
||||
data = json.load(fileobj)
|
||||
|
||||
if isinstance(data, list):
|
||||
return
|
||||
|
||||
# Extract the title field (main translatable field for Workspace Sidebar)
|
||||
title = data.get("title")
|
||||
if title:
|
||||
yield None, "_", title, ["Title of a Workspace Sidebar"]
|
||||
|
||||
# Extract labels from items list
|
||||
items = data.get("items", [])
|
||||
if isinstance(items, list):
|
||||
for item in items:
|
||||
label = item.get("label")
|
||||
if label:
|
||||
yield None, "_", label, ["Label of a Workspace Sidebar Item"]
|
||||
Loading…
Add table
Reference in a new issue