The R Project SVN R-packages

Rev

Rev 5711 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
966 urbaneks 1
#!/bin/sh
1048 urbaneks 2
#
3
# Created 2005/02/01 by Simon Urbanek
966 urbaneks 4
 
5
# list of localizations we want to generate from English
6148 urbaneks 6
if [ -z "$languages" ]; then languages=`cat LANGUAGES`; fi
966 urbaneks 7
 
8
# Get all (non-backup) NIBs in English.lproj assuming that this is where we do active development
5711 urbaneks 9
NIBS=`ls -d English.lproj/*.xib | grep -v \~ | awk -F / '{print substr($2,1,length($2)-4)}'`
966 urbaneks 10
 
1390 urbaneks 11
if [[ "x$1" == "x-h" || "x$1" == "x" ]]; then
967 urbaneks 12
	echo " "
1390 urbaneks 13
	echo " Usage: $0 -g       - generates translation string files"
5711 urbaneks 14
	echo "        $0 -t [-c]  - translates XIBs using translation"
1390 urbaneks 15
	echo "                      string files"
967 urbaneks 16
	echo " "
1390 urbaneks 17
	echo " Either -g or -t has to be specified in any case."
18
	echo " Options: -c  cleanup: results in a more aggressive handling"
5711 urbaneks 19
	echo "              of XIBs by discarding all information from the"
20
	echo "              localized version of each XIB."
1390 urbaneks 21
	echo " "
22
	echo " The usual process is to use $0 -g, translate"
23
	echo " string files and run $0 -t"
24
	echo " "
967 urbaneks 25
	exit 0
26
fi
27
 
28
mkdir Translated.strings 2> /dev/null
29
 
1390 urbaneks 30
echo "-----------------------------------------------------------------"
31
if [[ "x$1" == "x-t" || "x$2" == "x-t" ]]; then
32
	echo "*** Using translated string for localization"
33
else
34
	echo "*** Generating translated strings"
35
fi
36
if [[ "x$1" == "x-c" || "x$2" == "x-c" ]]; then
37
	echo "*** Cleanup requested - discarding layout in localized files."
38
fi
39
echo "-----------------------------------------------------------------"
40
 
966 urbaneks 41
# for each languange ...
5677 urbaneks 42
for lang in $languages; do
43
	echo "Updating $lang ..."
966 urbaneks 44
	# and each NIB ...
45
	for NIB in $NIBS; do
5711 urbaneks 46
		if [ -e "$lang.lproj/$NIB.xib" ]; then
966 urbaneks 47
			# create a strings file with all translations
1390 urbaneks 48
			if [[ "x$1" != "x-t" && "x$2" != "x-t" ]]; then
5711 urbaneks 49
				./nib2str "English.lproj/$NIB.xib" "$lang.lproj/$NIB.xib" > "Translated.strings/$NIB.$lang.strings"
967 urbaneks 50
			fi
5677 urbaneks 51
			if [ ! -e "Translated.strings/$NIB.$lang.strings" ]; then
967 urbaneks 52
				echo "   $NIB .. ERROR: Can't find translation strings"
53
			else
5711 urbaneks 54
				rm -rf "$lang.lproj/temp.xib" "$lang.lproj/temp~.xib"
1390 urbaneks 55
				if [[ "x$1" != "x-g" && "x$1" != "x-g" ]]; then
56
					if [[ "x$1" == "x-c" || "x$2" == "x-c" ]]; then
57
						# "clean" merge - i.e. don't use localized NIB for source
5677 urbaneks 58
						# nibtool -F 4 -8  -W "$lang.lproj/temp.nib" -d "Translated.strings/$NIB.$lang.strings" "English.lproj/$NIB.nib"
5711 urbaneks 59
						./str2nib "English.lproj/$NIB.xib" "Translated.strings/$NIB.$lang.strings" "$lang.lproj/temp.xib"
1390 urbaneks 60
					else
61
						# merge the changes taking modifications into account
5677 urbaneks 62
						# nibtool -F 4 -8 -I "$lang.lproj/$NIB.nib" -W "$lang.lproj/temp.nib" -d "Translated.strings/$NIB.$lang.strings" "English.lproj/$NIB.nib"
5711 urbaneks 63
						./str2nib "English.lproj/$NIB.xib" "Translated.strings/$NIB.$lang.strings" "$lang.lproj/temp.xib"
1390 urbaneks 64
					fi
5711 urbaneks 65
					if [ -e "$lang.lproj/temp.xib" ]; then
66
						mv "$lang.lproj/temp.xib" "$lang.lproj/$NIB.xib"
1390 urbaneks 67
						echo "   $NIB .. OK"
68
					else
5711 urbaneks 69
						echo "ERROR for language \"$lang\" and XIB \"$NIB\": Localized xib was not created. Check for ibtool errors."
1390 urbaneks 70
					fi
967 urbaneks 71
				fi
966 urbaneks 72
			fi
73
		else
74
			echo "   $NIB .. not localized yet."
75
		fi
76
	done
77
done