diff options
author | Joey Hess <joeyh@debian.org> | 2005-10-07 19:51:38 +0000 |
---|---|---|
committer | Joey Hess <joeyh@debian.org> | 2005-10-07 19:51:38 +0000 |
commit | 1ea73eea5ecc6a8ed901316049259aee737ee554 (patch) | |
tree | 03a077f0b1b1548f3c806bd1c5795964fba0fb52 /scripts/create_po | |
download | installation-guide-1ea73eea5ecc6a8ed901316049259aee737ee554.zip |
move manual to top-level directory, split out of debian-installer package
Diffstat (limited to 'scripts/create_po')
-rwxr-xr-x | scripts/create_po | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/scripts/create_po b/scripts/create_po new file mode 100755 index 000000000..bd919a663 --- /dev/null +++ b/scripts/create_po @@ -0,0 +1,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 /tmp/tmp.po.$$ /tmp/$$.xml &>/dev/null +exit 0 |