1 # Copyright (c) 2003 David Kocher. All rights reserved.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # Bug fixes, suggestions and comments should be sent to:
15 # dkocher@cyberduck.ch
20 convertstrings
="ruby convertstrings.rb"
21 base_language
="en.lproj"
23 tx
="/usr/local/bin/tx"
28 echo " Usage: i18n.sh [-l <language>] --status"
29 echo " Usage: i18n.sh [-l <language>] --init"
30 echo " Usage: i18n.sh [-l <language>] [-n <$extension>] [--force] --update"
31 echo " Usage: i18n.sh [-l <language>] --run"
33 echo "<language> must be Japanese.lproj, French.lproj, Spanish.lproj, ..."
34 echo "<$extension> must be Preferences.$extension, Main.$extension, ..."
36 echo "Call with no parameters to update all languages and all $extension files"
42 for n
in `ls $base_language | grep .$extension | grep -v ~.$extension`; do
45 cp -R $base_language/$n $language/$n
48 for stringsfile
in `ls $base_language | grep .strings`; do
50 echo "Copying $stringsfile"
51 cp -R $base_language/$stringsfile $language/$stringsfile
54 cp $base_language/License.txt
$language/
58 for lproj
in `ls . | grep lproj`; do
65 echo "Running app using `basename $language .lproj`...";
66 arch
-arch $arch .
/build
/Cyberduck.app
/Contents
/MacOS
/Cyberduck
-AppleLanguages "(`basename $language .lproj`)"
70 #Changes to the .strings has precedence over the NIBs
72 #Update the .strings with new values from NIBs
77 if($force == true
); then
80 echo "*** Updating $nib... (force) in $language..."
81 $nibtool --reference-external-strings-file \
82 --write $language/$nibfile \
83 --import-strings-file $language/$nib.
strings \
84 $base_language/$nibfile
89 echo "*** Updating $nib... (incremental) in $language..."
90 $nibtool --write $language/$nibfile \
91 --incremental-file $language/$nibfile \
92 --previous-file $base_language/$nibfile \
93 --import-strings-file $language/$nib.
strings \
94 --localize-incremental $base_language/$nibfile
100 echo "*** Updating $nib.strings in $language..."
101 $nibtool --export-strings-file $language/$nib.
strings $language/$nibfile
104 export_strings_legacy
() {
105 for lproj
in `ls . | grep lproj`; do
107 echo "*** Updating $language Localization...";
108 for nibfile
in `ls $language | grep $extension`; do
109 nib
=`basename $nibfile $extension`
110 echo "Update $language/$nib.strings.1 from $base_language/$nib.strings"
111 $convertstrings $base_language/$nib.
strings $language/$nib.
strings > $language/$nib.
strings.1
117 if [ "$language" = "all" ] ; then
119 echo "*** Updating all localizations...";
120 for lproj
in `ls . | grep lproj`; do
122 if [ $language != $base_language ]; then
124 echo "*** Updating $language Localization...";
125 if [ "$nibfile" = "all" ] ; then
126 echo "*** Updating all NIBs...";
127 for nibfile
in `ls $language | grep $extension`; do
128 nib
=`basename $nibfile $extension`
129 $nibtool --export-strings-file $base_language/$nib.
strings $base_language/$nibfile
133 if [ "$nibfile" != "all" ] ; then
134 nib
=`basename $nibfile $extension`
135 $nibtool --export-strings-file $base_language/$nib.
strings $base_language/$nibfile
144 echo "*** Updating $language Localization...";
145 if [ "$nibfile" = "all" ] ; then
146 echo "*** Updating all NIBs...";
147 for nibfile
in `ls $language | grep $extension`; do
148 nib
=`basename $nibfile $extension`;
149 $nibtool --export-strings-file $base_language/$nib.
strings $base_language/$nibfile
153 if [ "$nibfile" != "all" ] ; then
155 nib
=`basename $nibfile $extension`;
156 $nibtool --export-strings-file $base_language/$nib.
strings $base_language/$nibfile
165 echo "*** Updating all localizations...";
166 if [ "$stringsfile" = "all" ] ; then
167 echo "*** Updating all .strings...";
168 for stringsfile
in `ls en.lproj | grep .strings`; do
169 strings=`basename $stringsfile .strings`
170 echo "*** Updating $strings.strings...";
171 $tx --traceback set --auto-local -r cyberduck.
$strings '<lang>'.lproj
/$strings.
strings --source-language en
--type=STRINGS
--execute
172 $tx --traceback push
--source --translations --resource=cyberduck.
$strings --force --no-interactive --skip
175 if [ "$stringsfile" != "all" ] ; then
176 strings=`basename $stringsfile .strings`
177 echo "*** Updating $strings.strings...";
178 $tx --traceback set --auto-local -r cyberduck.
$strings '<lang>'.lproj
/$strings.
strings --source-language en
--type=STRINGS
--execute
179 $tx --traceback push
--source --translations --resource=cyberduck.
$strings --force --no-interactive --skip
184 echo "*** Updating all localizations...";
185 if [ "$stringsfile" = "all" ] ; then
186 echo "*** Updating all .strings...";
187 for stringsfile
in `ls en.lproj | grep .strings`; do
188 strings=`basename $stringsfile .strings`
189 echo "*** Updating $strings.strings...";
190 $tx --traceback pull
--source --resource=cyberduck.
$strings --force
193 if [ "$stringsfile" != "all" ] ; then
194 strings=`basename $stringsfile .strings`
195 echo "*** Updating $strings.strings...";
196 $tx --traceback pull
--source --resource=cyberduck.
$strings --force
205 while [ "$1" != "" ] # When there are arguments...
210 echo "Using Language:$language";
216 echo "Using Nib:$nibfile";
222 echo "Using strings:$stringsfile";
226 export_strings_legacy
;
228 echo "*** DONE. ***";
237 echo "*** DONE. ***";
240 echo "Init new localization...";
242 echo "*** DONE. ***";
246 echo "Updating localization...";
248 echo "*** DONE. ***";
253 echo "*** DONE. ***";
259 echo "Running architecture:$arch";
263 echo "Updating .tx...";
265 echo "*** DONE. ***";
269 echo "Updating .tx...";
271 echo "*** DONE. ***";
276 echo "*** DONE. ***";
280 echo "Option [$1] not one of [--update, --init, --tx-push, --tx-pull]"; # Error (!)
282 ;; # Abort Script Now