Rev 1390 | 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 EnglishLANGUAGES=`cat LANGUAGES`# Get all (non-backup) NIBs in English.lproj assuming that this is where we do active developmentNIBS=`ls -d English.lproj/*.nib | grep -v \~ | awk -F / '{print substr($2,1,length($2)-4)}'`if [[ "x$1" == "x-h" || "x$1" == "x" ]]; thenecho " "echo " Usage: $0 -g - generates translation string files"echo " $0 -t [-c] - translates NIBs using translation"echo " string files"echo " "echo " Either -g or -t has to be specified in any case."echo " Options: -c cleanup: results in a more aggressive handling"echo " of NIBs by discarding all information from the"echo " localized version of each NIB."echo " "echo " The usual process is to use $0 -g, translate"echo " string files and run $0 -t"echo " "exit 0fimkdir Translated.strings 2> /dev/nullecho "-----------------------------------------------------------------"if [[ "x$1" == "x-t" || "x$2" == "x-t" ]]; thenecho "*** Using translated string for localization"elseecho "*** Generating translated strings"fiif [[ "x$1" == "x-c" || "x$2" == "x-c" ]]; thenecho "*** Cleanup requested - discarding layout in localized files."fiecho "-----------------------------------------------------------------"# for each languange ...for LANG in $LANGUAGES; doecho "Updating $LANG ..."# and each NIB ...for NIB in $NIBS; doif [ -e "$LANG.lproj/$NIB.nib" ]; then# create a strings file with all translationsif [[ "x$1" != "x-t" && "x$2" != "x-t" ]]; thennibtool -8 -I "$LANG.lproj/$NIB.nib" -L "English.lproj/$NIB.nib" > "Translated.strings/$NIB.$LANG.strings"fiif [ ! -e "Translated.strings/$NIB.$LANG.strings" ]; thenecho " $NIB .. ERROR: Can't find translation strings"elserm -rf "$LANG.lproj/temp.nib" "$LANG.lproj/temp~.nib"if [[ "x$1" != "x-g" && "x$1" != "x-g" ]]; thenif [[ "x$1" == "x-c" || "x$2" == "x-c" ]]; then# "clean" merge - i.e. don't use localized NIB for sourcenibtool -8 -W "$LANG.lproj/temp.nib" -d "Translated.strings/$NIB.$LANG.strings" "English.lproj/$NIB.nib"else# merge the changes taking modifications into accountnibtool -8 -I "$LANG.lproj/$NIB.nib" -W "$LANG.lproj/temp.nib" -d "Translated.strings/$NIB.$LANG.strings" "English.lproj/$NIB.nib"fiif [ -e "$LANG.lproj/temp.nib/classes.nib" ]; thencp "$LANG.lproj/temp.nib/"* "$LANG.lproj/$NIB.nib/"rm -rf "$LANG.lproj/temp.nib" "$LANG.lproj/temp~.nib"echo " $NIB .. OK"elseecho "ERROR for language \"$LANG\" and NIB \"$NIB\": Localized nib was not created. Check for nibtool errors."fififielseecho " $NIB .. not localized yet."fidonedone