summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaun McCance <shaunm@gnome.org>2014-03-17 14:40:42 -0400
committerShaun McCance <shaunm@gnome.org>2014-03-17 14:40:42 -0400
commitd75f68cbc58075b57aee53d57b9156655a2fc99a (patch)
tree21759fc6c0df51ea9135d31c2750c307c8010617
parent6f1761d86b4749a65607d4b4af622f6771e1f330 (diff)
downloaditstool-d75f68cbc58075b57aee53d57b9156655a2fc99a.tar.gz
Fix UTF-8 handling for translated attributes
-rwxr-xr-xitstool.in2
-rw-r--r--tests/IT-attributes-2.ll.po21
-rw-r--r--tests/IT-attributes-2.ll.xml10
-rw-r--r--tests/IT-attributes-2.pot21
-rw-r--r--tests/IT-attributes-2.xml10
-rw-r--r--tests/run_tests.py3
6 files changed, 66 insertions, 1 deletions
diff --git a/itstool.in b/itstool.in
index 96fb913..d0e76a1 100755
--- a/itstool.in
+++ b/itstool.in
@@ -966,7 +966,7 @@ class Document (object):
for attr in trans_attrs:
newcontent = translations.ugettext(attr.get_content())
if newcontent:
- newnode.setProp(attr.name, translations.ugettext(attr.get_content()))
+ newnode.setProp(attr.name, newcontent.encode('utf-8'))
def get_translated (self, node, translations, strict=False, lang=None):
msg = self._msgs.get_message_by_node(node)
diff --git a/tests/IT-attributes-2.ll.po b/tests/IT-attributes-2.ll.po
new file mode 100644
index 0000000..fefd42d
--- /dev/null
+++ b/tests/IT-attributes-2.ll.po
@@ -0,0 +1,21 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"POT-Creation-Date: 2012-05-04 11:46-0400\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#. (itstool) path: page/code@title
+#: tests/IT-attributes-2.xml:9
+msgid "one"
+msgstr "öñé"
+
+#. (itstool) path: code/span@title
+#: tests/IT-attributes-2.xml:9
+msgid "two"
+msgstr "ŧwô"
diff --git a/tests/IT-attributes-2.ll.xml b/tests/IT-attributes-2.ll.xml
new file mode 100644
index 0000000..2a1044d
--- /dev/null
+++ b/tests/IT-attributes-2.ll.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<page>
+ <info>
+ <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0">
+ <its:translateRule selector="//code" translate="no"/>
+ <its:translateRule selector="//@title" translate="yes"/>
+ </its:rules>
+ </info>
+ <code title="öñé">Not translated <span title="ŧwô"/></code>
+</page>
diff --git a/tests/IT-attributes-2.pot b/tests/IT-attributes-2.pot
new file mode 100644
index 0000000..e989b08
--- /dev/null
+++ b/tests/IT-attributes-2.pot
@@ -0,0 +1,21 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"POT-Creation-Date: 2012-05-04 11:46-0400\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#. (itstool) path: page/code@title
+#: tests/IT-attributes-2.xml:9
+msgid "one"
+msgstr ""
+
+#. (itstool) path: code/span@title
+#: tests/IT-attributes-2.xml:9
+msgid "two"
+msgstr ""
+
diff --git a/tests/IT-attributes-2.xml b/tests/IT-attributes-2.xml
new file mode 100644
index 0000000..3233132
--- /dev/null
+++ b/tests/IT-attributes-2.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<page>
+ <info>
+ <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0">
+ <its:translateRule selector="//code" translate="no"/>
+ <its:translateRule selector="//@title" translate="yes"/>
+ </its:rules>
+ </info>
+ <code title="one">Not translated <span title="two"/></code>
+</page>
diff --git a/tests/run_tests.py b/tests/run_tests.py
index 6939ff6..af62d76 100644
--- a/tests/run_tests.py
+++ b/tests/run_tests.py
@@ -311,6 +311,9 @@ class ItstoolTests(unittest.TestCase):
def test_IT_attributes_1(self):
self._test_translation_process('IT-attributes-1.xml')
+ def test_IT_attributes_2(self):
+ self._test_translation_process('IT-attributes-2.xml')
+
def test_IT_context_1(self):
self._test_translation_process('IT-context-1.xml')