| Line 6... |
Line 6... |
| 6 |
LANGUAGES=`cat LANGUAGES`
|
6 |
LANGUAGES=`cat LANGUAGES`
|
| 7 |
|
7 |
|
| 8 |
# Get all (non-backup) NIBs in English.lproj assuming that this is where we do active development
|
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)}'`
|
9 |
NIBS=`ls -d English.lproj/*.nib | grep -v \~ | awk -F / '{print substr($2,1,length($2)-4)}'`
|
| 10 |
|
10 |
|
| 11 |
if [ "$1" == "-h" ]; then
|
11 |
if [[ "x$1" == "x-h" || "x$1" == "x" ]]; then
|
| 12 |
echo " Usage $0 [-t]"
|
- |
|
| 13 |
echo " "
|
12 |
echo " "
|
| 14 |
echo " When -t is used, translation files are not generated, but assumed to exist already."
|
13 |
echo " Usage: $0 -g - generates translation string files"
|
| 15 |
echo " Otherwise files in Translation.strings are overwritten."
|
14 |
echo " $0 -t [-c] - translates NIBs using translation"
|
| - |
|
15 |
echo " string files"
|
| - |
|
16 |
echo " "
|
| - |
|
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"
|
| 16 |
echo " "
|
24 |
echo " "
|
| 17 |
exit 0
|
25 |
exit 0
|
| 18 |
fi
|
26 |
fi
|
| 19 |
|
27 |
|
| 20 |
mkdir Translated.strings 2> /dev/null
|
28 |
mkdir Translated.strings 2> /dev/null
|
| 21 |
|
29 |
|
| - |
|
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 |
|
| 22 |
# for each languange ...
|
41 |
# for each languange ...
|
| 23 |
for LANG in $LANGUAGES; do
|
42 |
for LANG in $LANGUAGES; do
|
| 24 |
echo "Updating $LANG ..."
|
43 |
echo "Updating $LANG ..."
|
| 25 |
# and each NIB ...
|
44 |
# and each NIB ...
|
| 26 |
for NIB in $NIBS; do
|
45 |
for NIB in $NIBS; do
|
| 27 |
if [ -e "$LANG.lproj/$NIB.nib" ]; then
|
46 |
if [ -e "$LANG.lproj/$NIB.nib" ]; then
|
| 28 |
# create a strings file with all translations
|
47 |
# create a strings file with all translations
|
| 29 |
if [ "$1" != "-t" ]; then
|
48 |
if [[ "x$1" != "x-t" && "x$2" != "x-t" ]]; then
|
| 30 |
nibtool -8 -I "$LANG.lproj/$NIB.nib" -L "English.lproj/$NIB.nib" > "Translated.strings/$NIB.$LANG.strings"
|
49 |
nibtool -8 -I "$LANG.lproj/$NIB.nib" -L "English.lproj/$NIB.nib" > "Translated.strings/$NIB.$LANG.strings"
|
| 31 |
fi
|
50 |
fi
|
| 32 |
if [ ! -e "Translated.strings/$NIB.$LANG.strings" ]; then
|
51 |
if [ ! -e "Translated.strings/$NIB.$LANG.strings" ]; then
|
| 33 |
echo " $NIB .. ERROR: Can't find translation strings"
|
52 |
echo " $NIB .. ERROR: Can't find translation strings"
|
| 34 |
else
|
53 |
else
|
| 35 |
rm -rf "$LANG.lproj/temp.nib" "$LANG.lproj/temp~.nib"
|
54 |
rm -rf "$LANG.lproj/temp.nib" "$LANG.lproj/temp~.nib"
|
| - |
|
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
|
| 36 |
# merge the changes taking modifications into account
|
60 |
# merge the changes taking modifications into account
|
| 37 |
nibtool -8 -I "$LANG.lproj/$NIB.nib" -W "$LANG.lproj/temp.nib" -d "Translated.strings/$NIB.$LANG.strings" "English.lproj/$NIB.nib"
|
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
|
| 38 |
if [ -e "$LANG.lproj/temp.nib/classes.nib" ]; then
|
63 |
if [ -e "$LANG.lproj/temp.nib/classes.nib" ]; then
|
| 39 |
cp "$LANG.lproj/temp.nib/"* "$LANG.lproj/$NIB.nib/"
|
64 |
cp "$LANG.lproj/temp.nib/"* "$LANG.lproj/$NIB.nib/"
|
| 40 |
rm -rf "$LANG.lproj/temp.nib" "$LANG.lproj/temp~.nib"
|
65 |
rm -rf "$LANG.lproj/temp.nib" "$LANG.lproj/temp~.nib"
|
| 41 |
echo " $NIB .. OK"
|
66 |
echo " $NIB .. OK"
|
| 42 |
else
|
67 |
else
|
| 43 |
echo "ERROR for language \"$LANG\" and NIB \"$NIB\": Localized nib was not created. Check for nibtool errors."
|
68 |
echo "ERROR for language \"$LANG\" and NIB \"$NIB\": Localized nib was not created. Check for nibtool errors."
|
| - |
|
69 |
fi
|
| 44 |
fi
|
70 |
fi
|
| 45 |
fi
|
71 |
fi
|
| 46 |
else
|
72 |
else
|
| 47 |
echo " $NIB .. not localized yet."
|
73 |
echo " $NIB .. not localized yet."
|
| 48 |
fi
|
74 |
fi
|