Fix transcript in transfer window.
[cyberduck.git] / i18n.sh
blob8b6e768807bf09eb1eb2bf21acbfabc529449ea2
1 # Copyright (c) 2003 David Kocher. All rights reserved.
2 # http://cyberduck.ch/
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
17 #!/bin/bash
19 # From Xcode 2.5 Developer Tools installation
20 nibtool="nibtool"
21 base_language="en.lproj"
22 arch="x86_64"
23 tx="/usr/local/bin/tx"
25 usage() {
26 echo ""
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"
31 echo ""
32 echo "<language> must be Japanese.lproj, French.lproj, Spanish.lproj, ..."
33 echo "<nib> must be Preferences.nib, Main.nib, ..."
34 echo ""
35 echo "Call with no parameters to update all languages and all nib files"
36 echo ""
39 init() {
40 mkdir -p $language
41 for n in `ls $base_language | grep .nib | grep -v ~.nib`; do
43 echo "Copying $n"
44 cp -R $base_language/$n $language/$n
45 rm -rf $language/$n/.svn
47 done
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
53 done
54 cp $base_language/License.txt $language/
57 test() {
58 for lproj in `ls . | grep lproj`; do
59 language=$lproj;
60 run;
61 done;
64 open() {
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
72 fi;
73 done;
75 else
77 echo "*** Opening $language/$nib.strings"
78 /usr/bin/open $language/$nib.strings
80 fi;
83 run() {
84 echo "Running app using `basename $language .lproj`...";
85 arch -arch $arch ./build/Cyberduck.app/Contents/MacOS/Cyberduck -AppleLanguages "(`basename $language .lproj`)"
88 status() {
89 if [ "$language" = "all" ] ; then
91 for lproj in `ls . | grep lproj`; do
92 language=$lproj;
93 if [ $language != "$base_language" ]; then
94 echo "*** Status of $language Localization...";
95 polyglot -b en -l `basename $language .lproj` .
96 fi;
97 done;
99 else
101 echo "*** Status of $language Localization...";
102 polyglot -b en -l `basename $language .lproj` .
107 nib() {
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
120 # force update
121 echo "*** Updating $nib... (force) in $language..."
122 $nibtool --write $language/$nibfile --dictionary $language/$nib.strings $base_language/$nibfile
124 else
126 # incremental update
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
144 update() {
145 if [ "$language" = "all" ] ; then
147 echo "*** Updating all localizations...";
148 for lproj in `ls . | grep lproj`; do
149 language=$lproj;
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
158 nib;
159 done;
161 if [ "$n" != "all" ] ; then
162 nib=`basename $n .nib`
163 $nibtool --localizable-strings $base_language/$n > $base_language/$nib.strings
164 nib;
168 done;
170 else
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
178 nib;
179 done;
181 if [ "$nibfile" != "all" ] ; then
183 nib=`basename $nibfile .nib`;
184 $nibtool --localizable-strings $base_language/$nibfile > $base_language/$nib.strings
185 nib;
192 tx_push() {
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
201 done;
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
211 tx_pull() {
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
219 done;
221 if [ "$stringsfile" != "all" ] ; then
222 strings=`basename $stringsfile .strings`
223 echo "*** Updating $strings.strings...";
224 $tx --traceback pull --source --resource=cyberduck.$strings --force
228 language="all";
229 nibfile="all";
230 stringsfile="all";
231 force=false;
233 while [ "$1" != "" ] # When there are arguments...
234 do case "$1" in
235 -l | --language)
236 shift;
237 language=$1;
238 echo "Using Language:$language";
239 shift;
241 -n | --nib)
242 shift;
243 nibfile=$1;
244 echo "Using Nib:$nibfile";
245 shift;
247 --strings)
248 shift;
249 stringsfile=$1;
250 echo "Using strings:$stringsfile";
251 shift;
253 -f | --force)
254 force=true;
255 shift;
257 -h | --help)
258 usage;
259 exit 0;
260 echo "*** DONE. ***";
262 -i | --init)
263 echo "Init new localization...";
264 init;
265 echo "*** DONE. ***";
266 exit 0;
268 -s | --status)
269 echo "Status of localization...";
270 status;
271 echo "*** DONE. ***";
272 exit 0;
274 -u | --update)
275 echo "Updating localization...";
276 update;
277 echo "*** DONE. ***";
278 exit 0;
280 -o | --open)
281 echo "Opening localization .strings files...";
282 open;
283 echo "*** DONE. ***";
284 exit 0;
286 -r | --run)
287 run;
288 echo "*** DONE. ***";
289 exit 0;
291 --arch)
292 shift;
293 arch=$1;
294 echo "Running architecture:$arch";
295 shift;
297 -tx-push)
298 echo "Updating .tx...";
299 tx_push;
300 echo "*** DONE. ***";
301 exit 0;
303 -tx-pull)
304 echo "Updating .tx...";
305 tx_pull;
306 echo "*** DONE. ***";
307 exit 0;
309 --test)
310 test;
311 echo "*** DONE. ***";
312 exit 0;
315 echo "Option [$1] not one of [--status, --update, --open, --init]"; # Error (!)
316 exit 1
317 ;; # Abort Script Now
318 esac;
319 done;
321 usage;