# HG changeset patch
# User Edouard Tisserant
# Date 1611311437 -3600
# Node ID 6da94ec043251e31469cbb7f059a66237839e1d9
# Parent 77cfbf1aacf0320f8daf33072b33d98d715e1b9f
SVGHMI: i18n: finished passing back translated messaged to xslt proc, finished template to generate corresponding javascript literals.
diff -r 77cfbf1aacf0 -r 6da94ec04325 svghmi/gen_index_xhtml.xslt
--- a/svghmi/gen_index_xhtml.xslt Fri Jan 22 08:43:24 2021 +0100
+++ b/svghmi/gen_index_xhtml.xslt Fri Jan 22 11:30:37 2021 +0100
@@ -264,7 +264,9 @@
"
-
+ [
+
+ ]
@@ -959,23 +961,43 @@
- var translations = {
-
-
- "
-
- ":{
-
- }
+ var langs = [
+
+
+
+ ,
+
+
+ ];
+
+ var translations = [
+
+
+
+ ["
+
+ ",[
+
+ "
+
+
+
+ \n
+
+
+ "
+
+ ,
+
+
+ ]]
,
- };
-
-
+ ]
diff -r 77cfbf1aacf0 -r 6da94ec04325 svghmi/i18n.py
--- a/svghmi/i18n.py Fri Jan 22 08:43:24 2021 +0100
+++ b/svghmi/i18n.py Fri Jan 22 11:30:37 2021 +0100
@@ -106,20 +106,23 @@
def TranslationToEtree(langs,translated_messages):
- langsroot = etree.Element("langs")
+ result = etree.Element("translations")
+
+ langsroot = etree.SubElement(result, "langs")
for lang in langs:
langel = etree.SubElement(langsroot, "lang")
langel.text = lang
- msgsroot = etree.Element("translations")
+ msgsroot = etree.SubElement(result, "messages")
for msgid, msgs in translated_messages:
msgidel = etree.SubElement(msgsroot, "msgid")
- msgidel.text = msgid
for msg in msgs:
msgel = etree.SubElement(msgidel, "msg")
- msgel.text = msg
-
- return [langsroot,msgsroot]
+ for line in msg.split("\n"):
+ lineel = etree.SubElement(msgel, "line")
+ lineel.text = escape(line.encode("utf-8")).decode("utf-8")
+
+ return result
diff -r 77cfbf1aacf0 -r 6da94ec04325 svghmi/i18n.ysl2
--- a/svghmi/i18n.ysl2 Fri Jan 22 08:43:24 2021 +0100
+++ b/svghmi/i18n.ysl2 Fri Jan 22 11:30:37 2021 +0100
@@ -20,13 +20,28 @@
emit "preamble:i18n" {
const "translations", "ns:GetTranslations($translatable_strings)";
- | var translations = {
- foreach "$translations/*" {
- | "«local-name()»":{
- /* TODO */
- | }`if "position()!=last()" > ,`
+ > var langs = [
+ foreach "$translations/langs/lang" {
+ value ".";
+ if "position()!=last()" > ,
}
- | };
- |
-
+ | ];
+ | var translations = [
+ foreach "$translatable_texts" {
+ const "n","position()";
+ > ["«@id»",[
+ foreach "$translations/messages/msgid[$n]/msg" {
+ > "
+ foreach "line" {
+ value ".";
+ if "position()!=last()" > \\\\n
+ }
+ > "
+ if "position()!=last()" > ,
+ }
+ > ]]
+ if "position()!=last()" > ,
+ > \n
+ }
+ | ]
}