gimp-help-2 r2590 - in branches/xml2po-support: . tools
- From: ulfehlert svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp-help-2 r2590 - in branches/xml2po-support: . tools
- Date: Fri, 31 Oct 2008 20:57:56 +0000 (UTC)
Author: ulfehlert
Date: Fri Oct 31 20:57:56 2008
New Revision: 2590
URL: http://svn.gnome.org/viewvc/gimp-help-2?rev=2590&view=rev
Log:
2008-10-31 Ulf-D. Ehlert <ulfehlert svn gnome org>
* tools/xml2po_for_gimp-help.patch1
* tools/xml2po: fixed output of "tools/xml2po --version"
* tools/migrate.sh: more minor changes
* tools/split_xml_multi_lang.py: don't skip 'xi:include' elements
any more; a few more comments
Modified:
branches/xml2po-support/ChangeLog
branches/xml2po-support/tools/migrate.sh
branches/xml2po-support/tools/split_xml_multi_lang.py
branches/xml2po-support/tools/xml2po
branches/xml2po-support/tools/xml2po_for_gimp-help.patch1
Modified: branches/xml2po-support/tools/migrate.sh
==============================================================================
--- branches/xml2po-support/tools/migrate.sh (original)
+++ branches/xml2po-support/tools/migrate.sh Fri Oct 31 20:57:56 2008
@@ -2,25 +2,26 @@
# this script migrates the content from DocBook XML files to PO/GETTEXT
# supported XML files ??!?!
+# XXX: what about fi?
#LINGUAS="de en es fr it ko nl no pl ru sv"
-LINGUAS="de fr"
+: ${LINGUAS:="de fr"}
-srcdir="src"
-oldsrcdir="oldsrc"
-xmldir="xml"
-potdir="pot"
-podir="po"
+: ${srcdir:=src}
+: ${oldsrcdir:=oldsrc}
+: ${xmldir:=xml}
+: ${potdir:=pot}
+: ${podir:=po}
SPLIT="python tools/split_xml_multi_lang.py"
XML2PO="python tools/xml2po" # patched version!!
-exclude_patterns='.svn key-reference* glossary dictionary'
+: ${exclude_patterns:='.svn key-reference* glossary dictionary'}
exclude=$(echo "$exclude_patterns" | \
sed -e 's/[^ ]\+/"&"/g; s/ / -o -name /g; s/^/\\( -name /; s/$/ \\) -prune /')
# clean-up
if [ -d "$oldsrcdir" ]; then
- echo >&2 Removing $srcdir, $potdir, $podir, $xmldir, ...
+ echo >&2 Removing $srcdir, $potdir, $podir, $xmldir ...
test -L $xmldir/en && rm $xmldir/en
test -d $srcdir && rm -rf $srcdir
test -d $potdir && rm -rf $potdir
@@ -29,21 +30,28 @@
mv $oldsrcdir $srcdir
fi
-echo "Splitting the source XML"
+echo >&2 "Splitting the source XML"
+echo >&2 "Warning: the following files and directories will be skipped:"
+echo "$exclude_patterns" | sed -e 's/ /, /g; s/^/ /' >&2
time \
eval find $srcdir $exclude -o -name '*.xml' -print |
while read srcfile
do
base=${srcfile%/*}
- base=${base#$srcdir/}
+ base=${base#$srcdir}
$SPLIT --lang="$LINGUAS" --file="$srcfile" \
- --dest="$xmldir"/'*'/"$base"/
+ --dest="$xmldir"/'*'/"${base#/}"/
done
echo
-mv -vi "$srcdir" "$oldsrcdir" && mv -vi "$xmldir"/en "$srcdir"
+echo >&2 Moving $srcdir and $xmldir ...
+mv -vi "$srcdir" "$oldsrcdir" && \
+mv -vi "$xmldir"/en "$srcdir" && \
+echo >&2 Creating "$xmldir"/en link to "$srcdir" ...
+ln -vs $PWD/"$srcdir" "$xmldir"/en
echo
+test "$1" = "split" && exit 0
echo "Creating POT files"
time \
@@ -60,6 +68,7 @@
done
echo
+test "$1" = "pot" && exit 0
echo "Creating PO files"
time \
@@ -81,3 +90,11 @@
done
done
echo
+
+echo Simple check: searching for empty files...
+trap "rm -f 'empty files'" HUP INT QUIT PIPE TERM
+find ${podir} ${potdir} -type f -size 0 | sort | tee "empty files"
+echo $(wc -l "empty files") found. && rm -f "empty files"
+echo
+
+
Modified: branches/xml2po-support/tools/split_xml_multi_lang.py
==============================================================================
--- branches/xml2po-support/tools/split_xml_multi_lang.py (original)
+++ branches/xml2po-support/tools/split_xml_multi_lang.py Fri Oct 31 20:57:56 2008
@@ -120,8 +120,7 @@
This method is used to skip comments etc.
"""
- return self._node.nodeType in (xml.dom.minidom.Node.COMMENT_NODE,) \
- or self._node.nodeName in ('xi:include',)
+ return self._node.nodeType in (xml.dom.minidom.Node.COMMENT_NODE,)
# <<<<<<<<<<<<<<<< not used <<<<<<<<<<<<<<<<
@@ -269,11 +268,16 @@
for lang in self.languages:
dest[lang].appendChild(child.cloneNode(NONRECURSIVE))
- # (3) skip every non-English element
+ # (3) add xi:include elements
+ elif child.nodeName == 'xi:include':
+ for lang in self.languages:
+ dest[lang].appendChild(child.cloneNode(NONRECURSIVE))
+
+ # (4) skip every non-English element
elif self.skip(child):
pass
- # (4) at last, handle non-trivial cases...
+ # (5) at last, handle non-trivial cases...
else:
assert child.nodeType == child.ELEMENT_NODE \
and 'en' in self.get_langs(child)
@@ -284,13 +288,13 @@
# element.
copies = self.vectorize(child, parentnodes)
- # (4a) append recursively localized clones of nodes we don't
+ # (5a) append recursively localized clones of nodes we don't
# need/want to process any further (para, phrase, etc.)
if self.final(child):
self.logger.debug("split(%s) --> adding %s (final)" % \
(elem.nodeName, child.nodeName))
clones = self.append_clones(copies, dest, RECURSIVE)
- # (4b) append non-recursively localized clones of nodes and
+ # (5b) append non-recursively localized clones of nodes and
# then traverse child nodes recursively (sect[1-4], note, etc.)
else:
self.logger.debug("split(%s) --> adding %s" % \
@@ -333,24 +337,39 @@
# parent node.
if not parents:
- # copy element for every element language
+ # Algorithm:
+ # (1) for every language defined by the element's "lang"
+ # attribute select the element itself
+ # (2) create set of all sibling elements of the same type/name
+ # without a "seqnum" attribute (which indicates that this
+ # sibling has already been used)
+ # (3a) if element is final: select the first matching element
+ # for every remaining language
+ # (3b) if element is not final: same as (3a), but stop on the
+ # first sibling with a language that was already processed
+ # (4) select the element itself for every missing language
+
nodes = dict([(lang, elem) for lang in self.get_langs(elem)])
assert nodes.has_key('en')
assert len(nodes) != len(self.languages)
- # TODO: describe algorithm
-
- siblings = self.get_siblings(elem)
found = 0
-
- for sibl in siblings:
+ for sibl in self.get_siblings(elem):
sibl_langs = self.get_langs(sibl)
new_langs = [k for k in sibl_langs if k not in nodes]
+ # for non-final nodes (which will be processed recursively)
+ # it's important that we stop on any language already "seen",
+ # otherwise different sections will be mixed-up, .e.g.
+ # <section lang="en"> ... <section lang="en;xx;yy">
if not self.final(elem):
if len(sibl_langs) > len(new_langs):
break
elif not new_langs:
+ # here we just skip any non-matching sibling, e.g.
+ # <para lang="en"> ... <para lang="en"> ...
+ # <para lang="xx"> ... <para lang="xx"> ...
continue
+ # mark as "seen"
sibl.setAttribute("seqnum", str(self.seqnum))
for lang in new_langs:
nodes[lang] = sibl
@@ -496,8 +515,7 @@
This method is used to skip comments etc.
"""
- return node.nodeType in (node.COMMENT_NODE,) \
- or node.nodeName in ('xi:include',)
+ return node.nodeType in (node.COMMENT_NODE,)
def text(self, node):
"""Whether or not a node is a text node."""
Modified: branches/xml2po-support/tools/xml2po
==============================================================================
--- branches/xml2po-support/tools/xml2po (original)
+++ branches/xml2po-support/tools/xml2po Fri Oct 31 20:57:56 2008
@@ -777,7 +777,7 @@
elif opt in ('-o', '--output'):
output = arg
elif opt in ('-v', '--version'):
- print VERSION
+ print VERSION + " (patched by GIMP Documentation Team 2008-10-23)"
sys.exit(0)
elif opt in ('-h', '--help'):
usage(True)
Modified: branches/xml2po-support/tools/xml2po_for_gimp-help.patch1
==============================================================================
--- branches/xml2po-support/tools/xml2po_for_gimp-help.patch1 (original)
+++ branches/xml2po-support/tools/xml2po_for_gimp-help.patch1 Fri Oct 31 20:57:56 2008
@@ -1,5 +1,5 @@
---- xml2po 2008-10-11 14:10:16.000000000 +0200
-+++ xml2po 2008-10-23 20:00:00.000000000 +0200
+--- tools/xml2po 2008-10-23 20:00:00.000000000 +0200
++++ tools/xml2po 2008-10-31 21:00:00.000000000 +0100
@@ -430,39 +430,30 @@
return final
@@ -68,3 +68,12 @@
sys.exit(0)
elif opt in ('-h', '--help'):
sys.stderr.write("Error: If you want help, please use `%s --help' without '-u' option.\n" % (allargs[0]))
+@@ -786,7 +777,7 @@
+ elif opt in ('-o', '--output'):
+ output = arg
+ elif opt in ('-v', '--version'):
+- print VERSION
++ print VERSION + " (patched by GIMP Documentation Team 2008-10-23)"
+ sys.exit(0)
+ elif opt in ('-h', '--help'):
+ usage(True)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]