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
19 # From Xcode 2.5 Developer Tools installation
21 base_language
="en.lproj"
23 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 <nib>] [--force] --update"
30 echo " Usage: i18n.sh [-l <language>] --run"
32 echo "<language> must be Japanese.lproj, French.lproj, Spanish.lproj, ..."
33 echo "<nib> must be Preferences.nib, Main.nib, ..."
35 echo "Call with no parameters to update all languages and all nib files"
41 for n
in `ls $base_language | grep .nib | grep -v ~.nib`; do
44 cp -R $base_language/$n $language/$n
45 rm -rf $language/$n/.svn
48 for stringsfile
in `ls $base_language | grep .strings | grep -v ~.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 nib
=`basename $nibfile .nib`
66 if [ "$language" = "all" ] ; then
68 for lproj
in `ls . | grep lproj`; do
69 if [ $lproj != $base_language ]; then
70 echo "*** Opening $lproj/$nib.strings"
71 /usr
/bin
/open
$lproj/$nib.
strings
77 echo "*** Opening $language/$nib.strings"
78 /usr
/bin
/open
$language/$nib.
strings
84 echo "Running app using `basename $language .lproj`...";
85 arch
-arch $arch .
/build
/Cyberduck.app
/Contents
/MacOS
/Cyberduck
-AppleLanguages "(`basename $language .lproj`)"
89 if [ "$language" = "all" ] ; then
91 for lproj
in `ls . | grep lproj`; do
93 if [ $language != "$base_language" ]; then
94 echo "*** Status of $language Localization...";
95 polyglot
-b en
-l `basename $language .lproj` .
101 echo "*** Status of $language Localization...";
102 polyglot
-b en
-l `basename $language .lproj` .
108 #Changes to the .strings has precedence over the NIBs
109 updateNibFromStrings
;
110 #Update the .strings with new values from NIBs
111 udpateStringsFromNib
;
114 updateNibFromStrings
() {
115 rm -rf $language/$nibfile.bak
116 mv $language/$nibfile $language/$nibfile.bak
118 if($force == true
); then
121 echo "*** Updating $nib... (force) in $language..."
122 $nibtool --write $language/$nibfile --dictionary $language/$nib.
strings $base_language/$nibfile
127 echo "*** Updating $nib... (incremental) in $language..."
128 $nibtool --write $language/$nibfile \
129 --incremental $language/$nibfile.bak \
130 --dictionary $language/$nib.
strings $base_language/$nibfile
133 cp -R $language/$nibfile.bak
/.svn
$language/$nibfile/.svn
134 rm -rf $language/$nibfile.bak
137 udpateStringsFromNib
() {
138 echo "*** Updating $nib.strings in $language..."
139 $nibtool --previous $base_language/$nibfile \
140 --incremental $language/$nibfile \
141 --localizable-strings $base_language/$nibfile > $language/$nib.
strings
145 if [ "$language" = "all" ] ; then
147 echo "*** Updating all localizations...";
148 for lproj
in `ls . | grep lproj`; do
150 if [ $language != $base_language ]; then
152 echo "*** Updating $language Localization...";
153 if [ "$nibfile" = "all" ] ; then
154 echo "*** Updating all NIBs...";
155 for n
in `ls $language | grep .nib | grep -v ~.nib`; do
156 nib
=`basename $n .nib`
157 $nibtool --localizable-strings $base_language/$n > $base_language/$nib.
strings
161 if [ "$n" != "all" ] ; then
162 nib
=`basename $n .nib`
163 $nibtool --localizable-strings $base_language/$n > $base_language/$nib.
strings
172 echo "*** Updating $language Localization...";
173 if [ "$nibfile" = "all" ] ; then
174 echo "*** Updating all NIBs...";
175 for n
in `ls $language | grep .nib | grep -v ~.nib`; do
176 nib
=`basename $n .nib`;
177 $nibtool --localizable-strings $base_language/$n > $base_language/$nib.
strings
181 if [ "$nibfile" != "all" ] ; then
183 nib
=`basename $nibfile .nib`;
184 $nibtool --localizable-strings $base_language/$nibfile > $base_language/$nib.
strings
193 echo "*** Updating all localizations...";
194 if [ "$stringsfile" = "all" ] ; then
195 echo "*** Updating all .strings...";
196 for stringsfile
in `ls en.lproj | grep .strings | grep -v ~.strings`; do
197 strings=`basename $stringsfile .strings`
198 echo "*** Updating $strings.strings...";
199 $tx --traceback set --auto-local -r cyberduck.
$strings '<lang>'.lproj
/$strings.
strings --source-language en
--type=STRINGS
--execute
200 $tx --traceback push
--source --translations --resource=cyberduck.
$strings --force --no-interactive
203 if [ "$stringsfile" != "all" ] ; then
204 strings=`basename $stringsfile .strings`
205 echo "*** Updating $strings.strings...";
206 $tx --traceback set --auto-local -r cyberduck.
$strings '<lang>'.lproj
/$strings.
strings --source-language en
--type=STRINGS
--execute
207 $tx --traceback push
--source --translations --resource=cyberduck.
$strings --force --no-interactive
212 echo "*** Updating all localizations...";
213 if [ "$stringsfile" = "all" ] ; then
214 echo "*** Updating all .strings...";
215 for stringsfile
in `ls en.lproj | grep .strings | grep -v ~.strings`; do
216 strings=`basename $stringsfile .strings`
217 echo "*** Updating $strings.strings...";
218 $tx --traceback pull
--source --resource=cyberduck.
$strings --force
221 if [ "$stringsfile" != "all" ] ; then
222 strings=`basename $stringsfile .strings`
223 echo "*** Updating $strings.strings...";
224 $tx --traceback pull
--source --resource=cyberduck.
$strings --force
233 while [ "$1" != "" ] # When there are arguments...
238 echo "Using Language:$language";
244 echo "Using Nib:$nibfile";
250 echo "Using strings:$stringsfile";
260 echo "*** DONE. ***";
263 echo "Init new localization...";
265 echo "*** DONE. ***";
269 echo "Status of localization...";
271 echo "*** DONE. ***";
275 echo "Updating localization...";
277 echo "*** DONE. ***";
281 echo "Opening localization .strings files...";
283 echo "*** DONE. ***";
288 echo "*** DONE. ***";
294 echo "Running architecture:$arch";
298 echo "Updating .tx...";
300 echo "*** DONE. ***";
304 echo "Updating .tx...";
306 echo "*** DONE. ***";
311 echo "*** DONE. ***";
315 echo "Option [$1] not one of [--status, --update, --open, --init]"; # Error (!)
317 ;; # Abort Script Now