summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2011-05-31 22:05:00 +0200
committerClaude Paroz <claude@2xlibre.net>2011-05-31 22:05:00 +0200
commit2ffe1d30ea1d5925a75955bc9b88c3d4c14b7b46 (patch)
treea638edb862d9da2c605bd89a7354d22f35cfda50
parentd3177444660bac67265ba9cf17d586fd1b0b2907 (diff)
downloaditstool-2ffe1d30ea1d5925a75955bc9b88c3d4c14b7b46.tar.gz
Add tests for the Translate* series
-rw-r--r--tests/Translate2.ll.po15
-rw-r--r--tests/Translate2.ll.xml10
-rw-r--r--tests/Translate2.pot15
-rw-r--r--tests/Translate3.ll.po19
-rw-r--r--tests/Translate3.ll.xml10
-rw-r--r--tests/Translate4.ll.po19
-rw-r--r--tests/Translate4.ll.xml10
-rw-r--r--tests/Translate5.ll.po19
-rw-r--r--tests/Translate5.ll.xml19
-rw-r--r--tests/Translate5.pot19
-rw-r--r--tests/Translate6.ll.po31
-rw-r--r--tests/Translate6.ll.xml19
-rw-r--r--tests/Translate7.ll.po19
-rw-r--r--tests/Translate7.ll.xml29
-rw-r--r--tests/Translate7.pot19
-rw-r--r--tests/run_tests.py41
16 files changed, 307 insertions, 6 deletions
diff --git a/tests/Translate2.ll.po b/tests/Translate2.ll.po
new file mode 100644
index 0000000..9078ab4
--- /dev/null
+++ b/tests/Translate2.ll.po
@@ -0,0 +1,15 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"POT-Creation-Date: 2011-05-31 21:15+0200\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"
+
+#: tests/Translate2.xml:8(body/par)
+msgid "This is the first paragraph. It has some <_:code-1/>."
+msgstr "C'est le premier paragraphe. Il contient du texte <_:code-1/>."
+
diff --git a/tests/Translate2.ll.xml b/tests/Translate2.ll.xml
new file mode 100644
index 0000000..2092f86
--- /dev/null
+++ b/tests/Translate2.ll.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<myDoc>
+ <head>
+ <its:rules xmlns:its="http://www.w3.org/2005/11/its" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.0" xlink:type="simple" xlink:href="Translate2_LinkedRules.xml"/>
+ </head>
+ <body>
+ <par id="100" title="Text">C'est le premier paragraphe. Il contient du texte <code>un-translatable code</code>.</par>
+ </body>
+</myDoc>
+<!-- timestamp $Id: Translate2.xml,v 1.4 2007/02/02 16:55:05 srahtz3 Exp $ -->
diff --git a/tests/Translate2.pot b/tests/Translate2.pot
new file mode 100644
index 0000000..85aac4f
--- /dev/null
+++ b/tests/Translate2.pot
@@ -0,0 +1,15 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"POT-Creation-Date: 2011-05-31 21:17+0200\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"
+
+#: tests/Translate2.xml:8(body/par)
+msgid "This is the first paragraph. It has some <_:code-1/>."
+msgstr ""
+
diff --git a/tests/Translate3.ll.po b/tests/Translate3.ll.po
new file mode 100644
index 0000000..8348ee5
--- /dev/null
+++ b/tests/Translate3.ll.po
@@ -0,0 +1,19 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"POT-Creation-Date: 2011-05-31 21:23+0200\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"
+
+#: tests/Translate3.xml:6(head/title)
+msgid "The Life of a Simple Man"
+msgstr "La vie d'un simple homme"
+
+#: tests/Translate3.xml:9(body/p)
+msgid "Everything started when Zebulon discovered that he had a <_:span-1/> who was a serious baseball <_:span-2/>."
+msgstr "Tout commença alors que Zebulon découvrit qu'il avait un <_:span-1/> qui était un <_:span-2/> sérieux de baseball."
+
diff --git a/tests/Translate3.ll.xml b/tests/Translate3.ll.xml
new file mode 100644
index 0000000..a8376c3
--- /dev/null
+++ b/tests/Translate3.ll.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:its="http://www.w3.org/2005/11/its" xsi:noNamespaceSchemaLocation="EX-ways-to-use-its-5.xsd" its:version="1.0" lang="test">
+ <head>
+ <title>La vie d'un simple homme</title>
+ </head>
+ <body>
+ <p>Tout commença alors que Zebulon découvrit qu'il avait un <its:span translate="no">doppelgänger</its:span> qui était un <its:span translate="no">aficionado</its:span> sérieux de baseball.</p>
+ </body>
+</book>
+<!-- timestamp $Id: Translate3.xml,v 1.2 2006/12/19 06:24:35 fsasaki Exp $ -->
diff --git a/tests/Translate4.ll.po b/tests/Translate4.ll.po
new file mode 100644
index 0000000..09505db
--- /dev/null
+++ b/tests/Translate4.ll.po
@@ -0,0 +1,19 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"POT-Creation-Date: 2011-05-31 21:28+0200\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"
+
+#: tests/Translate4.xml:3(head/title)
+msgid "The Life of a Simple Man"
+msgstr "La vie d'un simple homme"
+
+#: tests/Translate4.xml:6(body/p)
+msgid "Everything started when Zebulon discovered that he had a <_:fexp-1/> who was a serious baseball <_:fexp-2/>."
+msgstr "Tout commença alors que Zebulon découvrit qu'il avait un <_:fexp-1/> qui était un <_:fexp-2/> sérieux de baseball."
+
diff --git a/tests/Translate4.ll.xml b/tests/Translate4.ll.xml
new file mode 100644
index 0000000..7394181
--- /dev/null
+++ b/tests/Translate4.ll.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<book xmlns:its="http://www.w3.org/2005/11/its" its:version="1.0" lang="test">
+ <head>
+ <title>La vie d'un simple homme</title>
+ </head>
+ <body>
+ <p>Tout commença alors que Zebulon découvrit qu'il avait un <fexp its:translate="no">doppelgänger</fexp> qui était un <fexp its:translate="no">aficionado</fexp> sérieux de baseball.</p>
+ </body>
+</book>
+<!-- timestamp $Id: Translate4.xml,v 1.4 2007/02/02 19:29:30 ysavoure Exp $ -->
diff --git a/tests/Translate5.ll.po b/tests/Translate5.ll.po
new file mode 100644
index 0000000..d223418
--- /dev/null
+++ b/tests/Translate5.ll.po
@@ -0,0 +1,19 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"POT-Creation-Date: 2011-05-31 21:45+0200\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"
+
+#: tests/Translate5.xml:9(info/item)
+msgid "The Life of a <_:b-1/>"
+msgstr "La vie d'un <_:b-1/>"
+
+#: tests/Translate5.xml:15(content/p)
+msgid "Everything started when Zebulon discovered that he had a <_:span-1/> who was a serious baseball <_:span-2/>."
+msgstr "Tout commença alors que Zebulon découvrit qu'il avait un <_:span-1/> qui était un <_:span-2/> sérieux de baseball."
+
diff --git a/tests/Translate5.ll.xml b/tests/Translate5.ll.xml
new file mode 100644
index 0000000..ccb9cbd
--- /dev/null
+++ b/tests/Translate5.ll.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<doc xmlns:its="http://www.w3.org/2005/11/its" its:version="1.0">
+ <head>
+ <its:rules version="1.0">
+ <its:translateRule selector="//*" translate="no"/>
+ <its:translateRule selector="//p" translate="yes"/>
+ </its:rules>
+ </head>
+ <info>
+ <item type="title" its:translate="yes">La vie d'un <b>Simple Man</b></item>
+ <!-- Note that the contents of <b> and <span> should end up
+ *not* translatable with these settings -->
+ <item type="date-main">Dec-05-2006</item>
+ </info>
+ <content>
+ <p>Tout commença alors que Zebulon découvrit qu'il avait un <span>doppelgänger</span> qui était un <span>aficionado</span> sérieux de baseball.</p>
+ </content>
+</doc>
+<!-- timestamp $Id: Translate5.xml,v 1.4 2007/02/02 17:14:37 srahtz3 Exp $ -->
diff --git a/tests/Translate5.pot b/tests/Translate5.pot
new file mode 100644
index 0000000..0e48c38
--- /dev/null
+++ b/tests/Translate5.pot
@@ -0,0 +1,19 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"POT-Creation-Date: 2011-05-31 21:45+0200\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"
+
+#: tests/Translate5.xml:9(info/item)
+msgid "The Life of a <_:b-1/>"
+msgstr ""
+
+#: tests/Translate5.xml:15(content/p)
+msgid "Everything started when Zebulon discovered that he had a <_:span-1/> who was a serious baseball <_:span-2/>."
+msgstr ""
+
diff --git a/tests/Translate6.ll.po b/tests/Translate6.ll.po
new file mode 100644
index 0000000..b589916
--- /dev/null
+++ b/tests/Translate6.ll.po
@@ -0,0 +1,31 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"POT-Creation-Date: 2011-05-31 21:48+0200\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"
+
+#: tests/Translate6.xml:9(item/b)
+msgid "Simple Man"
+msgstr "simple homme"
+
+#: tests/Translate6.xml:9(info/item)
+msgid "The Life of a <_:b-1/>"
+msgstr "La vie d'un <_:b-1/>"
+
+#: tests/Translate6.xml:16(p/span)
+msgid "doppelgänger"
+msgstr "double"
+
+#: tests/Translate6.xml:17(p/span)
+msgid "aficionado"
+msgstr "passionné"
+
+#: tests/Translate6.xml:15(content/p)
+msgid "Everything started when Zebulon discovered that he had a <_:span-1/> who was a serious baseball <_:span-2/>."
+msgstr "Tout commença alors que Zebulon découvrit qu'il avait un <_:span-1/> qui était un <_:span-2/> sérieux de baseball."
+
diff --git a/tests/Translate6.ll.xml b/tests/Translate6.ll.xml
new file mode 100644
index 0000000..7c30876
--- /dev/null
+++ b/tests/Translate6.ll.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<doc xmlns:its="http://www.w3.org/2005/11/its" its:version="1.0">
+ <head>
+ <its:rules version="1.0">
+ <its:translateRule selector="/doc" translate="no"/>
+ <its:translateRule selector="//p" translate="yes"/>
+ </its:rules>
+ </head>
+ <info>
+ <item type="title" its:translate="yes">La vie d'un <b>simple homme</b></item>
+ <!-- Note that the contents of <b> and <span> should end up
+ translatable with these settings -->
+ <item type="date-main">Dec-05-2006</item>
+ </info>
+ <content>
+ <p>Tout commença alors que Zebulon découvrit qu'il avait un <span>double</span> qui était un <span>passionné</span> sérieux de baseball.</p>
+ </content>
+</doc>
+<!-- timestamp $Id: Translate6.xml,v 1.5 2007/02/02 17:59:34 srahtz3 Exp $ -->
diff --git a/tests/Translate7.ll.po b/tests/Translate7.ll.po
new file mode 100644
index 0000000..16acd6c
--- /dev/null
+++ b/tests/Translate7.ll.po
@@ -0,0 +1,19 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"POT-Creation-Date: 2011-05-31 21:54+0200\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"
+
+#: tests/Translate7.xml:19(body/p)
+msgid "For the implementation of ITS, apply the rules in the order:"
+msgstr "Pour l'implémentation d'ITS, appliquez les règles dans l'ordre :"
+
+#: tests/Translate7.xml:26(body/p)
+msgid "<_:ph-1/> The last rule wins."
+msgstr "<_:ph-1/> La dernière règle gagne."
+
diff --git a/tests/Translate7.ll.xml b/tests/Translate7.ll.xml
new file mode 100644
index 0000000..1ac74b0
--- /dev/null
+++ b/tests/Translate7.ll.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<topic id="myTopic">
+ <title>The ITS Topic</title>
+ <prolog>
+ <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0">
+ <its:translateRule selector="//*" translate="no"/>
+ <its:translateRule selector="//p" translate="yes"/>
+ <!-- With these rules only the text "For the implementation of ITS, apply the rules in the order:"
+ and " The last rule wins." should end up translatable -->
+ </its:rules>
+ </prolog>
+ <body>
+ <dl>
+ <dlentry id="tDataCat">
+ <dt>Data category</dt>
+ <dd>ITS defines <term>data category</term> as an abstract concept for a particular
+ type of information for internationalization and localization of XML schemas and documents.</dd>
+ </dlentry>
+ </dl>
+ <p>Pour l'implémentation d'ITS, appliquez les règles dans l'ordre :</p>
+ <ul>
+ <li>Default</li>
+ <li>Rules in the schema</li>
+ <li>Rules in the document instance</li>
+ <li>Local attributes</li>
+ </ul>
+ <p><ph xml:lang="fr">Et voilà !</ph> La dernière règle gagne.</p>
+ </body>
+</topic>
diff --git a/tests/Translate7.pot b/tests/Translate7.pot
new file mode 100644
index 0000000..2fe7d5e
--- /dev/null
+++ b/tests/Translate7.pot
@@ -0,0 +1,19 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"POT-Creation-Date: 2011-05-31 21:56+0200\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"
+
+#: tests/Translate7.xml:19(body/p)
+msgid "For the implementation of ITS, apply the rules in the order:"
+msgstr ""
+
+#: tests/Translate7.xml:26(body/p)
+msgid "<_:ph-1/> The last rule wins."
+msgstr ""
+
diff --git a/tests/run_tests.py b/tests/run_tests.py
index f674b48..c14a26d 100644
--- a/tests/run_tests.py
+++ b/tests/run_tests.py
@@ -28,24 +28,53 @@ class ItstoolTests(unittest.TestCase):
result = self.run_command("diff -u %s %s %s" % (options, f1, f2))
return self.assertEqual(result[1], "", result[1])
- def test_unicode_markup(self):
+ def _test_translation_process(self, start_file):
+ start_file_base = os.path.splitext(start_file)[0]
result = self.run_command("cd %(dir)s && python itstool_test -o %(out)s %(in)s" % {
'dir' : ITSTOOL_DIR,
'out' : os.path.join('tests', "test.pot"),
- 'in' : os.path.join('tests', 'Translate1.xml'),
+ 'in' : os.path.join('tests', start_file),
})
- self.assertFilesEqual(os.path.join(TEST_DIR, "test.pot"), os.path.join(TEST_DIR, "Translate1.pot"))
+ # If a reference pot file is present, test the output with this file
+ reference_pot = start_file_base + ".pot"
+ if os.path.exists(reference_pot):
+ self.assertFilesEqual(os.path.join(TEST_DIR, "test.pot"), os.path.join(TEST_DIR, reference_pot))
# Compile mo and merge
- self.run_command("cd %(dir)s && msgfmt -o test.mo Translate1.ll.po" % {'dir': TEST_DIR})
+ self.run_command("cd %(dir)s && msgfmt -o test.mo %(base)s.ll.po" % {'dir': TEST_DIR, 'base': start_file_base})
res = self.run_command("cd %(dir)s && python itstool_test -m %(mo)s -o %(res)s %(src)s" % {
'dir': ITSTOOL_DIR,
'mo' : os.path.join(TEST_DIR, "test.mo"),
'res': os.path.join(TEST_DIR, "test.xml"),
- 'src': os.path.join(TEST_DIR, "Translate1.xml"),
+ 'src': os.path.join(TEST_DIR, start_file),
})
- self.assertFilesEqual(os.path.join(TEST_DIR, "test.xml"), os.path.join(TEST_DIR, "Translate1.ll.xml"))
+ self.assertFilesEqual(os.path.join(TEST_DIR, "test.xml"), os.path.join(TEST_DIR, "%s.ll.xml" % start_file_base))
+
+
+ def test_unicode_markup(self):
+ self._test_translation_process('Translate1.xml')
+
+ def test_external_rules(self):
+ self._test_translation_process('Translate2.xml')
+
+ def test_embedded_its(self):
+ self._test_translation_process('Translate3.xml')
+
+ def test_notranslate_to_simpletag(self):
+ self._test_translation_process('Translate4.xml')
+
+ def test_selector_translate_rule(self):
+ self._test_translation_process('Translate5.xml')
+
+ def test_root_selector(self):
+ self._test_translation_process('Translate6.xml')
+
+ def test_last_rule_win(self):
+ self._test_translation_process('Translate7.xml')
+ # FIXME: currently deactivated until attributes are translatable
+ def xx_test_attribute_selectable(self):
+ self._test_translation_process('TranslateGlobal.xml')
class ITSTestRunner(unittest.TextTestRunner):
def run(self, test):