blob: ce0a240c192ef2df8d4bb96a91e77704b484aa69 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
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 -f /tmp/tmp.po.$$ /tmp/$$.xml
exit 0
|