]> git.lyx.org Git - lyx.git/blobdiff - po/postats.sh
update German docs
[lyx.git] / po / postats.sh
index d5f956b80eb6299de16fb5fa52af3ba02034ac19..7244daa0c3a688adeee243f9f0b4c57af9fc5fd6 100755 (executable)
@@ -5,7 +5,7 @@
 # This file is part of LyX, the document processor.
 # Licence details can be found in the file COPYING.
 #
-# author: Michael Schmitt, michael.schmitt@teststep.org
+# author: Michael Gerz, michael.gerz@teststep.org
 #
 # This script extracts some information from the po file headers (last
 # translator, revision date), generates the corresponding gmo files
 # and generates a PHP web page.
 #
 # Invocation:
-#    postats.sh po_files > "pathToWebPages"/i18n.php3
+#    postats.sh po_files > "pathToWebPages"/i18n.php
 
+# modifiy this when you change version
+# Note that an empty lyx_branch variable (ie cvs HEAD)
+# will "do the right thing".
+lyx_version=1.4.0cvs
+lyx_branch=
+
+
+# GNU sed and grep have real problems dealing with 8-bit characters
+# in UTF-8 encoded environments.
+unset LANG
+LANGUAGE=C
 
 warning () {
        echo $* 1>&2
@@ -30,7 +41,7 @@ error () {
 # $1 is a string like
 # '588 translated messages, 1248 fuzzy translations, 2 untranslated messages.'
 # Any one of these substrings may not appear if the associated number is 0.
-# 
+#
 # $2 is the word following the number to be extracted,
 # ie, 'translated', 'fuzzy', or 'untranslated'.
 #
@@ -64,7 +75,7 @@ run_msgfmt () {
 
        output=
        test -f $1 || {
-               warning "File $1 does not exist"  
+               warning "File $1 does not exist"
                return
        }
 
@@ -73,7 +84,7 @@ run_msgfmt () {
        pofile=`basename $1`
        gmofile=`echo $pofile | sed 's/po$/gmo/'`
        test $pofile != '' -a $pofile != $gmofile || {
-               warning "File $1 is not a po file"  
+               warning "File $1 is not a po file"
                unset origdir dir pofile gmofile
                return
        }
@@ -88,7 +99,7 @@ run_msgfmt () {
        date=`grep 'Revision-Date' $pofile | sed 's/  */ /g' | cut -d ' ' -f 2`
 
        # Searching for a string of the form
-       # '"Last-Translator: Michael Schmitt <Michael.Schmitt@teststep.org>\n"'
+       # '"Last-Translator: Michael Gerz <Michael.Gerz@teststep.org>\n"'
        translator=
        email=
        input=`grep "Last-Translator" $pofile` && {
@@ -99,6 +110,19 @@ run_msgfmt () {
        }
        unset input
 
+       # Does $translator contain 8-bit characters?
+       TAB='   '
+       echo $translator | grep "[^${TAB} -~]" >/dev/null && {
+               # If so, grab the encoding from the po file.
+               charset=`sed -n '/Content-Type/{s/.*charset=//;s/\\\\n" *$//p;q}' $pofile`
+               # Use recode to generate HTML character codes for the 8-bit
+               # characters.
+               translator=`echo $translator | recode "${charset}..h4"` || exit 1
+               # The ampersands in the $translator entries will mess things
+               # up unless we escape 'em.
+               translator=`echo $translator | sed 's/&/\\\&/g'`
+       }
+
        # Run msgfmt on the pofile, filling $message with the raw info.
        message=`$msgfmt --statistics -o $gmofile $pofile 2>&1 | grep "^[1-9]"` || {
                warning "Unable to run msgfmt successfully on file $1"
@@ -137,12 +161,12 @@ cat <<EOF
        // What's the short name of the page in the navigation bar?
        \$item="i18n";
        // Who is the author?
-       \$author="Michael Schmitt";
+       \$author="Michael Gerz";
        // Full name of the file (relative path from LyX home page -- i.e., it should
-       // be "foo.php3" or "bar/foo.php3")
-       \$file_full="i18n.php3";
+       // be "foo.php" or "bar/foo.php")
+       \$file_full="devel/i18n.php";
 
-       include("start.php3");
+       include("start.php");
 
        error_reporting(E_ALL);
 ?>
@@ -155,6 +179,13 @@ EOF
 
 # The foot of the generated php file.
 dump_tail () {
+
+test "$lyx_branch" = "" && {
+       branch_tag=""
+} || {
+       branch_tag="?only_with_tag=$lyx_branch"
+}
+
 cat <<EOF
 <?
 \$lang = array(
@@ -171,7 +202,8 @@ cat <<EOF
        'hu' => 'Hungarian',
        'it' => 'Italian',
        'nl' => 'Dutch',
-       'no' => 'Norwegian',
+       'nn' => 'Nynorsk',
+       'nb' => 'Norwegian',
        'pl' => 'Polish',
        'pt' => 'Portuguese',
        'ro' => 'Romanian',
@@ -197,8 +229,8 @@ usort (\$podata, "cmp");
 
 <p>
        The following table details the current state of the translations of the
-       LyX GUI for the main LyX development branch (currently 1.3.0cvs).
-       Unfortunately, only a few languages are well-supported. The LyX term may,
+       LyX GUI for the LyX stable branch (currently $lyx_version).
+       Unfortunately, only a few languages are well-supported. The LyX team may,
        therefore, decide to exclude some of the translations from a formal
        release in order not to confuse the user with a strongly mixed-language
        interface.
@@ -236,8 +268,9 @@ while (list(\$foo,\$info) = each(\$podata)) {
        } else {
                \$style="style='background:#AA3333'";
        }
+       print "<td \$style>" ;
 
-       print "<td \$style>" . \$lang[\$info['langcode']] . "</td>";
+       print "<a href=\"http://www.lyx.org/cgi-bin/viewcvs.cgi/lyx-devel/po/" . \$info['langcode'] . ".po$branch_tag\">" . \$lang[\$info['langcode']] . "</a></td>";
 
        print "<td \$style align=\"right\">" . \$info['msg_tr'] . "</td>";
 
@@ -274,7 +307,7 @@ while (list(\$foo,\$info) = each(\$podata)) {
 </tbody>
 </table>
 <?
-include("end.php3");
+include("end.php");
 ?>
 EOF
 }
@@ -282,7 +315,7 @@ EOF
 
 # The main body of the script
 msgfmt=`which msgfmt`
-test $msgfmt != '' || error "Unable to find 'msgfmt'. Cannot proceed." 
+test $msgfmt != '' || error "Unable to find 'msgfmt'. Cannot proceed."
 
 dump_head