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

Contents of /trunk/manual/scripts/create_po

Parent Directory Parent Directory | Revision Log Revision Log


Revision 32343 - (show annotations) (download)
Mon Nov 21 18:10:38 2005 UTC (7 years, 6 months ago) by fjp
File size: 3475 byte(s)
Make sure po files are utf-8 encoded before running po2xml
1 #!/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
11 echo "Usage: $0 <language>"
12 exit 0
13 fi
14
15 language=${1:-pl}
16
17 [ -d ./$language/ ] || exit 1
18
19 SCRIPTDIR="./scripts"
20 WORKDIR="./integrated"
21 SOURCEDIR="$WORKDIR/$language"
22 PODIR="./po"
23
24 if [ ! -d "$PODIR" ] ; then
25 echo "Error: directory $PODIR does not exist."
26 exit 1
27 fi
28
29 mkdir -p $PODIR/$language
30 if [ -n "$PODIR/$language/*.po" ] ; then
31 echo "Deleting old PO files for '$language'..."
32 rm $PODIR/$language/*.po
33 fi
34
35 XMLLIST=$(find $SOURCEDIR -name "*.xml")
36
37 echo "Creating PO files for language '$language'..."
38
39 export NO_CREDITS=1 # Repress KDE specific credits
40 # Note: not yet supported by split2po
41
42 for SOURCEXML in $XMLLIST ; do
43 SUBDIR=$(dirname $SOURCEXML | sed "s:$SOURCEDIR::" | sed "s:^/::")
44 XML=$(basename $SOURCEXML)
45 ORIGXML=$WORKDIR/en/$SUBDIR/$XML
46 PO=$PODIR/$language/$(basename $SOURCEXML .xml).po
47
48 echo "Converting translated $SUBDIR/$XML to PO file"
49 split2po $ORIGXML $SOURCEXML >$PO
50 if [ $? -ne 0 ] ; then
51 echo "** Error during conversion."
52 continue
53 fi
54 done
55
56 # Check the results
57 echo ""
58 echo "Checking whether translation matches corresponding POT file..."
59 for PO in `find $PODIR/$language -name "*.po"` ; do
60 POT="$PODIR/pot/$(basename $PO .po).pot"
61 if [ -s $PO ] ; then
62 if [ -f $POT ] ; then
63 count_POT=$(egrep "^msgid " $POT | wc -l)
64 count_PO=$(egrep "^msgstr " $PO | wc -l)
65 if [ $count_PO != $count_POT ] ; then
66 echo "** Warning: translation for $PO has $count_PO strings, while original has $count_POT strings."
67 fi
68 # Missing strings: If a line with 'msgstr ""' is followed by an empty line.
69 count_missing_PO=$(egrep -A 1 "^msgstr \"\"$" $PO | egrep "^$" | wc -l)
70 if [ $count_missing_PO -ne 0 ] ; then
71 echo "** Warning: translation for $PO has $count_missing_PO missing strings."
72 fi
73 else
74 echo "** Error: corresponding POT file not found for $PO."
75 fi
76 else
77 echo "** Error: $PO is empty (conversion error)."
78 fi
79 done
80 echo "Done."
81
82 # Checking for untranslated strings
83 echo ""
84 echo "Checking for untranslated strings in the PO files..."
85 for PO in `find $PODIR/$language -name "*.po"` ; do
86 echo "Checking $PO..."
87 awk -f $SCRIPTDIR/mark_untranslated.awk $PO
88 done
89
90 echo ""
91 echo "The conversion has finished successfully."
92 echo "The PO files for $language have been saved in '$PODIR/$language'."
93 echo ""
94 echo "Please check all messages above very carefully."
95 echo "If any translations are shown to have a different amount of strings than the original,"
96 echo "you should probably correct the cause of this and run the conversion again."
97 echo ""
98 echo "Strings that are shown as 'looking untranslated', this could just be a string that"
99 echo "does not need translation, but could also indicate parts of the original that really"
100 echo "are untranslated but are not marked as such."
101 echo "In that case, you can use the set_untranslated script to mark these strings as"
102 echo "untranslated (enter 'set_untranslated --help' for usage)."
103
104 rm -f /tmp/tmp.po.$$ /tmp/$$.xml
105 exit 0

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.5