feat: add translatable string extractor for UOM names

This commit is contained in:
barredterra
2024-03-25 23:19:13 +01:00
parent 8fa5707911
commit b49d64de63
4 changed files with 18 additions and 0 deletions

1
babel_extractors.csv Normal file
View File

@@ -0,0 +1 @@
**/setup/setup_wizard/data/uom_data.json,erpnext.gettext.extractors.uom_data.extract
1 **/setup/setup_wizard/data/uom_data.json erpnext.gettext.extractors.uom_data.extract

View File

View File

View File

@@ -0,0 +1,17 @@
import json
def extract(fileobj, *args, **kwargs):
"""
Extract messages from a JSON file with standard UOM data. To be used by the Babel extractor.
:param fileobj: the file-like object the messages should be extracted from
:rtype: `iterator`
"""
uom_list = json.load(fileobj)
if not isinstance(uom_list, list):
return
for uom_data in uom_list:
yield None, "_", uom_data.get("uom_name"), ["Name of a UOM"]