--- a/svghmi/i18n.py Thu Jan 21 11:08:04 2021 +0100
+++ b/svghmi/i18n.py Fri Jan 22 08:43:24 2021 +0100
@@ -7,6 +7,7 @@
# See COPYING file for copyrights details.
from __future__ import absolute_import
@@ -44,7 +45,7 @@
- "\n".join([line.text.encode("utf-8") for line in msg]),
+ "\n".join([line.text for line in msg]), msg.get("label"), msg.get("id")))
@@ -85,16 +86,17 @@
errcallback(_('{}: Missing translation for "{}" (label:{}, id:{})\n').format(lang,msgid,label,svgid))
- translated_message.append(msg)
+ translated_message.append(msgid) + translated_message.append(msg) translated_messages.append((msgid,translated_message))
for lang,translation in translations:
for msgid, msg in translation.iteritems():
- errcallback(_('{}: Unused translation "{}":"{}"\n').format(lang,msgid,msg))
+ errcallback(_('{}: Unused translation "{}":"{}"\n').format(lang,msgid,msg)) if broken or lang in broken_lang:
errcallback(_('Translation for {} is outdated, please edit {}.po, click "Catalog -> Update from POT File..." and select messages.pot.\n').format(lang,lang))
@@ -103,7 +105,22 @@
def TranslationToEtree(langs,translated_messages):
+ langsroot = etree.Element("langs") + langel = etree.SubElement(langsroot, "lang") + msgsroot = etree.Element("translations") + for msgid, msgs in translated_messages: + msgidel = etree.SubElement(msgsroot, "msgid") + msgel = etree.SubElement(msgidel, "msg") + return [langsroot,msgsroot] @@ -180,8 +197,8 @@
def ImportMessages(self, msgs):
+ for msg, label, svgid in msgs: + self.addentry(msg.encode("utf-8"), label, svgid) def addentry(self, msg, label, svgid):
@@ -227,8 +244,8 @@
def add(self, msgid, msgstr, fuzzy):
"Add a non-fuzzy translation to the dictionary."
- if not fuzzy and msgstr:
- self.__messages[msgid] = msgstr
+ if not fuzzy and msgstr and msgid: + self.__messages[msgid.decode('utf-8')] = msgstr.decode('utf-8')