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 base_language
="en.lproj"
22 tx
="/usr/local/bin/tx"
27 echo " Usage: i18n.sh [-l <language>] --status"
28 echo " Usage: i18n.sh [-l <language>] --init"
29 echo " Usage: i18n.sh [-l <language>] [-n <$extension>] [--force] --update"
30 echo " Usage: i18n.sh [-l <language>] --run"
32 echo "<language> must be Japanese.lproj, French.lproj, Spanish.lproj, ..."
33 echo "<$extension> must be Preferences.$extension, Main.$extension, ..."
35 echo "Call with no parameters to update all languages and all $extension files"
41 for n
in `ls $base_language | grep .$extension | grep -v ~.$extension`; do
44 cp -R $base_language/$n $language/$n
47 for stringsfile
in `ls $base_language | grep .strings | grep -v ~.strings`; do
49 echo "Copying $stringsfile"
50 cp -R $base_language/$stringsfile $language/$stringsfile
53 cp $base_language/License.txt
$language/
57 for lproj
in `ls . | grep lproj`; do
64 echo "Running app using `basename $language .lproj`...";
65 arch
-arch $arch .
/build
/Cyberduck.app
/Contents
/MacOS
/Cyberduck
-AppleLanguages "(`basename $language .lproj`)"
69 #Changes to the .strings has precedence over the NIBs
71 #Update the .strings with new values from NIBs
76 if($force == true
); then
79 echo "*** Updating $nib... (force) in $language..."
80 $nibtool --reference-external-strings-file \
81 --write $language/$nibfile \
82 --import-strings-file $language/$nib.
strings \
83 $base_language/$nibfile
88 echo "*** Updating $nib... (incremental) in $language..."
89 $nibtool --write $language/$nibfile \
90 --incremental-file $language/$nibfile \
91 --previous-file $base_language/$nibfile \
92 --import-strings-file $language/$nib.
strings \
93 --localize-incremental $base_language/$nibfile
99 echo "*** Updating $nib.strings in $language..."
100 $nibtool --export-strings-file $language/$nib.
strings $language/$nibfile
104 if [ "$language" = "all" ] ; then
106 echo "*** Updating all localizations...";
107 for lproj
in `ls . | grep lproj`; do
109 if [ $language != $base_language ]; then
111 echo "*** Updating $language Localization...";
112 if [ "$nibfile" = "all" ] ; then
113 echo "*** Updating all NIBs...";
114 for nibfile
in `ls $language | grep $extension | grep -v ~$extension`; do
115 nib
=`basename $nibfile $extension`
116 $nibtool --export-strings-file $base_language/$nib.
strings $base_language/$nibfile
120 if [ "$nibfile" != "all" ] ; then
121 nib
=`basename $nibfile $extension`
122 $nibtool --export-strings-file $base_language/$nib.
strings $base_language/$nibfile
131 echo "*** Updating $language Localization...";
132 if [ "$nibfile" = "all" ] ; then
133 echo "*** Updating all NIBs...";
134 for nibfile
in `ls $language | grep $extension | grep -v ~$extension`; do
135 nib
=`basename $nibfile $extension`;
136 $nibtool --export-strings-file $base_language/$nib.
strings $base_language/$nibfile
140 if [ "$nibfile" != "all" ] ; then
142 nib
=`basename $nibfile $extension`;
143 $nibtool --export-strings-file $base_language/$nib.
strings $base_language/$nibfile
152 echo "*** Updating all localizations...";
153 if [ "$stringsfile" = "all" ] ; then
154 echo "*** Updating all .strings...";
155 for stringsfile
in `ls en.lproj | grep .strings | grep -v ~.strings`; do
156 strings=`basename $stringsfile .strings`
157 echo "*** Updating $strings.strings...";
158 $tx --traceback set --auto-local -r cyberduck.
$strings '<lang>'.lproj
/$strings.
strings --source-language en
--type=STRINGS
--execute
159 $tx --traceback push
--source --translations --resource=cyberduck.
$strings --force --no-interactive --skip
162 if [ "$stringsfile" != "all" ] ; then
163 strings=`basename $stringsfile .strings`
164 echo "*** Updating $strings.strings...";
165 $tx --traceback set --auto-local -r cyberduck.
$strings '<lang>'.lproj
/$strings.
strings --source-language en
--type=STRINGS
--execute
166 $tx --traceback push
--source --translations --resource=cyberduck.
$strings --force --no-interactive --skip
171 echo "*** Updating all localizations...";
172 if [ "$stringsfile" = "all" ] ; then
173 echo "*** Updating all .strings...";
174 for stringsfile
in `ls en.lproj | grep .strings | grep -v ~.strings`; do
175 strings=`basename $stringsfile .strings`
176 echo "*** Updating $strings.strings...";
177 $tx --traceback pull
--source --resource=cyberduck.
$strings --force
180 if [ "$stringsfile" != "all" ] ; then
181 strings=`basename $stringsfile .strings`
182 echo "*** Updating $strings.strings...";
183 $tx --traceback pull
--source --resource=cyberduck.
$strings --force
192 while [ "$1" != "" ] # When there are arguments...
197 echo "Using Language:$language";
203 echo "Using Nib:$nibfile";
209 echo "Using strings:$stringsfile";
219 echo "*** DONE. ***";
222 echo "Init new localization...";
224 echo "*** DONE. ***";
228 echo "Updating localization...";
230 echo "*** DONE. ***";
235 echo "*** DONE. ***";
241 echo "Running architecture:$arch";
245 echo "Updating .tx...";
247 echo "*** DONE. ***";
251 echo "Updating .tx...";
253 echo "*** DONE. ***";
258 echo "*** DONE. ***";
262 echo "Option [$1] not one of [--update, --init, --tx-push, --tx-pull]"; # Error (!)
264 ;; # Abort Script Now