seitime-frappe/frappe/gettext/extractors/workspace_sidebar.py
Exequiel Arona 06c8217c99
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>
2026-02-16 15:12:01 +00:00

26 lines
704 B
Python

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"]