gimp-help-2 r2585 - in branches/xml2po-support: . tools



Author: romanofski
Date: Sat Oct 18 12:08:43 2008
New Revision: 2585
URL: http://svn.gnome.org/viewvc/gimp-help-2?rev=2585&view=rev

Log:

2008-10-18  Roman Joost  <romanofski gimp org>

	* tools/xmllang2en.sh
	* tools/migrate.sh: added migrate script, which still needs to
	be evolved to do the right thing, but it basically does what
	we want
	
	* Makefile.am: added xml-* targets from the Makefile written by
	Ulf


Added:
   branches/xml2po-support/tools/migrate.sh   (contents, props changed)
   branches/xml2po-support/tools/xmllang2en.sh   (contents, props changed)
Modified:
   branches/xml2po-support/ChangeLog
   branches/xml2po-support/Makefile.am

Modified: branches/xml2po-support/Makefile.am
==============================================================================
--- branches/xml2po-support/Makefile.am	(original)
+++ branches/xml2po-support/Makefile.am	Sat Oct 18 12:08:43 2008
@@ -86,6 +86,8 @@
 
 xmldir   = src
 
+xmlpodir = xml
+
 potdir   = pot
 
 podir    = po
@@ -112,7 +114,6 @@
 
 
 #### POT -> PO
-# XXX TODO -> configure.ac
 PO_LANGS      = $(filter-out $(XML_LANG), $(ALL_LINGUAS))
 
 pot2po  = if [ -f $@ ]; then \
@@ -144,6 +145,52 @@
 po-en: ;
 
 
+#### PO -> XML
+po2xml  = $(XML2PO) --po-file=$(2) --language=$(3) --output=$(4) $(1) 2>&1 \
+          | sed -e '/Warning: image file .* not found./d'
+
+# HIDE FROM AUTOMAKE #define MAKE_XML_RULES
+# HIDE FROM AUTOMAKE #$(1)_XML_FILES = $$(XML_FILES:$$(xmldir)/%=$$(xmlpodir)/$(1)/%)
+# HIDE FROM AUTOMAKE #$$($(1)_XML_FILES): $$(xmlpodir)/$(1)/%.xml : $$(podir)/$(1)/%.po
+# HIDE FROM AUTOMAKE #	@f=$$@; d=$$$${f%/*}; test -d $$$$d || $$(mkdir_p) $$$$d
+# HIDE FROM AUTOMAKE #	@echo "[XML] $$@"
+# HIDE FROM AUTOMAKE #	@if test -s $$(@:$$(xmlpodir)/$(1)/%=$$(xmldir)/%); then \
+# HIDE FROM AUTOMAKE #		$$(call po2xml,$$(@:$$(xmlpodir)/$(1)/%=$$(xmldir)/%),$$<,$(1),$$@); \
+# HIDE FROM AUTOMAKE #	else \
+# HIDE FROM AUTOMAKE #		touch $$@; \
+# HIDE FROM AUTOMAKE #	fi
+# HIDE FROM AUTOMAKE ## This is indirectly used as HTML prerequisite:
+# HIDE FROM AUTOMAKE #$$(xmlpodir)/$(1): $$($(1)_XML_FILES)
+# HIDE FROM AUTOMAKE #	touch $$(xmlpodir)/$(1)
+# HIDE FROM AUTOMAKE ## Debugging
+# HIDE FROM AUTOMAKE #list-xmlfiles-$(1) list-xml-files-$(1) list-xml-$(1):
+# HIDE FROM AUTOMAKE #	@echo $$($(1)_XML_FILES)
+# HIDE FROM AUTOMAKE ## Targets suitable for command line
+# HIDE FROM AUTOMAKE #xml-$(1): $$($(1)_XML_FILES)
+# HIDE FROM AUTOMAKE #endef
+
+$(foreach LANG,$(PO_LANGS),$(eval $(call MAKE_XML_RULES,$(LANG))))
+
+# Special case: en
+en_XML_FILES = $(XML_FILES:$(xmldir)/%=$(xmlpodir)/en/%)
+$(en_XML_FILES): xmldir-en
+
+xmldir-en: $(xmlpodir)/en ;
+
+# TODO: make relative link rather than absolute link(?)
+$(xmlpodir)/en: $(XML_FILES)
+	$(cmd) target_dir=$$(cd $(srcdir)/$(xmldir) && pwd); \
+	link_dir=$(builddir)/$(xmlpodir); \
+	test -d $${link_dir} || $(fake) $(mkdir_p) $${link_dir}; \
+	test -d $${link_dir}/en || $(fake) $(ln_s) $${target_dir} $${link_dir}/en; \
+	touch $@
+
+
+# Targets suitable for command line
+# Special case: en
+xml-en: xmldir-en
+
+
 #### XML profiling
 
 # Note that "src/gimp.xml" must be the first prerequisite

Added: branches/xml2po-support/tools/migrate.sh
==============================================================================
--- (empty file)
+++ branches/xml2po-support/tools/migrate.sh	Sat Oct 18 12:08:43 2008
@@ -0,0 +1,79 @@
+#!/bin/bash
+# This file is part of the gimp-help-2 project and is
+# Copyright 2008, Ulf-D. Ehlert, Roman Joost
+#
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation; either version 2 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program; if not, write to the Free Software
+#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+
+srcdir="src"
+xmldir="xml"
+potdir="pot"
+podir="po"
+LINGUAS="de"
+SPLIT="/opt/python2.4/bin/python tools/split_xml_multi_lang.py"
+XML2PO="python tools/xml2po"	# patched version!!
+XMLLANG2EN="tools/xmllang2en.sh -v"
+
+echo "Creating en_US ..."
+$XMLLANG2EN --srcdir=$srcdir --dstdir=en_US
+
+echo "Splitting the source XML"
+time \
+find $srcdir -name .svn -prune -o -name '*.xml' -print |
+while read srcfile
+do
+    base=${srcfile%/*}
+    base=${base#$srcdir/}
+    $SPLIT --lang="$LINGUAS" --file="$srcfile" \
+           --dest="$xmldir"/'*'/"$base"/
+done
+echo
+
+srcdir=$xmldir/en
+echo
+
+
+echo "Creating POT files"
+time \
+find $srcdir -name '*.xml' |
+while read srcfile
+do
+    potfile=$potdir/${srcfile#$srcdir/}
+    potfile=${potfile%.xml}.pot
+    dest=${potfile%/*}
+    test -d "$dest" || mkdir -p "$dest"
+    echo >&2 $potfile
+    $XML2PO --output="$potfile" "$srcfile" 2>&1 | grep -vE 'image file .* not found'
+done
+echo
+
+
+echo "Creating PO files"
+time \
+find $srcdir -name '*.xml' |
+while read srcfile
+do
+    base=${srcfile#$srcdir/}
+    for lang in $LINGUAS; do
+        xmlfile=$xmldir/$lang/$base
+        pofile=${podir}/$lang/${base%.xml}.po
+        dest=${pofile%/*}
+        test -d "$dest" || mkdir -p "$dest"
+        echo >&2 $pofile
+        $XML2PO --language $lang --reuse=$xmlfile --output="$pofile" \
+                "$srcfile" 2>&1 | grep -vE 'image file .* not found'
+    done
+done
+echo

Added: branches/xml2po-support/tools/xmllang2en.sh
==============================================================================
--- (empty file)
+++ branches/xml2po-support/tools/xmllang2en.sh	Sat Oct 18 12:08:43 2008
@@ -0,0 +1,75 @@
+#!/bin/sh
+# This file is part of the gimp-help-2 project and is
+# Copyright 2008, Ulf-D. Ehlert
+#
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation; either version 2 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program; if not, write to the Free Software
+#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+srcdir="src"
+dstdir="xml"
+#srcfile=""
+verbose=''
+help=0
+stylesheet="stylesheets/profile.xsl"
+
+usage() {
+    exit_code="$1"
+    err_msg="$2"
+    test -n "$exit_code" || exit_code=0
+    test -n "$err_msg" && echo >&2 "$err_msg"
+    echo "Usage:"
+    echo "   ${0##*/} -h|--help"
+    echo "   ${0##*/} [OPTIONS]"
+    echo "Options:"
+    echo "   -s | --srcdir <source directory>"
+    echo "   -d | --dstdir <destination directory>"
+    exit $exit_code
+}
+
+options=`getopt -n xml2lang.sh --unquoted \
+         --longoptions "srcdir:,dstdir:,verbose,help" \
+	 --options "s:d:vh" -- "$@"` || usage 64
+set -- $options
+while [ -n "$1" ]; do
+    case "$1" in
+           -h|--help) usage;;
+        -v|--verbose) verbose='-v';;
+         -s|--srcdir) shift; srcdir="${1%/}";;
+         -d|--dstdir) shift; dstdir="${1%/}";;
+                  --) shift; break;;
+    esac
+    shift
+done
+test $# -eq 0 || usage 64 "Too many arguments: $@"
+
+test -d "$srcdir"     || usage 66 "Source directory \"$srcdir\" not found."
+test -d "$dstdir"     || usage 73 "Destination directory \"$dstdir\" not found."
+test -f "$stylesheet" || usage 66 "Stylesheet \"$stylesheet\" not found."
+
+find $srcdir -name '.svn' -prune -o -type d |
+while read src_dir
+do
+    dst_dir=${dstdir%/}/${src_dir#*$srcdir} 
+    test -d $dst_dir || mkdir $verbose -m 755 $dst_dir
+done
+
+find $srcdir -name '.svn' -prune -o -name '*.xml' -print |
+while read src_file
+do
+   test -n "$verbose" && echo $src_file
+   dst_file=$dstdir/${src_file#*$srcdir/} 
+   xsltproc --nonet --stringparam profile.lang en $stylesheet $src_file \
+   | sed -e '/^[ 	]*$/d' -e 's/^ *<sect[1-4][ >]/\n&/' \
+   | xmllint --nonet - > $dst_file
+done



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]