Change protection level.
[cyberduck.git] / i18n.sh
blobbe4098c08e9a07c2f72b9d74cfacc172329416e8
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 nibtool="ibtool"
20 base_language="en.lproj"
21 arch="x86_64"
22 tx="/usr/local/bin/tx"
23 extension=".xib"
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 <$extension>] [--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 "<$extension> must be Preferences.$extension, Main.$extension, ..."
34 echo ""
35 echo "Call with no parameters to update all languages and all $extension files"
36 echo ""
39 init() {
40 mkdir -p $language
41 for n in `ls $base_language | grep .$extension | grep -v ~.$extension`; do
43 echo "Copying $n"
44 cp -R $base_language/$n $language/$n
46 done
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
52 done
53 cp $base_language/License.txt $language/
56 test() {
57 for lproj in `ls . | grep lproj`; do
58 language=$lproj;
59 run;
60 done;
63 run() {
64 echo "Running app using `basename $language .lproj`...";
65 arch -arch $arch ./build/Cyberduck.app/Contents/MacOS/Cyberduck -AppleLanguages "(`basename $language .lproj`)"
68 nib() {
69 #Changes to the .strings has precedence over the NIBs
70 import_strings;
71 #Update the .strings with new values from NIBs
72 export_strings;
75 import_strings() {
76 if($force == true); then
78 # force update
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
85 else
87 # incremental update
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
95 fi;
98 export_strings() {
99 echo "*** Updating $nib.strings in $language..."
100 $nibtool --export-strings-file $language/$nib.strings $language/$nibfile
103 update() {
104 if [ "$language" = "all" ] ; then
106 echo "*** Updating all localizations...";
107 for lproj in `ls . | grep lproj`; do
108 language=$lproj;
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
117 nib;
118 done;
120 if [ "$nibfile" != "all" ] ; then
121 nib=`basename $nibfile $extension`
122 $nibtool --export-strings-file $base_language/$nib.strings $base_language/$nibfile
123 nib;
127 done;
129 else
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
137 nib;
138 done;
140 if [ "$nibfile" != "all" ] ; then
142 nib=`basename $nibfile $extension`;
143 $nibtool --export-strings-file $base_language/$nib.strings $base_language/$nibfile
144 nib;
151 tx_push() {
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
160 done;
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
170 tx_pull() {
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
178 done;
180 if [ "$stringsfile" != "all" ] ; then
181 strings=`basename $stringsfile .strings`
182 echo "*** Updating $strings.strings...";
183 $tx --traceback pull --source --resource=cyberduck.$strings --force
187 language="all";
188 nibfile="all";
189 stringsfile="all";
190 force=false;
192 while [ "$1" != "" ] # When there are arguments...
193 do case "$1" in
194 -l | --language)
195 shift;
196 language=$1;
197 echo "Using Language:$language";
198 shift;
200 -n | --nib)
201 shift;
202 nibfile=$1;
203 echo "Using Nib:$nibfile";
204 shift;
206 --strings)
207 shift;
208 stringsfile=$1;
209 echo "Using strings:$stringsfile";
210 shift;
212 -f | --force)
213 force=true;
214 shift;
216 -h | --help)
217 usage;
218 exit 0;
219 echo "*** DONE. ***";
221 -i | --init)
222 echo "Init new localization...";
223 init;
224 echo "*** DONE. ***";
225 exit 0;
227 -u | --update)
228 echo "Updating localization...";
229 update;
230 echo "*** DONE. ***";
231 exit 0;
233 -r | --run)
234 run;
235 echo "*** DONE. ***";
236 exit 0;
238 --arch)
239 shift;
240 arch=$1;
241 echo "Running architecture:$arch";
242 shift;
244 --tx-push)
245 echo "Updating .tx...";
246 tx_push;
247 echo "*** DONE. ***";
248 exit 0;
250 --tx-pull)
251 echo "Updating .tx...";
252 tx_pull;
253 echo "*** DONE. ***";
254 exit 0;
256 --test)
257 test;
258 echo "*** DONE. ***";
259 exit 0;
262 echo "Option [$1] not one of [--update, --init, --tx-push, --tx-pull]"; # Error (!)
263 exit 1
264 ;; # Abort Script Now
265 esac;
266 done;
268 usage;