summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorJoey Hess <joeyh@debian.org>2005-10-07 19:51:38 +0000
committerJoey Hess <joeyh@debian.org>2005-10-07 19:51:38 +0000
commit1ea73eea5ecc6a8ed901316049259aee737ee554 (patch)
tree03a077f0b1b1548f3c806bd1c5795964fba0fb52 /scripts
downloadinstallation-guide-1ea73eea5ecc6a8ed901316049259aee737ee554.zip
move manual to top-level directory, split out of debian-installer package
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/cp-untrans39
-rwxr-xr-xscripts/create_po105
-rwxr-xr-xscripts/create_xml57
-rwxr-xr-xscripts/doc-check119
-rwxr-xr-xscripts/historic/2format19
-rwxr-xr-xscripts/historic/2xml7
-rw-r--r--scripts/historic/2xml290
-rw-r--r--scripts/historic/formatparasect16
-rw-r--r--scripts/historic/para110
-rwxr-xr-xscripts/historic/validate.sh22
-rw-r--r--scripts/mark_untranslated.awk114
-rwxr-xr-xscripts/merge_xml79
-rw-r--r--scripts/merge_xml.awk138
-rwxr-xr-xscripts/rev-check315
-rwxr-xr-xscripts/rev-update136
-rwxr-xr-xscripts/revert_pot15
-rwxr-xr-xscripts/set_untranslated39
-rwxr-xr-xscripts/update_po58
-rwxr-xr-xscripts/update_pot50
19 files changed, 1428 insertions, 0 deletions
diff --git a/scripts/cp-untrans b/scripts/cp-untrans
new file mode 100755
index 000000000..a41356097
--- /dev/null
+++ b/scripts/cp-untrans
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+# If doc-check shows outdated untranslated files, this script can
+# be used to copy the new English versions of these updated files
+# to your translation. The script will also run rev-update for you.
+
+# Note:
+# Run doc-check before you run this script.
+# It is recommended you use 'svn diff <language>' to check the
+# changes made by this script before committing.
+
+set -e
+
+if [ "$1" = "--help" ]; then
+ echo "Usage: $0 language"
+ exit 0
+fi
+
+language=${1:-pl}
+
+UFILES="$(./scripts/doc-check $language 2>/dev/null | \
+ egrep "^en\/.* \(untranslated\)$" | \
+ cut -d" " -f1 | cut -d"/" -f2- )"
+
+if [ -z "$UFILES" ] ; then
+ echo "No updated untranslated files for language '$language' found."
+ exit 0
+fi
+
+for UFILE in $UFILES; do
+ echo "Copying $UFILE from ./en to ./$language"
+ cp ./en/$UFILE ./$language/$UFILE
+done
+
+echo ""
+echo "Running rev-update..."
+./scripts/rev-update $language
+
+exit 0
diff --git a/scripts/create_po b/scripts/create_po
new file mode 100755
index 000000000..bd919a663
--- /dev/null
+++ b/scripts/create_po
@@ -0,0 +1,105 @@
+#!/bin/sh
+
+# This script is used for translations using .po files.
+# It creates the initial .po files for a language where there
+# already is a translation.
+
+# This script is meant to be used only once for the transition
+# from translating the .xml files to using .po files.
+
+if [ "$1" = "--help" ] ; then
+ echo "Usage: $0 <language>"
+ exit 0
+fi
+
+language=${1:-pl}
+
+[ -d ./$language/ ] || exit 1
+
+SCRIPTDIR="./scripts"
+WORKDIR="./integrated"
+SOURCEDIR="$WORKDIR/$language"
+PODIR="./po"
+
+if [ ! -d "$PODIR" ] ; then
+ echo "Error: directory $PODIR does not exist."
+ exit 1
+fi
+
+mkdir -p $PODIR/$language
+if [ -n "$PODIR/$language/*.po" ] ; then
+ echo "Deleting old PO files for '$language'..."
+ rm $PODIR/$language/*.po
+fi
+
+XMLLIST=$(find $SOURCEDIR -name "*.xml")
+
+echo "Creating PO files for language '$language'..."
+
+export NO_CREDITS=1 # Repress KDE specific credits
+ # Note: not yet supported by split2po
+
+for SOURCEXML in $XMLLIST ; do
+ SUBDIR=$(dirname $SOURCEXML | sed "s:$SOURCEDIR::" | sed "s:^/::")
+ XML=$(basename $SOURCEXML)
+ ORIGXML=$WORKDIR/en/$SUBDIR/$XML
+ PO=$PODIR/$language/$(basename $SOURCEXML .xml).po
+
+ echo "Converting translated $SUBDIR/$XML to PO file"
+ split2po $ORIGXML $SOURCEXML >$PO
+ if [ $? -ne 0 ] ; then
+ echo "** Error during conversion."
+ continue
+ fi
+done
+
+# Check the results
+echo ""
+echo "Checking whether translation matches corresponding POT file..."
+for PO in `find $PODIR/$language -name "*.po"` ; do
+ POT="$PODIR/pot/$(basename $PO .po).pot"
+ if [ -s $PO ] ; then
+ if [ -f $POT ] ; then
+ count_POT=$(egrep "^msgid " $POT | wc -l)
+ count_PO=$(egrep "^msgstr " $PO | wc -l)
+ if [ $count_PO != $count_POT ] ; then
+ echo "** Warning: translation for $PO has $count_PO strings, while original has $count_POT strings."
+ fi
+ # Missing strings: If a line with 'msgstr ""' is followed by an empty line.
+ count_missing_PO=$(egrep -A 1 "^msgstr \"\"$" $PO | egrep "^$" | wc -l)
+ if [ $count_missing_PO -ne 0 ] ; then
+ echo "** Warning: translation for $PO has $count_missing_PO missing strings."
+ fi
+ else
+ echo "** Error: corresponding POT file not found for $PO."
+ fi
+ else
+ echo "** Error: $PO is empty (conversion error)."
+ fi
+done
+echo "Done."
+
+# Checking for untranslated strings
+echo ""
+echo "Checking for untranslated strings in the PO files..."
+for PO in `find $PODIR/$language -name "*.po"` ; do
+ echo "Checking $PO..."
+ awk -f $SCRIPTDIR/mark_untranslated.awk $PO
+done
+
+echo ""
+echo "The conversion has finished successfully."
+echo "The PO files for $language have been saved in '$PODIR/$language'."
+echo ""
+echo "Please check all messages above very carefully."
+echo "If any translations are shown to have a different amount of strings than the original,"
+echo "you should probably correct the cause of this and run the conversion again."
+echo ""
+echo "Strings that are shown as 'looking untranslated', this could just be a string that"
+echo "does not need translation, but could also indicate parts of the original that really"
+echo "are untranslated but are not marked as such."
+echo "In that case, you can use the set_untranslated script to mark these strings as"
+echo "untranslated (enter 'set_untranslated --help' for usage)."
+
+rm /tmp/tmp.po.$$ /tmp/$$.xml &>/dev/null
+exit 0
diff --git a/scripts/create_xml b/scripts/create_xml
new file mode 100755
index 000000000..2b12dc5a4
--- /dev/null
+++ b/scripts/create_xml
@@ -0,0 +1,57 @@
+#!/bin/sh
+
+# This script is used for translations using .po files.
+# It creates .xml files from the translated .po files.
+
+if [ "$1" = "--help" ] ; then
+ echo "Usage: $0 <language>"
+ exit 0
+fi
+
+language=${1:-pl}
+
+BUILDDIR="./build"
+if [ -z "$PO_USEBUILD" ] ; then
+ WORKDIR="./integrated"
+ PODIR="./po"
+else
+ WORKDIR="$BUILDDIR/build.po"
+ PODIR="$BUILDDIR/build.po"
+fi
+SOURCEDIR="$WORKDIR/en"
+# Don't overwrite XML translations committed to SVN
+if [ -d "./$language/.svn" ] ; then
+ TARGETDIR="./$language.new"
+else
+ TARGETDIR="./$language"
+fi
+RET=0
+
+[ -d "$SOURCE" -o -d "$PODIR" ] || exit 1
+
+[ -d "$TARGETDIR" ] && rm -r $TARGETDIR
+
+echo "Creating XML files for language '$language':"
+for ORIGXML in `find $SOURCEDIR -name "*.xml"` ; do
+ BASEDIR=$(dirname $ORIGXML | sed "s:$SOURCEDIR::" | sed "s:^/::")
+ BASENAME=$(basename $ORIGXML .xml)
+ PO=$PODIR/$language/$BASENAME.po
+ XML=$TARGETDIR/$BASEDIR/$BASENAME.xml
+
+ mkdir -p $TARGETDIR/$BASEDIR
+
+ if [ -f $PO ] ; then
+ echo "- creating $BASENAME.xml"
+ po2xml $ORIGXML $PO > $XML
+ RC=$?
+ if [ $RC -ne 0 ] ; then
+ RET=$RC
+ echo "Error: error $RC while executing po2xml"
+ fi
+ else
+ echo "Warning: no PO file found for '$BASENAME'; copying English original"
+ cp $ORIGXML $TARGETDIR/$BASEDIR
+ fi
+done
+
+exit $RET
diff --git a/scripts/doc-check b/scripts/doc-check
new file mode 100755
index 000000000..83bea7ad9
--- /dev/null
+++ b/scripts/doc-check
@@ -0,0 +1,119 @@
+#!/usr/bin/perl -w
+
+# This script checks if the translations of the documents are up to date.
+# When called with "-d" option, it also prints what has changed in the
+# original since last translation.
+# If the "-r" option is used with the "-d" option, the diff will be taken
+# against the revision number specified with the -r option instead of
+# the latest revision of the English original.
+# When called with "-s" option, it also shows all files that are marked
+# untranslated.
+
+# SYNOPSIS:
+# ./doc-check [-d] [-r <revision>] [-s] [-v] [-V] [lang]
+#
+# (uses $lang set below if lang is not given on commandline)
+
+use Getopt::Std;
+use File::Find;
+$opt_d = $opt_r = $opt_s = $opt_v = $opt_V = 0;
+getopts('r:dsvV');
+# You may set this to your default language code
+$lang = shift || "pl";
+if ($opt_r and $opt_r !~ /[0-9]+/) {
+ warn "Please enter a revision number for parameter -r.\n";
+ exit 1
+}
+
+sub checkdiff
+{
+ my ($plfname, $enfname) = (@_);
+ my ($plrev, $enrev, $untrans) = getrev($plfname, $enfname);
+ $plrev and $enrev or return;
+ if ( "$plrev" ne "$enrev" ) {
+ if ($opt_d and $opt_r and $opt_r < $enrev) {
+ $enrev = $opt_r;
+ }
+ if ($untrans) {
+ print "$enfname : $plrev -> $enrev (untranslated)\n";
+ } else {
+ print "$enfname : $plrev -> $enrev\n";
+ }
+ if ($opt_d) {
+ my $s = "svn diff -r $plrev:$enrev $enfname";
+ warn "running $s:\n" if ($opt_V);
+ system($s);
+ }
+ } else {
+ if ($untrans && $opt_s) {
+ print "$plfname: untranslated\n";
+ }
+ }
+}
+
+sub getrev
+{
+ my ($plfname, $enfname) = (@_);
+ my ($plrev, $enrev, $untrans, $notconverted) = (0, 0, 0, 0);
+
+ warn "checking $plfname:\n" if $opt_v;
+ open FILE, $plfname or warn "$plfname: $!\n" and return;
+ while (<FILE>) {
+ if (/<!--\s*original version\D*([\d\.]+)\s*-->/) {
+ $plrev = $1;
+ last;
+ }
+ if (/<!--\s*original version\D*(\d+)\s*untranslated\s*-->/) {
+ $plrev = $1;
+ $untrans = 1;
+ last;
+ }
+ # Also check for revision comments of original documents
+ if (/<!--\s*\$Id: \S+ (\d+) /) {
+ $plrev = $1;
+ $notconverted = 1;
+ $untrans = 1;
+ last;
+ }
+ # Also support CVS style revision comments (depreciated)
+ if (/<!--\s*original document: en\/\S+, revision ([\d\.]+)\s*-->/) {
+ $plrev = $1;
+ last;
+ }
+ }
+ warn "checking $enfname:\n" if $opt_v;
+ open FILE, $enfname or warn "$enfname: $!\n" and return;
+ while (<FILE>) {
+ if (/\$Id: \S+ (\d+) /) {
+ $enrev = $1;
+ last;
+ }
+ # Also support CVS style revision comments (depreciated)
+ if (/\$Revision: (\d+) \$/) {
+ $enrev = $1;
+ last;
+ }
+ }
+ close FILE;
+ warn "failed to find revision for $plfname\n" unless $plrev;
+ warn "failed to find revision for $enfname\n" unless $enrev;
+ if ($notconverted) {
+ warn "$plfname: contains revision comment for original document\n";
+ warn " use 'rev-update' to convert\n";
+ }
+ return ($plrev, $enrev, $untrans);
+}
+
+sub process
+{
+ my $enfname = $File::Find::name;
+ return unless $enfname =~ m/\.xml$/;
+ my $plfname = $enfname;
+ $plfname =~ s,^en/,$lang/,;
+ checkdiff($plfname, $enfname);
+}
+File::Find::find({ wanted => \&process, no_chdir => 1 }, 'en');
+#checkdiff("build/install.$lang.xml", "build/install.en.xml");
+#checkdiff("release-notes.$lang.sgml","release-notes.sgml");
+#checkdiff("index.$lang.html.m4","index.en.html.m4");
+#checkdiff("dselect-beginner.$lang.sgml","dselect-beginner.sgml");
diff --git a/scripts/historic/2format b/scripts/historic/2format
new file mode 100755
index 000000000..2e3ca0d48
--- /dev/null
+++ b/scripts/historic/2format
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+tmp=`tempfile`
+
+while [ x"$1" != x ]; do
+ echo $1
+ cat $1 \
+ | tr -d '\t' \
+ | sed -f formatparasect \
+ | sed -f para1 \
+ | sed '/<\/para>/{:a;N;/<para>/!ba;s/<\/para>\n*<para>/<\/para><para>/;}' \
+ | cat -s > $tmp
+ cp $tmp $1
+ shift;
+done
+
+rm -f $tmp
+
+# | sed -f fix \ \ No newline at end of file
diff --git a/scripts/historic/2xml b/scripts/historic/2xml
new file mode 100755
index 000000000..a68d24a88
--- /dev/null
+++ b/scripts/historic/2xml
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+# feed it sgml and it coughs up xml, pretty rough though.
+
+sgmlnorm -mn $1 | sed -f 2xml2 > tmp.xml
+
+sed '/<\/para>/{:a;N;/<para>/!ba;s/<\/para>\n*<para>/<\/para><para>/;}' tmp.xml | less \ No newline at end of file
diff --git a/scripts/historic/2xml2 b/scripts/historic/2xml2
new file mode 100644
index 000000000..299725d0d
--- /dev/null
+++ b/scripts/historic/2xml2
@@ -0,0 +1,90 @@
+# a very limited debiandoc to xml converter
+# can also be used by itself on entity files,
+# for those uncomment next line:
+s/<item>/|/gi
+# ENTITY must upper case
+s|<!entity|<!ENTITY|gi
+# start links on a new line
+s|<URL ID=\"\([^\"]*\)\" NAME=\"\([^\"]*\)\">|\
+<ulink url="\1">\2</ulink>|gi
+# pick up halves of those that got wrapped to different lines
+s|<URL ID=\"\([^\"]*\)\"|\
+<ulink url="\1">|gi
+s|<URL|<ulink|gi
+s|^ID=\"\([^\"]*\)\" NAME=\"\([^\"]*\)\">|url="\1">\2</ulink>|gi
+s|^NAME=\"\([^\"]*\)\">|\1</ulink>|gi
+# ID= at the start of a line can also be an orphan ref
+s|^ID=\"\(\&url[^\"]*\)\"|url="\1"></ulink>|gi
+s|<REF ID=\"\([^\"]*\)\">|<xref linkend="\1"></xref>|gi
+s|<^ID=\"\([^\"]*\)\">|linkend="\1"></xref>|gi
+s|<REF|<xref|gi
+s|<P>|<para>|gi
+s|</P>|</para>|gi
+s|HEADING>|title>|gi
+# An extra line is helpful when replacing with 2 tags
+s|<ITEM>|<listitem><para>\
+|gi
+s|</ITEM>|\
+</para></listitem>|gi
+s|<EM>\([^<]*\)</EM>|<emphasis>\1</emphasis>|gi
+s|<EM>|<emphasis>|gi
+s|</EM>|</emphasis>|gi
+s|ENUMLIST>|orderedlist>|gi
+s|TAGLIST>|variablelist>|gi
+s|<TAG>|<varentry><term>\
+|gi
+s|</TAG>|</term>|gi
+s|<LIST COMPACT>|<itemizedlist>|gi
+s|<LIST>|<itemizedlist>|gi
+s|</LIST>|</itemizedlist>|gi
+s|FILE>|filename>|gi
+s|CHAPT>|chapter>|gi
+s|CHAPT ID=|chapter id=|gi
+# xml has no plain <sect>, must be numbered
+# so move each one up a level
+s|SECT3>|sect4>|gi
+s|SECT2>|sect3>|gi
+s|SECT1>|sect2>|gi
+s|SECT>|sect1>|gi
+s|SECT3 ID=|sect4 id=|gi
+s|SECT2 ID=|sect3 id=|gi
+s|SECT1 ID=|sect2 id=|gi
+s|SECT ID=|sect1 id=|gi
+# locate sect's with text immediately following, insert <title>
+s|\(<sect[^>]*>\)\([^<>]\+$\)|\1<title>\2</title>|i
+# prgn could be <application>, but use <command> as default
+s|PRGN>|command>|gi
+# our <example>s don't have headings, use <informalexample>
+s|<EXAMPLE>|<informalexample><screen>\
+|gi
+s|</EXAMPLE>|\
+</screen></informalexample>|gi
+s|VAR>|replaceable>|gi
+# <tt> has been used for many purposes, but it _should_ be <userinput>
+s|TT>|userinput>|gi
+# no <package> allowed, substitute <classname> for now
+s|PACKAGE>|classname>|g
+# just change the case
+s|FOOTNOTE>|footnote>|gi
+#
+# formatting stuff
+s|&#13;|\
+\
+|g
+# all <para> to left margin on next line
+s|^ *\(<para>.*\)|\
+\1|
+s|^ *\(</para>.*\)|\1|
+# sect's on next line, appropriate indent
+s|^ *\(</*sect1.*\)|\
+ \1|
+s|^ *\(</*sect2.*\)|\
+ \1|
+s|^ *\(</*sect3.*\)|\
+ \1|
+s|^ *\(</*sect4.*\)|\
+ \1|
+
+
+
+
diff --git a/scripts/historic/formatparasect b/scripts/historic/formatparasect
new file mode 100644
index 000000000..16694297b
--- /dev/null
+++ b/scripts/historic/formatparasect
@@ -0,0 +1,16 @@
+s|&#13;|\
+\
+|g
+# all <para> to left margin on next line
+s|^ *\(<para>.*\)|\
+\1|
+s|^ *\(</para>.*\)|\1|
+# sect's on next line, appropriate indent
+s|^ *\(</*sect1.*\)|\
+ \1|
+s|^ *\(</*sect2.*\)|\
+ \1|
+s|^ *\(</*sect3.*\)|\
+ \1|
+s|^ *\(</*sect4.*\)|\
+ \1|
diff --git a/scripts/historic/para1 b/scripts/historic/para1
new file mode 100644
index 000000000..4342261b7
--- /dev/null
+++ b/scripts/historic/para1
@@ -0,0 +1,10 @@
+/<para>/,/[[:alnum:]]/s/<para>\n*/<para>\
+\
+/
+/[[:alnum:].:]/,/<\/para>/s/\n*<\/para>/\
+\
+<\/para>/
+
+
+
+
diff --git a/scripts/historic/validate.sh b/scripts/historic/validate.sh
new file mode 100755
index 000000000..bdb09989a
--- /dev/null
+++ b/scripts/historic/validate.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+catalog=/usr/share/sgml/docbook/dtd/xml/4.2/catalog
+xmldcl=/usr/share/sgml/declaration/xml.dcl
+err=`tempfile`
+
+if grep -q '^<!DOCTYPE' $1; then
+ nsgmls -s -c $catalog $xmldcl $1 2> $err
+else
+ temp=`tempfile`
+ topdir=`dirname $0`
+ root=`sed -e '0,/<[a-z]/!d' $1 | sed -e '$!d' | sed -e 's/<\([a-z][a-zA-Z0-9]*\).*/\1/'`
+ cat > $temp <<EOT
+<!DOCTYPE $root PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "docbookx.dtd"
+[<!ENTITY % entities SYSTEM "entities.ent"> %entities;]>
+EOT
+ cat $1 >> $temp
+ nsgmls -s -D$topdir -c $catalog $xmldcl $temp 2> $err
+ rm -f $temp
+fi
+
+less $err \ No newline at end of file
diff --git a/scripts/mark_untranslated.awk b/scripts/mark_untranslated.awk
new file mode 100644
index 000000000..63608197f
--- /dev/null
+++ b/scripts/mark_untranslated.awk
@@ -0,0 +1,114 @@
+BEGIN {
+ STRLINE = ""
+ TRANS_STATUS = 9
+
+ if (RANGE != "") {
+ # Check input range
+ if (match(RANGE, /^[0-9]+(:[0-9]+)?$/) == 1) {
+ TPOS = index(RANGE, ":")
+ if (TPOS > 0) {
+ RANGE_START = strtonum(substr(RANGE, 1, TPOS - 1))
+ RANGE_END = strtonum(substr(RANGE, TPOS + 1, length(RANGE)))
+ } else {
+ RANGE_START = strtonum(RANGE)
+ RANGE_END = strtonum(RANGE)
+ }
+ print "** Untranslating messages in range from " RANGE_START " to " RANGE_END "." >"/dev/stderr"
+ } else {
+ print "Range should be in format '<number>' or '<start>:<end>'." >"/dev/stderr"
+ exit 1
+ }
+ }
+}
+
+/^#: / {
+ line = $0
+ gsub(/^#: [^:]*:/, "", line)
+ TPOS = index(line, ", ")
+ if (STRLINE == "") {
+ STRLINE_FIRST = line
+ }
+ STRLINE_PREV = STRLINE
+ if (TPOS == 0) {
+ STRLINE = line
+ } else {
+ STRLINE = substr(line, 1, TPOS - 1)
+ }
+}
+
+/^msgid / {
+ line = $0
+ gsub(/^msgid /, "", line)
+ MSGID = line
+}
+
+/^msgstr / {
+ line = $0
+ gsub(/^msgstr /, "", line)
+ MSGSTR = line
+
+ if (STRLINE != "") {
+ if (MSGID == MSGSTR) {
+ IS_TRANSLATED = 0
+ } else {
+ IS_TRANSLATED = 1
+ }
+
+ if (RANGE != "" && STRLINE >= RANGE_START && STRLINE <= RANGE_END) {
+ if (IS_TRANSLATED == 1) {
+ print "** String " STRLINE " looks translated, leaving unchanged!" >"/dev/stderr"
+ } else {
+ untranslate()
+ }
+ }
+
+ if (TRANS_STATUS == 9) {
+ TRANS_STATUS = IS_TRANSLATED
+ if (IS_TRANSLATED == 0) {
+ UNTRANS_START = STRLINE
+ }
+ } else {
+ if (TRANS_STATUS == 0 && IS_TRANSLATED == 1) {
+ # The previous strings were untranslated but this one is
+ if (STRLINE_PREV == UNTRANS_START) {
+ print "** String looks untranslated: " STRLINE_PREV >"/dev/stderr"
+ } else {
+ print "** Strings look untranslated: " UNTRANS_START " - " STRLINE_PREV >"/dev/stderr"
+ }
+ TRANS_STATUS = IS_TRANSLATED
+ }
+ if (TRANS_STATUS == 1 && IS_TRANSLATED == 0) {
+ TRANS_STATUS = IS_TRANSLATED
+ UNTRANS_START = STRLINE
+ }
+ }
+ }
+}
+
+{
+ # For all lines: if untranslating, write line to $filename.untrans
+ if (RANGE != "") {
+ print $0
+ }
+}
+
+END {
+ if (TRANS_STATUS == 0) {
+ if (UNTRANS_START == STRLINE_FIRST) {
+ print "** File looks untranslated (" UNTRANS_START " - " STRLINE ")" >"/dev/stderr"
+ } else {
+ print "** Strings look untranslated: " UNTRANS_START " - " STRLINE >"/dev/stderr"
+ }
+ }
+}
+
+function untranslate() {
+ print "** Untranslating string " STRLINE >"/dev/stderr"
+ print "msgstr \"\""
+ getline
+ # Skip other lines belonging to this msgstr
+ while (match($0, /^[[:space:]]*"/) > 0) {
+ getline
+ }
+ IS_TRANSLATED = 1
+}
diff --git a/scripts/merge_xml b/scripts/merge_xml
new file mode 100755
index 000000000..561a9a734
--- /dev/null
+++ b/scripts/merge_xml
@@ -0,0 +1,79 @@
+#!/bin/bash
+
+# This script is used for translations using .po files.
+# It merges .xml files per chapter (or appendix).
+# The reason files are merged is that individual .xml files
+# are often not well-formed xml.
+
+if [ "$1" = "--help" ]; then
+ echo "Usage: $0 lang"
+ exit 0
+fi
+
+language=${1:-pl}
+
+SCRIPTDIR="./scripts"
+BUILDDIR="./build"
+if [ -z "$PO_USEBUILD" ] ; then
+ WORKDIR="./integrated"
+else
+ WORKDIR="$BUILDDIR/build.po"
+fi
+LANGDIR="./$language"
+
+[ -d $LANGDIR ] || exit 1
+
+TEMPDIR=/tmp/merge_xml.$$
+LOG=$TEMPDIR/merge_xml.$language.log
+[ -d $TEMPDIR ] || mkdir $TEMPDIR
+
+#<!ENTITY bookinfo.xml SYSTEM "en/bookinfo.xml">
+OLD_IFS=$IFS
+IFS="
+"
+:>$TEMPDIR/entlist
+echo "Building list of entities..."
+for ENT in `grep "<!ENTITY" $BUILDDIR/templates/docstruct.ent` ; do
+ echo -n "$(echo $ENT | sed "s/.*ENTITY\ *//" | sed "s/\ *SYSTEM.*$//")" >>$TEMPDIR/entlist
+ echo -n ":" >>$TEMPDIR/entlist
+ echo "$(echo $ENT | sed "s/.*SYSTEM\ *\"##SRCPATH##\///" | sed "s/\">//")" >>$TEMPDIR/entlist
+
+done
+IFS=$OLD_IFS
+
+# Make sure that all files are in UTF-8 first
+echo "Converting XML files to UTF-8..."
+echo "Converting XML files to UTF-8..." >>$LOG
+for FILE in `find $LANGDIR -name "*.xml"` ; do
+ SUBDIR=$(dirname $FILE | sed "s:$LANGDIR::");
+ XML=$(basename $FILE)
+ mkdir -p $TEMPDIR/in/$SUBDIR
+ REGEXP="^<?.*encoding="
+ if egrep -q $REGEXP $FILE ; then
+ echo "Encoded : $FILE" >>$LOG
+ ENC=$(egrep $REGEXP $FILE | sed "s/.*xml.*encoding=\"//" | sed "s/\"?>//")
+ iconv -f $ENC -t utf-8 $FILE | egrep -v $REGEXP >$TEMPDIR/in/$SUBDIR/$XML
+ else
+ echo "Not encoded: $FILE" >>$LOG
+ cp $FILE $TEMPDIR/in/$SUBDIR/$XML
+ fi
+done
+echo "" >>$LOG
+
+# Include lower level xml-files for all the main level xml-files
+echo "Merging XML files per 'chapter'..."
+echo "Merging XML files per 'chapter'..." >>$LOG
+gawk -v WORKDIR="$TEMPDIR" -v LOG=$LOG -v ENTLIST="$TEMPDIR/entlist" \
+ -f $SCRIPTDIR/merge_xml.awk $BUILDDIR/templates/install.xml.template
+
+# Copy the results to their proper location
+TARGET="$WORKDIR/$language"
+if [ -d $TARGET ]; then
+ rm -r $TARGET
+fi
+mkdir -p $TARGET
+cp -r $TEMPDIR/out/* $TARGET
+cp $LOG $TARGET
+
+rm -r $TEMPDIR
+exit 0
diff --git a/scripts/merge_xml.awk b/scripts/merge_xml.awk
new file mode 100644
index 000000000..b0f590690
--- /dev/null
+++ b/scripts/merge_xml.awk
@@ -0,0 +1,138 @@
+# The script keeps track of some special situations:
+# - 'tags' in comments are not handled well by poxml tools, so these
+# are removed
+# - references within comments should not be processed, so we keep
+# a count of opening and closing of comments
+
+BEGIN {
+ main_count = 1
+
+ # Let's first build an array with all the entities (xml files)
+ while (getline <ENTLIST) {
+ delim = index($0, ":")
+ i = substr($0, 1, delim - 1)
+
+ fname = substr($0, delim + 1, length($0) - delim)
+ # Trim any leading and trailing space of filenames
+ gsub(/^[[:space:]]*/, "", fname)
+ gsub(/[[:space:]]*$/, "", fname)
+
+ ent [i] = fname
+ included [i] = 0
+ }
+}
+
+{
+ # In the main loop we only want to process entities that are refered to
+ line = $0
+ if (match (line, /^[[:space:]]*&.*\.xml;[[:space:]]*(<\!--.*-->[[:space:]]*|)*$/) > 0) {
+ process_file(line, "main")
+ }
+}
+
+END {
+ print "" >>LOG
+ print "The following defined entities (from docstruct) were NOT processed:" >>LOG
+ for (entname in ent) {
+ if (included [entname] == 0) {
+ print " " entname >>LOG
+ }
+ }
+}
+
+function process_file(entline, level, fname, tfname) {
+ entname = get_entname(entline)
+ if (entname in ent) {
+ fname = ent [entname]
+ print "Processing: " fname >>LOG
+ INFILE = WORKDIR "/in/" fname
+
+ if (level == "main") {
+ main_count += 1
+
+ # Change at highest level: change to a new output file
+ OUTFILE = WORKDIR "/out/" fname
+ OUTDIR = OUTFILE
+ gsub(/\/[^\/]*$/, "/", OUTDIR) # strip filename
+ system("mkdir -p " OUTDIR) # create directory
+ } else {
+ print "" >>OUTFILE
+ }
+
+ if (level == "sub" && included [entname] != 0 && included [entname] < main_count) {
+ print "** Warning: entity '" entname "'was also included in another file." >>LOG
+ }
+ if (level == "main") {
+ included [entname] = 1
+ } else {
+ included [entname] = main_count
+ }
+ parse_file(INFILE, fname)
+
+ } else {
+ print "** Entity " entname " not found and will be skipped!" >>LOG
+ print entline >>OUTFILE
+ }
+}
+
+function parse_file(PARSEFILE, FNAME, fname, nwline, comment_count) {
+ comment_count = 0
+ fname = FNAME
+
+ # Test whether file exists
+ getline <PARSEFILE
+ if (ERRNO != 0) {
+ print "** Error: file '" PARSEFILE "' does not exist!" >>LOG
+ return
+ }
+
+ print "<!-- Start of file " fname " -->" >>OUTFILE
+ while (getline <PARSEFILE) {
+ nwline = $0
+
+ # Update the count of 'open' comments
+ comment_count += count_comments(nwline)
+
+ if (match(nwline, /^[[:space:]]*&.*\.xml;[[:space:]]*(<\!--.*-->[[:space:]]*|)*$/) > 0) {
+ # If we find another entity reference, we process that file recursively
+ # But not if the reference is within a comment
+ if (comment_count != 0) {
+ print "** Skipping entity reference '" nwline "' found in comment!" >>LOG
+ } else {
+ process_file(nwline, "sub")
+ }
+ } else {
+ # Else we just print the line
+ if (match(nwline, /<\!--.*<.*>.*<.*>.*-->/) > 0) {
+ # Comments containing "<...> ... <...>" are not handled correctly
+ # by xml2pot and split2po, so we skip lines like that
+ # Note: this is a workaround for a bug in the tools:
+ # http://bugs.kde.org/show_bug.cgi?id=90294
+ print "** Comment deleted in line '" nwline "'" >>LOG
+ gsub(/<\!--.*<.*>.*<.*>.*-->/, "", nwline)
+ }
+ print nwline >>OUTFILE
+ }
+ }
+ if (comment_count != 0) {
+ print "** Comment count is not zero at end of file: " comment_count >>LOG
+ }
+ print "<!-- End of file " fname " -->" >>OUTFILE
+ close(PARSEFILE)
+}
+
+function get_entname(entline, ename) {
+ # Parse the name of the entity out of the entity reference
+ ename = entline
+ gsub(/^[[:space:]]*&/, "", ename)
+ gsub(/;.*$/, "", ename)
+ return ename
+}
+
+function count_comments(inline, tmpline, count) {
+ # 'abuse' gsub to count them
+ tmpline = inline
+ count += gsub(/<\!--/, "", tmpline)
+ count -= gsub(/-->/, "", tmpline)
+ return count
+}
diff --git a/scripts/rev-check b/scripts/rev-check
new file mode 100755
index 000000000..05b092afd
--- /dev/null
+++ b/scripts/rev-check
@@ -0,0 +1,315 @@
+#!/bin/bash
+
+# This script will allow to check for changes in the original
+# English docs for languages that use po files for translation.
+# It combines the function of the old doc-check and rev-update
+# scripts (resulting in the name rev-check :-)
+
+# For each language, the last three revisions for which the
+# translation has been updated are saved in a file.
+# The current revision of English documents is checked against
+# the most recent revisions in this file.
+
+lang=""
+default_lang="nl"
+file=""
+
+print_usage () {
+ echo "Usage: $(basename $0) [options] [language] [file]"
+ echo " TODO: explanation of syntax and options"
+}
+
+print_usage_err () {
+ print_usage
+ exit 1
+}
+
+check_parm_lang () {
+ # Check that directory exists won't work after conversion to po...
+ if [ -d "$1" ] ; then
+ lang="$1"
+ else
+ echo "Info: no valid language specified, using default '$default_lang'"
+ if [ -d "$default_lang" ] ; then
+ lang="$default_lang"
+ return 1
+ else
+ echo "Error: directory for language '$default_lang' not found"
+ print_usage_err
+ fi
+ fi
+ return 0
+}
+
+check_parm_file () {
+ file=$(echo "$1" | sed "s:^./::" | sed "s:^en/::")
+ if [ ! -f "./en/$file" ] ; then
+ echo "Error: file '$file' does not exist"
+ return 1
+ fi
+ return 0
+}
+
+parse_opts () {
+ command="check"
+ do_diff=""
+ do_all=""
+ parm_count=0
+
+ for opt in $@; do
+ case "$opt" in
+ --update|-u)
+ [ $command = "check" ] || print_usage_err
+ command="update"
+ ;;
+ --add|-a)
+ [ $command = "check" ] || print_usage_err
+ command="add"
+ ;;
+ --diff|-d)
+ do_diff=1
+ ;;
+ --all|-A)
+ do_all=1
+ ;;
+ --convert)
+ [ $command = "check" ] || print_usage_err
+ command="convert"
+ ;;
+ --help|-h)
+ print_usage
+ exit 0
+ ;;
+ -*)
+ print_usage_err
+ ;;
+ *)
+ parm_count=$(($parm_count + 1))
+ if [ $parm_count -eq 1 ] ; then
+ check_parm_lang "$opt"
+ [ $? -ne 0 ] && parm_count=$(($parm_count + 1))
+ fi
+ if [ $parm_count -eq 2 ] ; then
+ check_parm_file "$opt"
+ [ $? -ne 0 ] && print_usage_err
+ fi
+
+ [ $parm_count -gt 2 ] && print_usage_err
+ ;;
+ esac
+
+ done
+
+ [ -z "$lang" ] && check_parm_lang "<none>"
+
+ case $command in
+ check)
+ [ "$do_all" ] && print_usage_err
+ ;;
+ convert)
+ [ "$do_all" ] && print_usage_err
+ if [ -n "$file" ] ; then
+ echo "Error: parameter [file] not allowed with --$command option"
+ print_usage_err
+ fi
+ if [ ! -d $lang ] ; then
+ echo "Error: directory for language '$lang' not found"
+ exit 1
+ fi
+ ;;
+ add|update)
+ if [ ! "$do_all" ] && [ -z "$file" ] ; then
+ echo "Error: parameter [file] missing, to update all files add --all option"
+ print_usage_err
+ fi
+ if [ "$do_all" ] && [ ! -z "$file" ] ; then
+ echo "Error: parameter [file] not allowed with --all option"
+ print_usage_err
+ fi
+ ;;
+ esac
+}
+
+get_rev () {
+ local REV
+ REV="$(egrep '^<\!--[[:space:]]*\$Id:' ./en/$1 | \
+ sed 's/^.*$Id:[[:space:]]*//' | cut -d " " -f 2)"
+ if [ -z "$REV" ] ; then
+ echo "Error: could not determine revision of './en/$1'"
+ return 1
+ fi
+ echo "$REV"
+ return 0
+}
+
+get_trev () {
+ local TREV
+ [ "$2" = "all" ] && fields="2-" || fields="2"
+ TREV="$(egrep "^$1" $rev_file | cut -f $fields)"
+ if [ -z "$TREV" ] ; then
+ return 1
+ fi
+ echo "$TREV"
+ return 0
+}
+
+print_diff () {
+ local TREV
+ local TREV_PREV=""
+ for TREV in $2; do
+ [ "$TREV_PREV" ] && echo "Diff against revision $TREV_PREV failed, trying next oldest: $TREV"
+ svn diff -r $TREV:$3 ./en/$1
+ [ $? -eq 0 ] && break
+ TREV_PREV=$TREV
+ done
+}
+
+check_one () {
+ REV=$(get_rev $1)
+ [ $? -ne 0 ] && return 9
+ TREV=$(get_trev $1)
+ if [ $? -ne 0 ] ; then
+ echo "$1: N/A -> $REV"
+ return 2
+ fi
+
+ local RET=0
+ if [ ! "$TREV" = "$REV" ] ; then
+ RET=1
+ echo "$1: $TREV -> $REV"
+ if [ "$do_diff" ] ; then
+ print_diff $1 "$(get_trev $1 all)" $REV
+ echo
+ fi
+ fi
+ return $RET
+}
+
+do_check () {
+ local RESULT=0
+ if [ -n "$file" ] ; then
+ check_one $file
+ RESULT=$?
+ else
+ for file in $(find ./en/ -name "*.xml" | sed "s:^./::" | sed "s:^en/::"); do
+ check_one $file
+ [ $? -eq 1 ] && RESULT=1
+ done
+ fi
+ [ $RESULT -ne 1 ] && echo "No updates found"
+}
+
+update_revdata () {
+ cp $rev_file $rev_file~
+ egrep -v "^$1" $rev_file~ >$rev_file
+
+ # Keep the last three revisions in $rev_file
+ local REV
+ local counter=1
+ echo -n "$1" >>$rev_file
+ for REV in $2; do
+ echo -en "\t$REV" >>$rev_file
+ counter=$(($counter + 1))
+ [ $counter -gt 3 ] && break
+ done
+ echo >>$rev_file
+ echo " Revision updated"
+}
+
+update_one () {
+ local file=$1
+ check_one $file
+ if [ $? -eq 1 ] ; then
+ update_revdata $1 "$REV $(get_trev $1 all)"
+ fi
+}
+
+do_update () {
+ if [ -n "$file" ] ; then
+ update_one $file
+ else
+ for file in $(find ./en/ -name "*.xml" | sed "s:^./::" | sed "s:^en/::"); do
+ update_one $file
+ done
+ fi
+}
+
+do_add_one () {
+ if egrep "^$file" $rev_file ; then
+ echo "Error: revision data already has '$file'"
+ exit 1
+ fi
+
+ REV=$(get_rev $1)
+ [ $? -ne 0 ] && exit 1
+
+ echo -e "$file\t$REV" >>$rev_file
+}
+
+do_add_all () {
+ for file in $(find ./en/ -name "*.xml" | sed "s:^./::" | sed "s:^en/::"); do
+ if [ -f $rev_file ] && egrep "^$file" $rev_file ; then
+ continue
+ fi
+
+ REV=$(get_rev $file)
+ [ $? -ne 0 ] && continue
+
+ echo -e "$file\t$REV" >>$rev_file
+ echo "Added '$file' at $REV"
+ done
+}
+
+do_convert () {
+ for file in $(find ./en/ -name "*.xml" | sed "s:^./::" | sed "s:^en/::"); do
+ if [ -f ./$lang/$file ]; then
+ REV="$(egrep '^<\!--[[:space:]]*original version:' ./$lang/$file | \
+ sed 's/^.*original version:[[:space:]]*//' | cut -d " " -f 1)"
+ if [ -z "$REV" ] ; then
+ echo "Warning: no revision comment found for './$lang/$file'"
+ else
+ echo -e "$file\t$REV" >>$rev_file
+ fi
+ else
+ echo "Warning: file './$lang/$file' not found"
+ fi
+ done
+}
+
+
+## MAINLINE
+
+[ -d ./po/revdata ] || exit 1
+
+parse_opts "$@"
+rev_file=./po/revdata/$lang.dat
+
+if [ "$command" = "convert" ] || \
+ ( [ "$command" = "add" ] && [ "$do_all" ] ) ; then
+ if [ -s $rev_file ] ; then
+ echo "Error: file with revision data already exists"
+ exit 1
+ fi
+else
+ if [ ! -s $rev_file ] ; then
+ echo "Error: file with revision data does not exist"
+ exit 1
+ fi
+fi
+
+case $command in
+ check)
+ do_check
+ ;;
+ update)
+ do_update
+ ;;
+ add)
+ [ "$do_all" ] && do_add_all || do_add_one
+ ;;
+ convert)
+ do_convert
+ ;;
+esac
+
+exit 0
diff --git a/scripts/rev-update b/scripts/rev-update
new file mode 100755
index 000000000..8d1d16f8b
--- /dev/null
+++ b/scripts/rev-update
@@ -0,0 +1,136 @@
+#!/usr/bin/perl -w
+
+# This script converts and updates revision comments in translations.
+# It will automatically replace revision comments for 'original documents'
+# with revision comments for 'translated documents'.
+# When called with "-u" option, it will also update the revision for the
+# translated document to the revision number in the original document.
+# This script only supports SVN style revision marks.
+
+# Note: only use the "-u" option after you have made sure there are no
+# changes in content for the listed documents.
+
+# SYNOPSIS:
+# ./rev-update [-u] [-v] [lang]
+#
+# (uses $lang set below if lang is not given on commandline)
+
+use Getopt::Std;
+use File::Find;
+$opt_u = $opt_v = 0;
+getopts('uvV');
+# You may set this to your default language code
+$lang = shift || "pl";
+
+sub convert
+{
+ my ($plfname, $plrev) = (@_);
+ my $transtext = '';
+ open (FILE, "< $plfname");
+ while (<FILE>) {
+ if (/<!--\s*\$Id: \S+ (\d+) /) {
+ s/(<!--)(.*)(-->)/$1 original version: $plrev untranslated $3/;
+ }
+ $transtext .= $_;
+ }
+ close (FILE);
+ warn "Writing $plfname\n" if $opt_v;
+ open (FILE, "> $plfname");
+ print FILE $transtext;
+ close (FILE);
+}
+
+sub update
+{
+ my ($plfname, $plrev, $enrev) = (@_);
+ my $transtext = '';
+ open (FILE, "< $plfname");
+ while (<FILE>) {
+ if (/<!--\s*original version/) {
+ s/(<!--.*\s)($plrev)(\s.*-->)/$1$enrev$3/;
+ }
+ $transtext .= $_;
+ }
+ close (FILE);
+ warn "Writing $plfname\n" if $opt_v;
+ open (FILE, "> $plfname");
+ print FILE $transtext;
+ close (FILE);
+}
+
+sub getrev
+{
+ my ($plfname, $enfname) = (@_);
+ my ($plrev, $enrev) = (0, 0);
+ my ($notconverted, $untrans) = (0, 0);
+
+ warn "checking $plfname:\n" if $opt_v;
+ open FILE, $plfname or warn "$plfname: $!\n" and return;
+ while (<FILE>) {
+ if (/<!--\s*original version\D*(\d+)\s*-->/) {
+ $plrev = $1;
+ last;
+ }
+ if (/<!--\s*original version\D*(\d+)\s*untranslated\s*-->/) {
+ $plrev = $1;
+ $untrans = 1;
+ last;
+ }
+ # Also check for revision comments of original documents
+ if (/<!--\s*\$Id: \S+ (\d+) /) {
+ $plrev = $1;
+ $notconverted = 1;
+ $untrans = 1;
+ last;
+ }
+ }
+ warn "checking $enfname:\n" if $opt_v;
+ open FILE, $enfname or warn "$enfname: $!\n" and return;
+ while (<FILE>) {
+ if (/<!--\s*\$Id: \S+ (\d+) /) {
+ $enrev = $1;
+ last;
+ }
+ }
+ close FILE;
+ warn "failed to find revision for $plfname\n" unless $plrev;
+ warn "failed to find revision for $enfname\n" unless $enrev;
+ if ($notconverted) {
+ warn "$plfname: converting revision comment\n";
+ warn " document marked 'untranslated'\n";
+ convert($plfname, $plrev);
+ }
+ return ($plrev, $enrev, $untrans);
+}
+
+sub checkrev
+{
+ my ($plfname, $enfname) = (@_);
+ my ($plrev, $enrev, $untrans) = getrev($plfname, $enfname);
+ $plrev and $enrev or return;
+ if ( "$plrev" ne "$enrev" ) {
+ if ($untrans) {
+ print "$enfname : $plrev -> $enrev (untranslated)\n";
+ } else {
+ print "$enfname : $plrev -> $enrev\n";
+ }
+ if ($opt_u) {
+ update($plfname, $plrev, $enrev);
+ print "$plfname : revision updated\n";
+ }
+ }
+}
+
+sub process
+{
+ my $enfname = $File::Find::name;
+ return unless $enfname =~ m/\.xml$/;
+ my $plfname = $enfname;
+ $plfname =~ s,^en/,$lang/,;
+ checkrev($plfname, $enfname);
+}
+File::Find::find({ wanted => \&process, no_chdir => 1 }, 'en');
+#checkrev("build/install.$lang.xml", "build/install.en.xml");
+#checkdiff("release-notes.$lang.sgml","release-notes.sgml");
+#checkdiff("index.$lang.html.m4","index.en.html.m4");
+#checkdiff("dselect-beginner.$lang.sgml","dselect-beginner.sgml");
diff --git a/scripts/revert_pot b/scripts/revert_pot
new file mode 100755
index 000000000..a46996ed6
--- /dev/null
+++ b/scripts/revert_pot
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Reverts local changes in POT files.
+# Translators are normally not supposed to commit any changes to POT
+# files after they've run update_pot.
+
+POTDIR="./po/pot"
+
+[ -d $POTDIR ] || exit 1
+
+echo "Reverting modified POT files (if any)..."
+for POT in $(svn st $POTDIR | grep "^M" | sed "s/^M[[:space:]]*//"); do
+ svn revert $POT
+done
+echo "done."
diff --git a/scripts/set_untranslated b/scripts/set_untranslated
new file mode 100755
index 000000000..44a6ebf7f
--- /dev/null
+++ b/scripts/set_untranslated
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+# This script is used for translations using .po files.
+
+# This script is meant to be used only once for the transition
+# from translating the .xml files to using .po files.
+
+basedir="$(cd "$(dirname $0)"; pwd)"
+POFILE=$2
+TEMPFILE="/tmp/set_untranslated.$$"
+
+print_usage () {
+ echo "Usage: $0 <range> <filename>"
+ echo " where <range> is <number> or <start:end>"
+}
+
+if [ "$1" = "--help" ] ; then
+ print_usage
+ exit 0
+fi
+if [ $# -ne 2 ] || [ ! -f $POFILE ] ; then
+ print_usage
+ exit 1
+fi
+
+
+gawk -f $basedir/mark_untranslated.awk -v RANGE="$1" $POFILE >$TEMPFILE
+if [ $? -eq 0 ] ; then
+ cp $POFILE $POFILE.sv
+ cp $TEMPFILE $POFILE
+
+ echo ""
+ echo "NOTE"
+ echo "The original file has been replaced!"
+ echo "A copy of the original file was saved as '$POFILE.sv'."
+fi
+
+rm $TEMPFILE
+exit 0
diff --git a/scripts/update_po b/scripts/update_po
new file mode 100755
index 000000000..9432c7659
--- /dev/null
+++ b/scripts/update_po
@@ -0,0 +1,58 @@
+#!/bin/sh
+
+# This script is used for translations using .po files.
+# It updates .po files after changes in the original English
+# .xml files.
+# The scripts 'merge_xml' and 'update-pot' should be run before
+# this script!
+
+if [ "$1" = "--help" ] ; then
+ echo "Usage: $0 <language>"
+ exit 0
+fi
+if [ -z "`which msgmerge 2>/dev/null`" ] ; then
+ echo "ERR: Msgmerge not found, please install the gettext package"
+ exit 1
+fi
+
+language=${1:-pl}
+
+SPODIR="./po"
+BUILDDIR="./build"
+if [ -z "$PO_USEBUILD" ] ; then
+ PODIR=$SPODIR
+else
+ PODIR="$BUILDDIR/build.po"
+ mkdir -p $PODIR/$language
+fi
+RET=0
+
+[ -d "$PODIR" ] || exit 1
+
+echo "Updating PO files for language '$language':"
+for POT in `find $PODIR/pot -name "*.pot"` ; do
+ BASENAME="$(basename $POT .pot)"
+ PO=$PODIR/$language/$BASENAME.po
+ SPO=$SPODIR/$language/$BASENAME.po
+
+ if [ -f $SPO ] ; then
+ echo "- updating $BASENAME.po"
+ if [ -z "$PO_USEBUILD" ] ; then
+ # Update existing PO file
+ msgmerge -q -U --backup=simple $PO $POT
+ RC=$?
+ else
+ # Generate temporary PO file in build directory
+ msgmerge -q $SPO $POT -o $PO
+ RC=$?
+ fi
+ if [ $RC -ne 0 ] ; then
+ RET=$RC
+ echo "Error: error $RC while executing msgmerge"
+ fi
+ else
+ echo "Warning: no PO file found for '$BASENAME'."
+ fi
+done
+
+exit $RET
diff --git a/scripts/update_pot b/scripts/update_pot
new file mode 100755
index 000000000..cc94a4009
--- /dev/null
+++ b/scripts/update_pot
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+# This script is used for translations using .po files.
+# It updates .pot files after changes in the original English
+# .xml files.
+# The script 'merge_xml' should be run before this script!
+
+if [ "$1" = "--help" ] ; then
+ echo "Usage: $0"
+ exit 0
+fi
+
+if [ -z "`which xml2pot 2>/dev/null`" ] ; then
+ echo "ERR: xml2pot not found, please install the poxml package"
+ exit 1
+fi
+
+BUILDDIR="./build"
+if [ -z "$PO_USEBUILD" ] ; then
+ WORKDIR="./integrated"
+ PODIR="./po"
+else
+ WORKDIR="$BUILDDIR/build.po"
+ PODIR="$BUILDDIR/build.po"
+fi
+SOURCEDIR="$WORKDIR/en"
+RET=0
+
+[ -d $SOURCE ] || exit 1
+mkdir -p $PODIR/pot
+
+# This check is broken!
+if [ -n "$(find $PODIR/pot/ -name *.pot 2>/dev/null)" ] ; then
+ echo "Deleting old POT files..."
+ rm $PODIR/pot/*.pot
+fi
+
+for XML in `find $SOURCEDIR -name "*.xml"` ; do
+ echo "Creating new POT file for $XML"
+ POT=$(basename $XML .xml).pot
+
+ xml2pot $XML >$PODIR/pot/$POT
+ RC=$?
+ if [ $RC -ne 0 ] ; then
+ RET=$RC
+ echo "Error: error $RC while executing xml2pot"
+ fi
+done
+
+exit $RET