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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 22119 - (show annotations) (download)
Mon Sep 27 18:43:52 2004 UTC (8 years, 7 months ago) by fjpop-guest
File size: 3452 byte(s)
- Moved all scripts to a ./scripts directory
- Moved some unused scripts to ./scripts/historic
- Created scripts to convert translations to .po files

1 #!/bin/sh
2
3 if [ "$1" = "--help" ] ; then
4 echo "Usage: $0 <language>"
5 fi
6
7 language=${1:-nl}
8
9 basedir="$(pwd)/$(dirname $0)"
10 TARGET="./integrated"
11
12 cd $TARGET/
13 [ ! -d ./$language/ ] && exit 1
14 [ ! -d ./po/ ] && mkdir po/
15
16 cd ./$language/
17 XMLLIST=$(find . -name "*.xml")
18
19 cd ./../
20 echo "Creating .po files for language '$language'..."
21 for XMLFILE in $XMLLIST ; do
22 DIR=$(echo $XMLFILE | sed "s/\/[^/]*$//")
23 if [ ! -d $language/$DIR/ ] ; then
24 echo "Skipping $DIR; directory does not exist under ./po/"
25 continue
26 fi
27 XML=$(basename $XMLFILE)
28 PO=$(basename $XML .xml).$language.po
29
30 echo "Converting translated $DIR/$XML to .po file"
31
32 split2po en/$DIR/$XML $language/$DIR/$XML >po/$DIR/$PO
33 if [ $? -ne 0 ] ; then
34 echo "** Error during conversion."
35 continue
36 fi
37
38 # Remove strange references created by split2po
39 if grep -q "POXML_" po/$DIR/$PO ; then
40 echo " Converting "POXML_" references..."
41 cat po/$DIR/$PO | \
42 sed "s/!POXML_AMP!/\&/g" | \
43 sed "s/ /\\\t/g" | \
44 sed "s/&POXML_SPACE;/ /g" | \
45 sed "s/&POXML_LINEFEED;/\\\n\"\n \"/g" | \
46 sed "s/&POXML_LT;/</g" | \
47 sed "s/&POXML_GT;/>/g" \
48 >/tmp/$$.po
49 cp /tmp/$$.po po/$DIR/$PO
50 fi
51 # Check if there are any we don't yet know about
52 if grep "POXML_" po/$DIR/$PO ; then
53 echo "** Error: file contains unknown "POXML_" references."
54 fi
55
56 # Remove spurious msgid's created by split2po (drop last 6 lines)
57 if grep "ROLES_OF_TRANSLATORS" po/$DIR/$PO >/dev/null; then
58 LINES=$(cat po/$DIR/$PO | wc -l)
59 head -n $(($LINES - 6)) po/$DIR/$PO >/tmp/$$.po
60 cp /tmp/$$.po po/$DIR/$PO
61 fi
62 done
63
64 # Check the results
65 echo ""
66 echo "Checking whether translation matches corresponding .pot file..."
67 for PO in `find po/ -name "*.$language.po"` ; do
68 PODIR=$(dirname $PO); POFILE=$(basename $PO ".$language.po")
69 if [ -f $PODIR/$POFILE.pot ] ; then
70 count_PO=$(grep "^msgid " $PO | wc -l)
71 count_POT=$(grep "^msgid " $PODIR/$POFILE.pot | wc -l)
72 if [ ! $count_PO = $count_POT ] ; then
73 echo "** Warning: translation for $PO has $count_PO strings, while original has $count_POT strings."
74 fi
75 else
76 echo "** Error: Corresponding .pot file not found for $PO."
77 fi
78 done
79 echo "Done."
80
81 # Checking for untranslated strings
82 echo ""
83 echo "Checking for untranslated strings in the .po files..."
84 for PO in `find po/ -name "*.$language.po"` ; do
85 echo "Checking $PO..."
86 awk -f $basedir/mark_untranslated.awk $PO
87 done
88
89 echo ""
90 echo "The conversion has finished successfully."
91 echo "The .po files for $language have been saved in './integrated/po/'."
92 echo ""
93 echo "Please check all messages above very carefully."
94 echo "If any translations are shown to have a different amount of strings than the original,"
95 echo "you should probably correct the cause of this and run the conversion again."
96 echo ""
97 echo "Strings that are shown as 'looking untranslated', this could just be a string that"
98 echo "does not need translation, but could also indicate parts of the original that really"
99 echo "are untranslated but are not marked as such."
100 echo "In that case, you can use the set_untranslated script to mark these strings as"
101 echo "untranslated (enter 'set_untranslated --help' for usage)."
102
103 rm /tmp/$$.po /tmp/$$.xml &>/dev/null
104 exit 0

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.5