--- a/svghmi/gen_index_xhtml.ysl2 Tue Jan 05 01:23:45 2021 +0100
+++ b/svghmi/gen_index_xhtml.ysl2 Fri Jan 15 10:11:05 2021 +0100
@@ -51,6 +51,8 @@
include widgets_common.ysl2
--- a/svghmi/inline_svg.ysl2 Tue Jan 05 01:23:45 2021 +0100
+++ b/svghmi/inline_svg.ysl2 Fri Jan 15 10:11:05 2021 +0100
@@ -37,6 +37,11 @@
error > All units must be set to "px" in Inkscape's document properties
+// remove i18n markers, so that defs_by_labels can find text elements +svgtmpl "svg:text/@inkscape:label[starts-with(., '_')]", mode="inline_svg" { + attrib "{name()}" > «substring(., 2)» // svg:use (inkscape's clones) inside a widgets are
--- a/svghmi/svghmi.py Tue Jan 05 01:23:45 2021 +0100
+++ b/svghmi/svghmi.py Fri Jan 15 10:11:05 2021 +0100
@@ -30,6 +30,7 @@
from editors.ConfTreeNodeEditor import ConfTreeNodeEditor
from XSLTransform import XSLTransform
+from svghmi.i18n import POTWriter, POReader @@ -460,9 +461,9 @@
"method": "_StartInkscape"
- # TODO : Launch POEdit button
- # PO -> SVG layers button
+ # TODO : Launch POEdit button for new languqge (opens POT) + # TODO : Launch POEdit button for existing languqge (opens one of existing PO) # - can drag'n'drop variabes to Inkscape
@@ -474,6 +475,10 @@
project_path = self.CTNPath()
return os.path.join(project_path, "svghmi.svg")
+ def _getPOTpath(self, project_path=None): + if project_path is None: + project_path = self.CTNPath() + return os.path.join(project_path, "messages.pot") def OnCTNSave(self, from_project_path=None):
if from_project_path is not None:
@@ -513,6 +518,19 @@
res = [hmi_tree_root.etree(add_hash=True)]
+ def GetTranslations(self, _context, msgs): + # XXX scan existing PO files + return None # XXX return all langs from all POs def CTNGenerate_C(self, buildpath, locations):
location_str = "_".join(map(str, self.GetCurrentLocation()))
@@ -532,7 +550,8 @@
# TODO : move to __init__
transform = XSLTransform(os.path.join(ScriptDirectory, "gen_index_xhtml.xslt"),
[("GetSVGGeometry", lambda *_ignored:self.GetSVGGeometry()),
- ("GetHMITree", lambda *_ignored:self.GetHMITree())])
+ ("GetHMITree", lambda *_ignored:self.GetHMITree()), + ("GetTranslations", self.GetTranslations)]) # load svg as a DOM with Etree
@@ -649,6 +668,28 @@
+ def _StartPOEdit(self, POFile): + if not self.GetCTRoot().CheckProjectPathPerm(): + dialog = wx.MessageDialog(self.GetCTRoot().AppFrame, + _("You don't have write permissions.\nOpen POEdit anyway ?"), + wx.YES_NO | wx.ICON_QUESTION) + open_poedit = dialog.ShowModal() == wx.ID_YES + def _EditTranslation(self): + """ Select a specific translation and edit it with POEdit """ + def _EditNewTranslation(self): + """ Start POEdit with untouched empty catalog """ + POFile = self._getPOTpath() + self._StartPOEdit(POFile) def CTNGlobalInstances(self):
# view_name = self.BaseParams.getName()
# return [ (view_name + "_" + name, iec_type, "") for name, iec_type in SPECIAL_NODES]