The R Project SVN R-packages

Rev

Rev 1041 | Rev 1390 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

#!/bin/sh
#
# Created 2005/02/01 by Simon Urbanek

# list of localizations we want to generate from English
LANGUAGES=`cat LANGUAGES`

# Get all (non-backup) NIBs in English.lproj assuming that this is where we do active development
NIBS=`ls -d English.lproj/*.nib | grep -v \~ | awk -F / '{print substr($2,1,length($2)-4)}'`

if [ "$1" == "-h" ]; then
    echo " Usage $0 [-t]"
    echo " "
    echo " When -t is used, translation files are not generated, but assumed to exist already."
    echo " Otherwise files in Translation.strings are overwritten."
    echo " "
    exit 0
fi

mkdir Translated.strings 2> /dev/null

# for each languange ...
for LANG in $LANGUAGES; do
    echo "Updating $LANG ..."
    # and each NIB ...
    for NIB in $NIBS; do
        if [ -e "$LANG.lproj/$NIB.nib" ]; then
            # create a strings file with all translations
            if [ "$1" != "-t" ]; then
                nibtool -8 -I "$LANG.lproj/$NIB.nib" -L "English.lproj/$NIB.nib" > "Translated.strings/$NIB.$LANG.strings"
            fi
            if [ ! -e "Translated.strings/$NIB.$LANG.strings" ]; then
                echo "   $NIB .. ERROR: Can't find translation strings"
            else
                rm -rf "$LANG.lproj/temp.nib" "$LANG.lproj/temp~.nib"
                # merge the changes taking modifications into account
                nibtool -8 -I "$LANG.lproj/$NIB.nib" -W "$LANG.lproj/temp.nib" -d "Translated.strings/$NIB.$LANG.strings" "English.lproj/$NIB.nib"
                if [ -e "$LANG.lproj/temp.nib/classes.nib" ]; then
                    cp "$LANG.lproj/temp.nib/"* "$LANG.lproj/$NIB.nib/"
                    rm -rf "$LANG.lproj/temp.nib" "$LANG.lproj/temp~.nib"
                    echo "   $NIB .. OK"
                else
                    echo "ERROR for language \"$LANG\" and NIB \"$NIB\": Localized nib was not created. Check for nibtool errors."
                fi
            fi
        else
            echo "   $NIB .. not localized yet."
        fi
    done
done