| 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
|
| 1048 |
urbaneks |
6 |
LANGUAGES=`cat LANGUAGES`
|
| 966 |
urbaneks |
7 |
|
|
|
8 |
# Get all (non-backup) NIBs in English.lproj assuming that this is where we do active development
|
|
|
9 |
NIBS=`ls -d English.lproj/*.nib | grep -v \~ | awk -F / '{print substr($2,1,length($2)-4)}'`
|
|
|
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"
|
|
|
14 |
echo " $0 -t [-c] - translates NIBs using translation"
|
|
|
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"
|
|
|
19 |
echo " of NIBs by discarding all information from the"
|
|
|
20 |
echo " localized version of each NIB."
|
|
|
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 ...
|
|
|
42 |
for LANG in $LANGUAGES; do
|
|
|
43 |
echo "Updating $LANG ..."
|
|
|
44 |
# and each NIB ...
|
|
|
45 |
for NIB in $NIBS; do
|
|
|
46 |
if [ -e "$LANG.lproj/$NIB.nib" ]; then
|
|
|
47 |
# create a strings file with all translations
|
| 1390 |
urbaneks |
48 |
if [[ "x$1" != "x-t" && "x$2" != "x-t" ]]; then
|
| 967 |
urbaneks |
49 |
nibtool -8 -I "$LANG.lproj/$NIB.nib" -L "English.lproj/$NIB.nib" > "Translated.strings/$NIB.$LANG.strings"
|
|
|
50 |
fi
|
|
|
51 |
if [ ! -e "Translated.strings/$NIB.$LANG.strings" ]; then
|
|
|
52 |
echo " $NIB .. ERROR: Can't find translation strings"
|
|
|
53 |
else
|
| 966 |
urbaneks |
54 |
rm -rf "$LANG.lproj/temp.nib" "$LANG.lproj/temp~.nib"
|
| 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
|
|
|
58 |
nibtool -8 -W "$LANG.lproj/temp.nib" -d "Translated.strings/$NIB.$LANG.strings" "English.lproj/$NIB.nib"
|
|
|
59 |
else
|
|
|
60 |
# merge the changes taking modifications into account
|
|
|
61 |
nibtool -8 -I "$LANG.lproj/$NIB.nib" -W "$LANG.lproj/temp.nib" -d "Translated.strings/$NIB.$LANG.strings" "English.lproj/$NIB.nib"
|
|
|
62 |
fi
|
|
|
63 |
if [ -e "$LANG.lproj/temp.nib/classes.nib" ]; then
|
|
|
64 |
cp "$LANG.lproj/temp.nib/"* "$LANG.lproj/$NIB.nib/"
|
|
|
65 |
rm -rf "$LANG.lproj/temp.nib" "$LANG.lproj/temp~.nib"
|
|
|
66 |
echo " $NIB .. OK"
|
|
|
67 |
else
|
|
|
68 |
echo "ERROR for language \"$LANG\" and NIB \"$NIB\": Localized nib was not created. Check for nibtool errors."
|
|
|
69 |
fi
|
| 967 |
urbaneks |
70 |
fi
|
| 966 |
urbaneks |
71 |
fi
|
|
|
72 |
else
|
|
|
73 |
echo " $NIB .. not localized yet."
|
|
|
74 |
fi
|
|
|
75 |
done
|
|
|
76 |
done
|