+commit 0520144626db679e81725aebfaba273a52fd0bf4
+Merge: 092a264 7e07396
+Author: Shaun McCance <shaunm@gnome.org>
+Date: Sat Sep 3 13:21:09 2011 -0400
+
+ Merge: Proper XML error catching [claude]
+
+commit 092a26470a5032c85ba8a40570ee6fd6c9fe9b30
+Merge: c3566db 48e4257
+Author: Shaun McCance <shaunm@gnome.org>
+Date: Sat Sep 3 13:10:19 2011 -0400
+
+ Merge commit '48e4257421beb439f23a78507f43aae694775974'
+
+commit c3566dbec79ecd2d0bbef5b42044d7b12380c034
+Merge: 6e6ca0d 6411b09
+Author: Shaun McCance <shaunm@gnome.org>
+Date: Sat Sep 3 10:56:58 2011 -0400
+
+ Merge commit 'refs/merge-requests/2' of git://gitorious.org/itstool/itstool
+
+commit 7e0739641507d92e1d2ec7e9b7f5e5c7c09a940a
+Author: Claude Paroz <claude@2xlibre.net>
+Date: Wed Aug 17 13:32:42 2011 +0200
+
+ Catch XML errors in translated content
+
+ itstool.in | 1 +
+ tests/Translate3.ll.wrong.po | 19 +++++++++++++++++++
+ tests/run_tests.py | 24 ++++++++++++++++++------
+ 3 files changed, 38 insertions(+), 6 deletions(-)
+
+commit 1abdf1b0d83b37a9f298563e139c118c9a62629b
+Author: Claude Paroz <claude@2xlibre.net>
+Date: Wed Aug 17 12:10:36 2011 +0200
+
+ Catch XML parsing errors so itstool does properly exit with error code
+
+ itstool.in | 10 ++++++++++
+ tests/Malformed.xml | 6 ++++++
+ tests/run_tests.py | 18 ++++++++++++------
+ 3 files changed, 28 insertions(+), 6 deletions(-)
+
+commit 6411b09431eb72ed5426d40a0142e7479c486d3b
+Author: Claude Paroz <claude@2xlibre.net>
+Date: Wed Jun 29 21:15:46 2011 +0200
+
+ Fix placeholder translation when it contains sub-elements
+
+ itstool.in | 12 ++++++++++--
+ tests/Placeholder.ll.po | 19 +++++++++++++++++++
+ tests/Placeholder.ll.xml | 6 ++++++
+ tests/Placeholder.xml | 5 +++++
+ tests/run_tests.py | 4 +++-
+ 5 files changed, 43 insertions(+), 3 deletions(-)
+
+commit 6e6ca0daf4084aaa94268f062461e1ec712698fa
+Author: Shaun McCance <shaunm@gnome.org>
+Date: Mon Jun 27 14:59:56 2011 -0400
+
+ Version 1.1.0
+
+ NEWS | 14 ++++++++++++++
+ configure.ac | 2 +-
+ 2 files changed, 15 insertions(+), 1 deletions(-)
+
commit 187fcbe585560f128c7436e66f6b8e3a789a73b0
Author: Shaun McCance <shaunm@gnome.org>
Date: Sun Jun 26 12:28:10 2011 -0400
itstool | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
+commit 48e4257421beb439f23a78507f43aae694775974
+Author: Javier Jardón <jjardon@gnome.org>
+Date: Tue Apr 26 17:00:23 2011 +0100
+
+ autogen.sh: Improve script to handle out of tree compilations
+
+ Also handle the option to not run the configure step
+
+ autogen.sh | 7 +++++--
+ 1 files changed, 5 insertions(+), 2 deletions(-)
+
commit 65ecbc8856e91b991d812e08dfa10300504bfb1b
Author: Shaun McCance <shaunm@gnome.org>
Date: Tue Apr 26 11:33:03 2011 -0400
+1.1.1
+=====
+* Catch XML parsing errors and exit with error code
+* Fixed placeholder translation when it contains sub-elements
+* Improved autogen.sh for out of tree compilations
+* Commits by Claude Paroz, Javier Jardón
+
1.1.0
=====
* Added itst:context to set msgctxt
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.66 for itstool 1.1.0.
+# Generated by GNU Autoconf 2.66 for itstool 1.1.1.
#
#
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
# Identity of this package.
PACKAGE_NAME='itstool'
PACKAGE_TARNAME='itstool'
-PACKAGE_VERSION='1.1.0'
-PACKAGE_STRING='itstool 1.1.0'
+PACKAGE_VERSION='1.1.1'
+PACKAGE_STRING='itstool 1.1.1'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures itstool 1.1.0 to adapt to many kinds of systems.
+\`configure' configures itstool 1.1.1 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of itstool 1.1.0:";;
+ short | recursive ) echo "Configuration of itstool 1.1.1:";;
esac
cat <<\_ACEOF
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-itstool configure 1.1.0
+itstool configure 1.1.1
generated by GNU Autoconf 2.66
Copyright (C) 2010 Free Software Foundation, Inc.
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by itstool $as_me 1.1.0, which was
+It was created by itstool $as_me 1.1.1, which was
generated by GNU Autoconf 2.66. Invocation command line was
$ $0 $@
# Define the identity of the package.
PACKAGE='itstool'
- VERSION='1.1.0'
+ VERSION='1.1.1'
cat >>confdefs.h <<_ACEOF
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by itstool $as_me 1.1.0, which was
+This file was extended by itstool $as_me 1.1.1, which was
generated by GNU Autoconf 2.66. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-itstool config.status 1.1.0
+itstool config.status 1.1.1
configured by $0, generated by GNU Autoconf 2.66,
with options \\"\$ac_cs_config\\"
-AC_INIT([itstool], [1.1.0], [])
+AC_INIT([itstool], [1.1.1], [])
AM_INIT_AUTOMAKE([1.9 no-dist-gzip dist-bzip2])
DATADIR=`(
# Place, Suite 330, Boston, MA 0211-1307 USA.
#
-VERSION="1.1.0"
+VERSION="1.1.1"
DATADIR="/usr/local/share"
import gettext
return False
return node.name == name and node.ns() is not None and node.ns().content == ns
+def xml_error_catcher(doc, error):
+ doc._xml_err += " %s" % error
+
class Document (object):
def __init__ (self, filename, messages):
+ self._xml_err = ''
+ libxml2.registerErrorHandler(xml_error_catcher, self)
ctxt = libxml2.createFileParserCtxt(filename)
ctxt.lineNumbers(1)
ctxt.replaceEntities(1)
self._localrules.append(child)
pre_process(child)
pre_process(self._doc)
+ self._check_errors()
self._msgs = messages
self._its_translate_nodes = {}
self._its_within_text_nodes = {}
self._itst_credits = None
self._itst_externals = []
+ def _check_errors(self):
+ if self._xml_err:
+ raise libxml2.parserError(self._xml_err)
+
def apply_its_rule(self, rule, xpath):
if rule.type != 'element':
return
if child.type == 'element':
fix_node_ns(child, childnsdefs)
fix_node_ns(node, {})
+ self._check_errors()
def translate_attrs(self, oldnode, newnode):
trans_attrs = [attr for attr in xml_attr_iter(oldnode) if self._its_translate_nodes.get(attr, 'no') == 'yes']
if child.type != 'element':
continue
if child.ns() is not None and child.ns().content == NS_BLANK:
- repl = self.get_translated(msg.get_placeholder(child.name).node, translations)
- child.replaceNode(repl)
+ ph_node = msg.get_placeholder(child.name).node
+ if self.has_child_elements(ph_node):
+ self.merge_translations(translations, None, ph_node)
+ child.replaceNode(ph_node)
+ else:
+ repl = self.get_translated(ph_node, translations)
+ child.replaceNode(repl)
scan_node(child)
scan_node(trnode)
retnode = node.copyNode(2)
def is_translation_unit (self, node):
return self.get_its_within_text(node) != 'yes'
+ def has_child_elements(self, node):
+ return len([child for child in xml_child_iter(node) if child.type=='element'])
+
def get_preserve_space (self, node):
if node.getSpacePreserve() == 1:
return True
-.TH ITSTOOL "1" "May 2011" "itstool 1.1.0"
+.TH ITSTOOL "1" "May 2011" "itstool 1.1.1"
.SH NAME
itstool \- convert between XML and PO using ITS
return False
return node.name == name and node.ns() is not None and node.ns().content == ns
+def xml_error_catcher(doc, error):
+ doc._xml_err += " %s" % error
+
class Document (object):
def __init__ (self, filename, messages):
+ self._xml_err = ''
+ libxml2.registerErrorHandler(xml_error_catcher, self)
ctxt = libxml2.createFileParserCtxt(filename)
ctxt.lineNumbers(1)
ctxt.replaceEntities(1)
self._localrules.append(child)
pre_process(child)
pre_process(self._doc)
+ self._check_errors()
self._msgs = messages
self._its_translate_nodes = {}
self._its_within_text_nodes = {}
self._itst_credits = None
self._itst_externals = []
+ def _check_errors(self):
+ if self._xml_err:
+ raise libxml2.parserError(self._xml_err)
+
def apply_its_rule(self, rule, xpath):
if rule.type != 'element':
return
if child.type == 'element':
fix_node_ns(child, childnsdefs)
fix_node_ns(node, {})
+ self._check_errors()
def translate_attrs(self, oldnode, newnode):
trans_attrs = [attr for attr in xml_attr_iter(oldnode) if self._its_translate_nodes.get(attr, 'no') == 'yes']
if child.type != 'element':
continue
if child.ns() is not None and child.ns().content == NS_BLANK:
- repl = self.get_translated(msg.get_placeholder(child.name).node, translations)
- child.replaceNode(repl)
+ ph_node = msg.get_placeholder(child.name).node
+ if self.has_child_elements(ph_node):
+ self.merge_translations(translations, None, ph_node)
+ child.replaceNode(ph_node)
+ else:
+ repl = self.get_translated(ph_node, translations)
+ child.replaceNode(repl)
scan_node(child)
scan_node(trnode)
retnode = node.copyNode(2)
def is_translation_unit (self, node):
return self.get_its_within_text(node) != 'yes'
+ def has_child_elements(self, node):
+ return len([child for child in xml_child_iter(node) if child.type=='element'])
+
def get_preserve_space (self, node):
if node.getSpacePreserve() == 1:
return True