diff options
author | Shaun McCance <shaunm@gnome.org> | 2012-09-19 16:44:37 -0400 |
---|---|---|
committer | Shaun McCance <shaunm@gnome.org> | 2012-09-19 16:44:37 -0400 |
commit | fee986b054284b029b7b870eff6ded9fd53e43a0 (patch) | |
tree | b818b5642d215ace03a48fe0ddb78b3c9da7ec1f | |
parent | bec881523df59fb1380f82ab0a789d67c34a58ed (diff) | |
download | itstool-fee986b054284b029b7b870eff6ded9fd53e43a0.tar.gz |
Implemented ITS 2.0 External Resource data category
24 files changed, 501 insertions, 0 deletions
@@ -473,6 +473,7 @@ class Document (object): self._its_lang = {} self._itst_lang_attr = {} self._itst_credits = None + self._its_externals = {} self._itst_externals = [] def _check_errors(self): @@ -591,6 +592,20 @@ class Document (object): for node in self._try_xpath_eval(xpath, rule.nsProp('appendTo', None)): self._itst_credits = (node, rule) break + elif xml_is_ns_name(rule, NS_ITS, 'externalResourceRefRule'): + sel = rule.nsProp('selector', None) + ptr = rule.nsProp('externalResourceRefPointer', None) + if sel is not None and ptr is not None: + for node in self._try_xpath_eval(xpath, sel): + try: + oldnode = xpath.contextNode() + except: + oldnode = None + xpath.setContextNode(node) + res = self._try_xpath_eval(xpath, ptr) + if len(res) > 0: + self._its_externals[node] = res[0].content + xpath.setContextNode(oldnode) elif xml_is_ns_name(rule, NS_ITST, 'externalRefRule'): if rule.nsProp('selector', None) is not None and rule.nsProp('refPointer', None) is not None: for node in self._try_xpath_eval(xpath, rule.nsProp('selector', None)): @@ -1035,6 +1050,10 @@ class Document (object): break cnode = cnode.parent + self.generate_external_resource_message(node) + for attr in xml_attr_iter(node): + self.generate_external_resource_message(attr) + if withinText: path = path + '/' + node.name for child in xml_child_iter(node): @@ -1046,6 +1065,38 @@ class Document (object): elif msg is not None: msg.add_end_tag(node) + def generate_external_resource_message(self, node): + if not self._its_externals.has_key(node): + return + resref = self._its_externals[node] + if node.type == 'element': + translate = self.get_its_translate(node) + marker = '%s/%s' % (node.parent.name, node.name) + else: + translate = self.get_its_translate(node.parent) + marker = '%s/%s/@%s' % (node.parent.parent.name, node.parent.name, node.name) + if translate == 'no': + return + msg = Message() + try: + fullfile = os.path.join(os.path.dirname(self._filename), resref) + filefp = open(fullfile) + filemd5 = hashlib.md5(filefp.read()).hexdigest() + filefp.close() + except: + filemd5 = '__failed__' + txt = "external ref='%s' md5='%s'" % (resref, filemd5) + msg.set_context('_') + msg.add_text(txt) + msg.add_source('%s:%i' % (self._doc.name, node.lineNo())) + msg.add_marker(marker) + msg.add_comment(Comment('This is a reference to an external file such as an image or' + ' video. When the file changes, the md5 hash will change to' + ' let you know you need to update your localized copy. The' + ' msgstr is not used at all. Set it to whatever you like' + ' once you have updated your copy of the file.')) + self._msgs.add_message(msg, None) + def is_translation_unit (self, node): return self.get_its_within_text(node) != 'yes' diff --git a/tests/ExternalResource/Attr/ExternalResource1AttrXml.pot b/tests/ExternalResource/Attr/ExternalResource1AttrXml.pot new file mode 100644 index 0000000..79304ff --- /dev/null +++ b/tests/ExternalResource/Attr/ExternalResource1AttrXml.pot @@ -0,0 +1,41 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2012-09-19 16:09-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: videoobject/videodata/@fileref +#. This is a reference to an external file such as an image or video. When +#. the file changes, the md5 hash will change to let you know you need to +#. update your localized copy. The msgstr is not used at all. Set it to +#. whatever you like once you have updated your copy of the file. +#: tests/ExternalResource/Attr/ExternalResource1AttrXml.xml:9 +msgctxt "_" +msgid "external ref='movie.avi' md5='2a8c7c38f728f5183233a6a2d23dfd22'" +msgstr "" + +#. (itstool) path: imageobject/imagedata/@fileref +#. This is a reference to an external file such as an image or video. When +#. the file changes, the md5 hash will change to let you know you need to +#. update your localized copy. The msgstr is not used at all. Set it to +#. whatever you like once you have updated your copy of the file. +#: tests/ExternalResource/Attr/ExternalResource1AttrXml.xml:12 +msgctxt "_" +msgid "external ref='movie-frame.gif' md5='accdff2c3567073294db431130715b03'" +msgstr "" + +#. (itstool) path: textobject/para +#: tests/ExternalResource/Attr/ExternalResource1AttrXml.xml:15 +msgid "This video illustrates the proper way to assemble an inverting time distortion device." +msgstr "" + +#. (itstool) path: warning/para +#: tests/ExternalResource/Attr/ExternalResource1AttrXml.xml:18 +msgid "It is imperative that the primary and secondary temporal couplings not be mounted in the wrong order. Temporal catastrophe is the likely result. The future you destroy may be your own." +msgstr "" + diff --git a/tests/ExternalResource/Attr/ExternalResource1AttrXml.xml b/tests/ExternalResource/Attr/ExternalResource1AttrXml.xml new file mode 100644 index 0000000..23d509d --- /dev/null +++ b/tests/ExternalResource/Attr/ExternalResource1AttrXml.xml @@ -0,0 +1,24 @@ +<doc + xmlns:its="http://www.w3.org/2005/11/its" + xmlns:dbk="http://docbook.org/ns/docbook" > + <its:rules version="2.0"> + <its:externalResourceRefRule selector="//dbk:imagedata/@fileref | //dbk:audiodata/@fileref | //dbk:videodata/@fileref" externalResourceRefPointer="."/> + </its:rules> + <dbk:mediaobject> + <dbk:videoobject> + <dbk:videodata fileref="movie.avi"/> + </dbk:videoobject> + <dbk:imageobject> + <dbk:imagedata fileref="movie-frame.gif"/> + </dbk:imageobject> + <dbk:textobject> + <dbk:para>This video illustrates the proper way to assemble an inverting time distortion + device. </dbk:para> + <dbk:warning> + <dbk:para> It is imperative that the primary and secondary temporal couplings not be + mounted in the wrong order. Temporal catastrophe is the likely result. The + future you destroy may be your own. </dbk:para> + </dbk:warning> + </dbk:textobject> + </dbk:mediaobject> +</doc> diff --git a/tests/ExternalResource/Attr/ExternalResource2AttrRule.xml b/tests/ExternalResource/Attr/ExternalResource2AttrRule.xml new file mode 100644 index 0000000..f29c8eb --- /dev/null +++ b/tests/ExternalResource/Attr/ExternalResource2AttrRule.xml @@ -0,0 +1,3 @@ +<its:rules xmlns:its="http://www.w3.org/2005/11/its" xmlns:dbk="http://docbook.org/ns/docbook" version="2.0"> + <its:externalResourceRefRule selector="//dbk:imagedata/@fileref | //dbk:audiodata/@fileref | //dbk:videodata/@fileref" externalResourceRefPointer="."/> + </its:rules> diff --git a/tests/ExternalResource/Attr/ExternalResource2AttrXml.pot b/tests/ExternalResource/Attr/ExternalResource2AttrXml.pot new file mode 100644 index 0000000..c182f9e --- /dev/null +++ b/tests/ExternalResource/Attr/ExternalResource2AttrXml.pot @@ -0,0 +1,41 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2012-09-19 16:09-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: videoobject/videodata/@fileref +#. This is a reference to an external file such as an image or video. When +#. the file changes, the md5 hash will change to let you know you need to +#. update your localized copy. The msgstr is not used at all. Set it to +#. whatever you like once you have updated your copy of the file. +#: tests/ExternalResource/Attr/ExternalResource2AttrXml.xml:7 +msgctxt "_" +msgid "external ref='movie.avi' md5='2a8c7c38f728f5183233a6a2d23dfd22'" +msgstr "" + +#. (itstool) path: imageobject/imagedata/@fileref +#. This is a reference to an external file such as an image or video. When +#. the file changes, the md5 hash will change to let you know you need to +#. update your localized copy. The msgstr is not used at all. Set it to +#. whatever you like once you have updated your copy of the file. +#: tests/ExternalResource/Attr/ExternalResource2AttrXml.xml:10 +msgctxt "_" +msgid "external ref='movie-frame.gif' md5='accdff2c3567073294db431130715b03'" +msgstr "" + +#. (itstool) path: textobject/para +#: tests/ExternalResource/Attr/ExternalResource2AttrXml.xml:13 +msgid "This video illustrates the proper way to assemble an inverting time distortion device." +msgstr "" + +#. (itstool) path: warning/para +#: tests/ExternalResource/Attr/ExternalResource2AttrXml.xml:16 +msgid "It is imperative that the primary and secondary temporal couplings not be mounted in the wrong order. Temporal catastrophe is the likely result. The future you destroy may be your own." +msgstr "" + diff --git a/tests/ExternalResource/Attr/ExternalResource2AttrXml.xml b/tests/ExternalResource/Attr/ExternalResource2AttrXml.xml new file mode 100644 index 0000000..0669fb2 --- /dev/null +++ b/tests/ExternalResource/Attr/ExternalResource2AttrXml.xml @@ -0,0 +1,22 @@ +<doc + xmlns:its="http://www.w3.org/2005/11/its" + xmlns:dbk="http://docbook.org/ns/docbook" > + <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="ExternalResource2AttrRule.xml"/> + <dbk:mediaobject> + <dbk:videoobject> + <dbk:videodata fileref="movie.avi"/> + </dbk:videoobject> + <dbk:imageobject> + <dbk:imagedata fileref="movie-frame.gif"/> + </dbk:imageobject> + <dbk:textobject> + <dbk:para>This video illustrates the proper way to assemble an inverting time distortion + device. </dbk:para> + <dbk:warning> + <dbk:para> It is imperative that the primary and secondary temporal couplings not be + mounted in the wrong order. Temporal catastrophe is the likely result. The + future you destroy may be your own. </dbk:para> + </dbk:warning> + </dbk:textobject> + </dbk:mediaobject> +</doc> diff --git a/tests/ExternalResource/Attr/ExternalResource3AttrRule.xml b/tests/ExternalResource/Attr/ExternalResource3AttrRule.xml new file mode 100644 index 0000000..3c7df89 --- /dev/null +++ b/tests/ExternalResource/Attr/ExternalResource3AttrRule.xml @@ -0,0 +1,3 @@ +<its:rules xmlns:its="http://www.w3.org/2005/11/its" xmlns:dbk="http://docbook.org/ns/docbook" version="2.0"> + <its:externalResourceRefRule selector="//dbk:imagedata/@fileref | //dbk:videodata/@fileref" externalResourceRefPointer="."/> + </its:rules> diff --git a/tests/ExternalResource/Attr/ExternalResource3AttrXml.pot b/tests/ExternalResource/Attr/ExternalResource3AttrXml.pot new file mode 100644 index 0000000..52a3820 --- /dev/null +++ b/tests/ExternalResource/Attr/ExternalResource3AttrXml.pot @@ -0,0 +1,51 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2012-09-19 16:09-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: videoobject/videodata/@fileref +#. This is a reference to an external file such as an image or video. When +#. the file changes, the md5 hash will change to let you know you need to +#. update your localized copy. The msgstr is not used at all. Set it to +#. whatever you like once you have updated your copy of the file. +#: tests/ExternalResource/Attr/ExternalResource3AttrXml.xml:10 +msgctxt "_" +msgid "external ref='movie.avi' md5='2a8c7c38f728f5183233a6a2d23dfd22'" +msgstr "" + +#. (itstool) path: audioobject/audiodata/@fileref +#. This is a reference to an external file such as an image or video. When +#. the file changes, the md5 hash will change to let you know you need to +#. update your localized copy. The msgstr is not used at all. Set it to +#. whatever you like once you have updated your copy of the file. +#: tests/ExternalResource/Attr/ExternalResource3AttrXml.xml:13 +msgctxt "_" +msgid "external ref='movie.mp3' md5='8af2d557bdfbc6d8a9afa5828eea3547'" +msgstr "" + +#. (itstool) path: imageobject/imagedata/@fileref +#. This is a reference to an external file such as an image or video. When +#. the file changes, the md5 hash will change to let you know you need to +#. update your localized copy. The msgstr is not used at all. Set it to +#. whatever you like once you have updated your copy of the file. +#: tests/ExternalResource/Attr/ExternalResource3AttrXml.xml:16 +msgctxt "_" +msgid "external ref='movie-frame.gif' md5='accdff2c3567073294db431130715b03'" +msgstr "" + +#. (itstool) path: textobject/para +#: tests/ExternalResource/Attr/ExternalResource3AttrXml.xml:19 +msgid "This video illustrates the proper way to assemble an inverting time distortion device." +msgstr "" + +#. (itstool) path: warning/para +#: tests/ExternalResource/Attr/ExternalResource3AttrXml.xml:22 +msgid "It is imperative that the primary and secondary temporal couplings not be mounted in the wrong order. Temporal catastrophe is the likely result. The future you destroy may be your own." +msgstr "" + diff --git a/tests/ExternalResource/Attr/ExternalResource3AttrXml.xml b/tests/ExternalResource/Attr/ExternalResource3AttrXml.xml new file mode 100644 index 0000000..d58792a --- /dev/null +++ b/tests/ExternalResource/Attr/ExternalResource3AttrXml.xml @@ -0,0 +1,28 @@ +<doc + xmlns:its="http://www.w3.org/2005/11/its" + xmlns:dbk="http://docbook.org/ns/docbook" > + <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="ExternalResource2AttrRule.xml"/> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" xmlns:dbk="http://docbook.org/ns/docbook" version="2.0"> + <its:externalResourceRefRule selector="//dbk:audiodata/@fileref" externalResourceRefPointer="."/> + </its:rules> + <dbk:mediaobject> + <dbk:videoobject> + <dbk:videodata fileref="movie.avi"/> + </dbk:videoobject> + <dbk:audioobject> + <dbk:audiodata fileref="movie.mp3"/> + </dbk:audioobject> + <dbk:imageobject> + <dbk:imagedata fileref="movie-frame.gif"/> + </dbk:imageobject> + <dbk:textobject> + <dbk:para>This video illustrates the proper way to assemble an inverting time distortion + device. </dbk:para> + <dbk:warning> + <dbk:para> It is imperative that the primary and secondary temporal couplings not be + mounted in the wrong order. Temporal catastrophe is the likely result. The + future you destroy may be your own. </dbk:para> + </dbk:warning> + </dbk:textobject> + </dbk:mediaobject> +</doc> diff --git a/tests/ExternalResource/Attr/movie-frame.gif b/tests/ExternalResource/Attr/movie-frame.gif new file mode 100644 index 0000000..65c0d08 --- /dev/null +++ b/tests/ExternalResource/Attr/movie-frame.gif @@ -0,0 +1 @@ +movie-frame.gif diff --git a/tests/ExternalResource/Attr/movie.avi b/tests/ExternalResource/Attr/movie.avi new file mode 100644 index 0000000..a32c425 --- /dev/null +++ b/tests/ExternalResource/Attr/movie.avi @@ -0,0 +1 @@ +movie.avi diff --git a/tests/ExternalResource/Attr/movie.mp3 b/tests/ExternalResource/Attr/movie.mp3 new file mode 100644 index 0000000..34ee97e --- /dev/null +++ b/tests/ExternalResource/Attr/movie.mp3 @@ -0,0 +1 @@ +movie.mp3 diff --git a/tests/ExternalResource/ExternalResource1Xml.pot b/tests/ExternalResource/ExternalResource1Xml.pot new file mode 100644 index 0000000..a0be75c --- /dev/null +++ b/tests/ExternalResource/ExternalResource1Xml.pot @@ -0,0 +1,41 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2012-09-19 16:09-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: videoobject/videodata +#. This is a reference to an external file such as an image or video. When +#. the file changes, the md5 hash will change to let you know you need to +#. update your localized copy. The msgstr is not used at all. Set it to +#. whatever you like once you have updated your copy of the file. +#: tests/ExternalResource/ExternalResource1Xml.xml:9 +msgctxt "_" +msgid "external ref='movie.avi' md5='2a8c7c38f728f5183233a6a2d23dfd22'" +msgstr "" + +#. (itstool) path: imageobject/imagedata +#. This is a reference to an external file such as an image or video. When +#. the file changes, the md5 hash will change to let you know you need to +#. update your localized copy. The msgstr is not used at all. Set it to +#. whatever you like once you have updated your copy of the file. +#: tests/ExternalResource/ExternalResource1Xml.xml:12 +msgctxt "_" +msgid "external ref='movie-frame.gif' md5='accdff2c3567073294db431130715b03'" +msgstr "" + +#. (itstool) path: textobject/para +#: tests/ExternalResource/ExternalResource1Xml.xml:15 +msgid "This video illustrates the proper way to assemble an inverting time distortion device." +msgstr "" + +#. (itstool) path: warning/para +#: tests/ExternalResource/ExternalResource1Xml.xml:18 +msgid "It is imperative that the primary and secondary temporal couplings not be mounted in the wrong order. Temporal catastrophe is the likely result. The future you destroy may be your own." +msgstr "" + diff --git a/tests/ExternalResource/ExternalResource1Xml.xml b/tests/ExternalResource/ExternalResource1Xml.xml new file mode 100644 index 0000000..51b640e --- /dev/null +++ b/tests/ExternalResource/ExternalResource1Xml.xml @@ -0,0 +1,24 @@ +<doc + xmlns:its="http://www.w3.org/2005/11/its" + xmlns:dbk="http://docbook.org/ns/docbook" > + <its:rules version="2.0"> + <its:externalResourceRefRule selector="//dbk:imagedata | //dbk:audiodata | //dbk:videodata" externalResourceRefPointer="@fileref"/> + </its:rules> + <dbk:mediaobject> + <dbk:videoobject> + <dbk:videodata fileref="movie.avi"/> + </dbk:videoobject> + <dbk:imageobject> + <dbk:imagedata fileref="movie-frame.gif"/> + </dbk:imageobject> + <dbk:textobject> + <dbk:para>This video illustrates the proper way to assemble an inverting time distortion + device. </dbk:para> + <dbk:warning> + <dbk:para> It is imperative that the primary and secondary temporal couplings not be + mounted in the wrong order. Temporal catastrophe is the likely result. The + future you destroy may be your own. </dbk:para> + </dbk:warning> + </dbk:textobject> + </dbk:mediaobject> +</doc> diff --git a/tests/ExternalResource/ExternalResource2Rule.xml b/tests/ExternalResource/ExternalResource2Rule.xml new file mode 100644 index 0000000..718135f --- /dev/null +++ b/tests/ExternalResource/ExternalResource2Rule.xml @@ -0,0 +1,3 @@ +<its:rules xmlns:its="http://www.w3.org/2005/11/its" xmlns:dbk="http://docbook.org/ns/docbook" version="2.0"> + <its:externalResourceRefRule selector="//dbk:imagedata | //dbk:audiodata | //dbk:videodata" externalResourceRefPointer="@fileref"/> + </its:rules> diff --git a/tests/ExternalResource/ExternalResource2Xml.pot b/tests/ExternalResource/ExternalResource2Xml.pot new file mode 100644 index 0000000..d439bcd --- /dev/null +++ b/tests/ExternalResource/ExternalResource2Xml.pot @@ -0,0 +1,41 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2012-09-19 16:09-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: videoobject/videodata +#. This is a reference to an external file such as an image or video. When +#. the file changes, the md5 hash will change to let you know you need to +#. update your localized copy. The msgstr is not used at all. Set it to +#. whatever you like once you have updated your copy of the file. +#: tests/ExternalResource/ExternalResource2Xml.xml:7 +msgctxt "_" +msgid "external ref='movie.avi' md5='2a8c7c38f728f5183233a6a2d23dfd22'" +msgstr "" + +#. (itstool) path: imageobject/imagedata +#. This is a reference to an external file such as an image or video. When +#. the file changes, the md5 hash will change to let you know you need to +#. update your localized copy. The msgstr is not used at all. Set it to +#. whatever you like once you have updated your copy of the file. +#: tests/ExternalResource/ExternalResource2Xml.xml:10 +msgctxt "_" +msgid "external ref='movie-frame.gif' md5='accdff2c3567073294db431130715b03'" +msgstr "" + +#. (itstool) path: textobject/para +#: tests/ExternalResource/ExternalResource2Xml.xml:13 +msgid "This video illustrates the proper way to assemble an inverting time distortion device." +msgstr "" + +#. (itstool) path: warning/para +#: tests/ExternalResource/ExternalResource2Xml.xml:16 +msgid "It is imperative that the primary and secondary temporal couplings not be mounted in the wrong order. Temporal catastrophe is the likely result. The future you destroy may be your own." +msgstr "" + diff --git a/tests/ExternalResource/ExternalResource2Xml.xml b/tests/ExternalResource/ExternalResource2Xml.xml new file mode 100644 index 0000000..0120546 --- /dev/null +++ b/tests/ExternalResource/ExternalResource2Xml.xml @@ -0,0 +1,22 @@ +<doc + xmlns:its="http://www.w3.org/2005/11/its" + xmlns:dbk="http://docbook.org/ns/docbook" > + <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="ExternalResource2Rule.xml"/> + <dbk:mediaobject> + <dbk:videoobject> + <dbk:videodata fileref="movie.avi"/> + </dbk:videoobject> + <dbk:imageobject> + <dbk:imagedata fileref="movie-frame.gif"/> + </dbk:imageobject> + <dbk:textobject> + <dbk:para>This video illustrates the proper way to assemble an inverting time distortion + device. </dbk:para> + <dbk:warning> + <dbk:para> It is imperative that the primary and secondary temporal couplings not be + mounted in the wrong order. Temporal catastrophe is the likely result. The + future you destroy may be your own. </dbk:para> + </dbk:warning> + </dbk:textobject> + </dbk:mediaobject> +</doc> diff --git a/tests/ExternalResource/ExternalResource3Rule.xml b/tests/ExternalResource/ExternalResource3Rule.xml new file mode 100644 index 0000000..383781c --- /dev/null +++ b/tests/ExternalResource/ExternalResource3Rule.xml @@ -0,0 +1,3 @@ +<its:rules xmlns:its="http://www.w3.org/2005/11/its" xmlns:dbk="http://docbook.org/ns/docbook" version="2.0"> + <its:externalResourceRefRule selector="//dbk:imagedata | //dbk:videodata" externalResourceRefPointer="@fileref"/> + </its:rules> diff --git a/tests/ExternalResource/ExternalResource3Xml.pot b/tests/ExternalResource/ExternalResource3Xml.pot new file mode 100644 index 0000000..c1b2a90 --- /dev/null +++ b/tests/ExternalResource/ExternalResource3Xml.pot @@ -0,0 +1,51 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2012-09-19 16:09-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: videoobject/videodata +#. This is a reference to an external file such as an image or video. When +#. the file changes, the md5 hash will change to let you know you need to +#. update your localized copy. The msgstr is not used at all. Set it to +#. whatever you like once you have updated your copy of the file. +#: tests/ExternalResource/ExternalResource3Xml.xml:10 +msgctxt "_" +msgid "external ref='movie.avi' md5='2a8c7c38f728f5183233a6a2d23dfd22'" +msgstr "" + +#. (itstool) path: audioobject/audiodata +#. This is a reference to an external file such as an image or video. When +#. the file changes, the md5 hash will change to let you know you need to +#. update your localized copy. The msgstr is not used at all. Set it to +#. whatever you like once you have updated your copy of the file. +#: tests/ExternalResource/ExternalResource3Xml.xml:13 +msgctxt "_" +msgid "external ref='movie.mp3' md5='8af2d557bdfbc6d8a9afa5828eea3547'" +msgstr "" + +#. (itstool) path: imageobject/imagedata +#. This is a reference to an external file such as an image or video. When +#. the file changes, the md5 hash will change to let you know you need to +#. update your localized copy. The msgstr is not used at all. Set it to +#. whatever you like once you have updated your copy of the file. +#: tests/ExternalResource/ExternalResource3Xml.xml:16 +msgctxt "_" +msgid "external ref='movie-frame.gif' md5='accdff2c3567073294db431130715b03'" +msgstr "" + +#. (itstool) path: textobject/para +#: tests/ExternalResource/ExternalResource3Xml.xml:19 +msgid "This video illustrates the proper way to assemble an inverting time distortion device." +msgstr "" + +#. (itstool) path: warning/para +#: tests/ExternalResource/ExternalResource3Xml.xml:22 +msgid "It is imperative that the primary and secondary temporal couplings not be mounted in the wrong order. Temporal catastrophe is the likely result. The future you destroy may be your own." +msgstr "" + diff --git a/tests/ExternalResource/ExternalResource3Xml.xml b/tests/ExternalResource/ExternalResource3Xml.xml new file mode 100644 index 0000000..0384a58 --- /dev/null +++ b/tests/ExternalResource/ExternalResource3Xml.xml @@ -0,0 +1,28 @@ +<doc + xmlns:its="http://www.w3.org/2005/11/its" + xmlns:dbk="http://docbook.org/ns/docbook" > + <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="ExternalResource2Rule.xml"/> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" xmlns:dbk="http://docbook.org/ns/docbook" version="2.0"> + <its:externalResourceRefRule selector="//dbk:audiodata" externalResourceRefPointer="@fileref"/> + </its:rules> + <dbk:mediaobject> + <dbk:videoobject> + <dbk:videodata fileref="movie.avi"/> + </dbk:videoobject> + <dbk:audioobject> + <dbk:audiodata fileref="movie.mp3"/> + </dbk:audioobject> + <dbk:imageobject> + <dbk:imagedata fileref="movie-frame.gif"/> + </dbk:imageobject> + <dbk:textobject> + <dbk:para>This video illustrates the proper way to assemble an inverting time distortion + device. </dbk:para> + <dbk:warning> + <dbk:para> It is imperative that the primary and secondary temporal couplings not be + mounted in the wrong order. Temporal catastrophe is the likely result. The + future you destroy may be your own. </dbk:para> + </dbk:warning> + </dbk:textobject> + </dbk:mediaobject> +</doc> diff --git a/tests/ExternalResource/movie-frame.gif b/tests/ExternalResource/movie-frame.gif new file mode 100644 index 0000000..65c0d08 --- /dev/null +++ b/tests/ExternalResource/movie-frame.gif @@ -0,0 +1 @@ +movie-frame.gif diff --git a/tests/ExternalResource/movie.avi b/tests/ExternalResource/movie.avi new file mode 100644 index 0000000..a32c425 --- /dev/null +++ b/tests/ExternalResource/movie.avi @@ -0,0 +1 @@ +movie.avi diff --git a/tests/ExternalResource/movie.mp3 b/tests/ExternalResource/movie.mp3 new file mode 100644 index 0000000..34ee97e --- /dev/null +++ b/tests/ExternalResource/movie.mp3 @@ -0,0 +1 @@ +movie.mp3 diff --git a/tests/run_tests.py b/tests/run_tests.py index dcd427d..1a6bcd6 100644 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -156,6 +156,24 @@ class ItstoolTests(unittest.TestCase): def test_TranslateGlobal(self): self._test_translation_process('Translate/TranslateGlobal.xml') + def test_ExternalResource1(self): + self._test_pot_generation('ExternalResource/ExternalResource1Xml.xml') + + def test_ExternalResource2(self): + self._test_pot_generation('ExternalResource/ExternalResource2Xml.xml') + + def test_ExternalResource3(self): + self._test_pot_generation('ExternalResource/ExternalResource3Xml.xml') + + def test_ExternalResource1Attr(self): + self._test_pot_generation('ExternalResource/Attr/ExternalResource1AttrXml.xml') + + def test_ExternalResource2Attr(self): + self._test_pot_generation('ExternalResource/Attr/ExternalResource2AttrXml.xml') + + def test_ExternalResource3Attr(self): + self._test_pot_generation('ExternalResource/Attr/ExternalResource3AttrXml.xml') + def test_Locale1(self): self._test_translation_process('LocaleFilter/Locale1Xml.xml', outputs=[('LocaleFilter/Locale1Xml.fr_FR.po', |