/[d-i]/trunk/installer/doc/manual/scripts/create_po
ViewVC logotype

Diff of /trunk/installer/doc/manual/scripts/create_po

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 23464 by fjpop-guest, Mon Sep 27 18:43:52 2004 UTC revision 23465 by fjpop-guest, Mon Oct 25 16:56:18 2004 UTC
# Line 1  Line 1 
1  #!/bin/sh  #!/bin/sh
2    
3    # This script is used for translations using .po files.
4    # It creates the initial .po files for a language where there
5    # already is a translation.
6    
7    # This script is meant to be used only once for the transition
8    # from translating the .xml files to using .po files.
9    
10  if [ "$1" = "--help" ] ; then  if [ "$1" = "--help" ] ; then
11      echo "Usage: $0 <language>"      echo "Usage: $0 <language>"
12        exit 0
13  fi  fi
14    
15  language=${1:-nl}  language=${1:-pl}
16    
17  basedir="$(pwd)/$(dirname $0)"  [ -d ./$language/ ] || exit 1
 TARGET="./integrated"  
18    
19  cd $TARGET/  SCRIPTDIR="./scripts"
20  [ ! -d ./$language/ ] && exit 1  WORKDIR="./integrated"
21  [ ! -d ./po/ ] && mkdir po/  SOURCEDIR="$WORKDIR/$language"
22    PODIR="./po"
23    
24    if [ -d "$PODIR" ] ; then
25        echo "Deleting old .po files for '$language'..."
26        for i in `find $PODIR/ -name "*.$language.po"` ; do
27            rm $i
28        done
29    fi
30    
31  cd ./$language/  XMLLIST=$(find $SOURCEDIR -name "*.xml")
 XMLLIST=$(find . -name "*.xml")  
32    
 cd ./../  
33  echo "Creating .po files for language '$language'..."  echo "Creating .po files for language '$language'..."
34  for XMLFILE in $XMLLIST ; do  for SOURCEXML in $XMLLIST ; do
35      DIR=$(echo $XMLFILE | sed "s/\/[^/]*$//")      SUBDIR=$(dirname $SOURCEXML | sed "s:$SOURCEDIR::" | sed "s:^/::")
36      if [ ! -d $language/$DIR/ ] ; then      if [ ! -d $PODIR/$SUBDIR ] ; then
37          echo "Skipping $DIR; directory does not exist under ./po/"          echo "Skipping $SUBDIR; directory does not exist under $PODIR"
38          continue          continue
39      fi      fi
40      XML=$(basename $XMLFILE)      XML=$(basename $SOURCEXML)
41      PO=$(basename $XML .xml).$language.po      ORIGXML=$WORKDIR/en/$SUBDIR/$XML
42        PO=$PODIR/$SUBDIR/$(basename $SOURCEXML .xml).$language.po
43    
44      echo "Converting translated $DIR/$XML to .po file"      echo "Converting translated $SUBDIR/$XML to .po file"
45        split2po $ORIGXML $SOURCEXML >$PO
     split2po en/$DIR/$XML $language/$DIR/$XML >po/$DIR/$PO  
46      if [ $? -ne 0 ] ; then      if [ $? -ne 0 ] ; then
47          echo "** Error during conversion."          echo "** Error during conversion."
48          continue          continue
49      fi      fi
50    
51      # Remove strange references created by split2po      # Remove strange references created by split2po
52      if grep -q "POXML_" po/$DIR/$PO ; then      # Note: this is a workaround for a bug in the tools:
53        #       http://bugs.kde.org/show_bug.cgi?id=90112
54        if grep -q "POXML_" $PO ; then
55          echo "   Converting "POXML_" references..."          echo "   Converting "POXML_" references..."
56          cat po/$DIR/$PO | \          cat $PO | \
57              sed "s/!POXML_AMP!/\&/g" | \              sed "s/!POXML_AMP!/\&/g" | \
58              sed "s/        /\\\t/g" | \              sed "s/        /\\\t/g" | \
59              sed "s/&POXML_SPACE;/ /g" | \              sed "s/&POXML_SPACE;/ /g" | \
60              sed "s/&POXML_LINEFEED;/\\\n\"\n      \"/g" | \              sed "s/&POXML_LINEFEED;/\\\n\"\n      \"/g" | \
61              sed "s/&POXML_LT;/</g" | \              sed "s/&POXML_LT;/</g" | \
62              sed "s/&POXML_GT;/>/g" \              sed "s/&POXML_GT;/>/g" \
63              >/tmp/$$.po              >/tmp/tmp.po.$$
64          cp /tmp/$$.po po/$DIR/$PO          cp /tmp/tmp.po.$$ $PO
65      fi      fi
66      # Check if there are any we don't yet know about      # Check if there are any we don't yet know about
67      if grep "POXML_" po/$DIR/$PO ; then      if grep "POXML_" $PO ; then
68          echo "** Error: file contains unknown "POXML_" references."          echo "** Error: file contains unknown "POXML_" references."
69      fi      fi
70    
71      # Remove spurious msgid's created by split2po (drop last 6 lines)      # Remove spurious msgid's created by split2po (drop last 6 lines)
72      if grep "ROLES_OF_TRANSLATORS" po/$DIR/$PO >/dev/null; then      # Note: this is a workaround for a feature in the tools:
73          LINES=$(cat po/$DIR/$PO | wc -l)      #       http://bugs.kde.org/show_bug.cgi?id=90112
74          head -n $(($LINES - 6)) po/$DIR/$PO >/tmp/$$.po      if grep "ROLES_OF_TRANSLATORS" $PO >/dev/null; then
75          cp /tmp/$$.po po/$DIR/$PO          LINES=$(cat $PO | wc -l)
76            head -n $(($LINES - 6)) $PO >/tmp/tmp.po.$$
77            cp /tmp/tmp.po.$$ $PO
78      fi      fi
79  done  done
80    
81  # Check the results  # Check the results
82  echo ""  echo ""
83  echo "Checking whether translation matches corresponding .pot file..."  echo "Checking whether translation matches corresponding .pot file..."
84  for PO in `find po/ -name "*.$language.po"` ; do  for PO in `find $PODIR -name "*.$language.po"` ; do
85      PODIR=$(dirname $PO); POFILE=$(basename $PO ".$language.po")      TDIR=$(dirname $PO); POT=$(basename $PO ".$language.po").pot
86      if [ -f $PODIR/$POFILE.pot ] ; then      if [ -s $PO ] ; then
87          count_PO=$(grep "^msgid " $PO | wc -l)          if [ -f $TDIR/$POT ] ; then
88          count_POT=$(grep "^msgid " $PODIR/$POFILE.pot | wc -l)              count_POT=$(egrep "^msgid " $TDIR/$POT | wc -l)
89          if [ ! $count_PO = $count_POT ] ; then              count_PO=$(egrep "^msgstr " $PO | wc -l)
90              echo "** Warning: translation for $PO has $count_PO strings, while original has $count_POT strings."              if [ $count_PO != $count_POT ] ; then
91                    echo "** Warning: translation for $PO has $count_PO strings, while original has $count_POT strings."
92                fi
93                count_missing_PO=$(egrep "^msgstr \"\"$" $PO | wc -l)
94                count_missing_PO=$(($count_missing_PO - 1))
95                if [ $count_missing_PO -ne 0 ] ; then
96                    echo "** Warning: translation for $PO has $count_missing_PO missing strings."
97                fi
98            else
99                echo "** Error: corresponding .pot file not found for $PO."
100          fi          fi
101      else      else
102          echo "** Error: Corresponding .pot file not found for $PO."          echo "** Error: $PO is empty (conversion error)."
103      fi      fi
104  done  done
105  echo "Done."  echo "Done."
# Line 83  echo "" Line 109  echo ""
109  echo "Checking for untranslated strings in the .po files..."  echo "Checking for untranslated strings in the .po files..."
110  for PO in `find po/ -name "*.$language.po"` ; do  for PO in `find po/ -name "*.$language.po"` ; do
111      echo "Checking $PO..."      echo "Checking $PO..."
112      awk -f $basedir/mark_untranslated.awk $PO      awk -f $SCRIPTDIR/mark_untranslated.awk $PO
113  done  done
114    
115  echo ""  echo ""
116  echo "The conversion has finished successfully."  echo "The conversion has finished successfully."
117  echo "The .po files for $language have been saved in './integrated/po/'."  echo "The .po files for $language have been saved in '$PODIR'."
118  echo ""  echo ""
119  echo "Please check all messages above very carefully."  echo "Please check all messages above very carefully."
120  echo "If any translations are shown to have a different amount of strings than the original,"  echo "If any translations are shown to have a different amount of strings than the original,"
# Line 100  echo "are untranslated but are not marke Line 126  echo "are untranslated but are not marke
126  echo "In that case, you can use the set_untranslated script to mark these strings as"  echo "In that case, you can use the set_untranslated script to mark these strings as"
127  echo "untranslated (enter 'set_untranslated --help' for usage)."  echo "untranslated (enter 'set_untranslated --help' for usage)."
128    
129  rm /tmp/$$.po /tmp/$$.xml &>/dev/null  rm /tmp/tmp.po.$$ /tmp/$$.xml &>/dev/null
130  exit 0  exit 0

Legend:
Removed from v.23464  
changed lines
  Added in v.23465

  ViewVC Help
Powered by ViewVC 1.1.5