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.
7
# This script is meant to be used only once for the transition
8
# from translating the .xml files to using .po files.
10
if [ "$1" = "--help" ] ; then
11
echo "Usage: $0 <language>"
17
[ -d ./$language/ ] || exit 1
20
WORKDIR="./integrated"
21
SOURCEDIR="$WORKDIR/$language"
24
if [ ! -d "$PODIR" ] ; then
25
echo "Error: directory $PODIR does not exist."
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
35
XMLLIST=$(find $SOURCEDIR -name "*.xml")
37
echo "Creating PO files for language '$language'..."
39
export NO_CREDITS=1 # Repress KDE specific credits
40
# Note: not yet supported by split2po
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
48
echo "Converting translated $SUBDIR/$XML to PO file"
49
split2po $ORIGXML $SOURCEXML >$PO
50
if [ $? -ne 0 ] ; then
51
echo "** Error during conversion."
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"
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."
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."
74
echo "** Error: corresponding POT file not found for $PO."
77
echo "** Error: $PO is empty (conversion error)."
82
# Checking for untranslated strings
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
91
echo "The conversion has finished successfully."
92
echo "The PO files for $language have been saved in '$PODIR/$language'."
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."
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)."
104
rm /tmp/tmp.po.$$ /tmp/$$.xml &>/dev/null