update po2wml to make things work
Runa A. Sandvik

Runa A. Sandvik commited on 2011-03-31 13:17:24
Zeige 1 geänderte Dateien mit 113 Einfügungen und 130 Löschungen.

... ...
@@ -124,90 +124,9 @@ for file in $po ; do
124 124
 				echo '#include "foot.wmi"' >> "$wmldir/$subdir/$wmlfile"
125 125
 			fi
126 126
 
127
-			# If the directory does not include sidenav.wmi,
128
-			# copy it from the English directory (only if
129
-			# the English directory has this file)
130
-			if [[ ! -e "$wmldir/$subdir/sidenav.wmi" && -e "$wmldir/en/sidenav.wmi" ]]
131
-			then
132
-				cp "$wmldir/en/sidenav.wmi" "$wmldir/$subdir"
133
-			fi
134
-
135
-		fi
136
-	}	
137
-
138
-	# Convert translations to directories such as website/torbrowser/nb/.
139
-	# Again, po4a will write the file and then delete it if less than 80% has been translated
140
-	function subdir {
141
-		# The location of the english wml file
142
-                english="$wmldir/$subdir/en/$wmlfile"
143
-
144
-		# Convert the files
145
-		po4a-translate -f wml -m "$english" -p "$file" -l "$wmldir/$subdir/$lang/$wmlfile" --master-charset utf-8 -L utf-8 -o customtag="$customtag" -o nodefault="$nodefault"
146
-
147
-		# Check to see if the file was written
148
-		if [ -e "$wmldir/$subdir/$lang/$wmlfile" ]
149
-		then
150
-			# Remove last three lines in file
151
-			sed -i -e :a -e '$d;N;2,3ba' -e 'P;D' "$wmldir/$subdir/$lang/$wmlfile"
152
-
153
-			# Remove a specific comment from a specific file
154
-			if [ $wmlfile == "download-easy.wml" ]			
155
-			then
156
-				translator_comment="# Translators: please point to the version of TBB in your language, if there is one."
157
-				sed -i "s/$translator_comment//" "$wmldir/$subdir/$lang/$wmlfile"
158
-			fi
159
-
160
-			# Include the English footer for most of the
161
-			# translations 
162
-			if [[ $lang != "ar" && $lang != "pl" ]]
163
-			then
164
-				echo '#include "foot.wmi"' >> "$wmldir/$subdir/$lang/$wmlfile"
165
-			fi
166
-
167
-			# If the directory does not include sidenav.wmi,
168
-			# copy it from the English directory (only if 
169
-			# the English directory has this file)
170
-			if [[ ! -e "$wmldir/$subdir/$lang/sidenav.wmi" && -e "$wmldir/$subdir/en/sidenav.wmi" ]]
171
-			then
172
-				cp "$wmldir/$subdir/en/sidenav.wmi" "$wmldir/$subdir/$lang/"
173
-			fi
174
-		fi
175
-	}
176
-
177
-	# If $onedirup is equal to $lang, that means we do not have a
178
-	# subdirectory.
179
-	if [ $onedirup == $lang ]
180
-	then
181
-		# If the current subdirectory is "zh_CN" use "zh-cn" instead
182
-		if [ $subdir = "zh_CN" ]
183
-		then
184
-			subdir="zh-cn"
185
-			nosubdir
186
-		fi
187
-		
188
-		# If the current directory is "nb" use "no" instead
189
-		if [ $subdir = "nb" ]
190
-		then
191
-			subdir="no"
192
-			nosubdir
193
-		fi
194
-
195
-		# If the current directory is "sv" use "se" instead
196
-		if [ $subdir = "sv" ]
197
-		then
198
-			subdir="se"
199
-			nosubdir
200
-		fi
201
-
202
-		# If the current directory is "pl_PL" use "pl" instead
203
-		if [ $subdir = "pl_PL" ]
204
-		then
205
-			subdir="pl"
206
-			nosubdir
207
-
208
-			# If the file was written, include the right
209
-			# header, menu files and footer
210
-			if [ -e "$wmldir/$subdir/$wmlfile" ]
127
+			# If the translation is Polish, include the
128
+			# correct header, menu files and footer
129
+			if [ $subdir = "pl" ]
211 130
 			then
212 131
 				# Head
213 132
 				orig_head=`grep '#include "head.wmi"' "$wmldir/$subdir/$wmlfile"`
... ...
@@ -233,17 +152,10 @@ for file in $po ; do
233 152
 				# Footer
234 153
 				echo '#include "pl/foot.wmi"' >> "$wmldir/$subdir/$wmlfile"
235 154
 			fi
236
-		fi
237 155
 
238
-		# If the file is an Arabic translation, include
239
-		# the right header, css, menu files and footer
156
+			# If the translation is Arabic, include the
157
+			# correct header, css, menu files and footer
240 158
 			if [ $subdir = "ar" ]
241
-		then
242
-			# Convert the file first
243
-			nosubdir
244
-
245
-			# If it was written, do the following
246
-			if [ -e "$wmldir/$subdir/$wmlfile" ]
247 159
 			then
248 160
 				# Head
249 161
 				orig_head=`grep '#include "head.wmi"' "$wmldir/$subdir/$wmlfile"`
... ...
@@ -270,46 +182,50 @@ for file in $po ; do
270 182
 				# Footer
271 183
 				echo '#include "ar/foot.wmi"' >> "$wmldir/$subdir/$wmlfile"
272 184
 			fi
273
-		fi
274 185
 
275
-		# Convert everything else
276
-		if [[ $subdir != "en" && $subdir != "zh_CN" && $subdir != "nb" && $subdir != "sv" && $subdir != "ar" ]]
186
+			# If the directory does not include sidenav.wmi,
187
+			# copy it from the English directory (only if
188
+			# the English directory has this file)
189
+			if [[ ! -e "$wmldir/$subdir/sidenav.wmi" && -e "$wmldir/en/sidenav.wmi" ]]
277 190
 			then
278
-			nosubdir
191
+				cp "$wmldir/en/sidenav.wmi" "$wmldir/$subdir"
279 192
 			fi
280
-	else
281
-		# If the current language is "zh_CN" use "zh-cn" instead
282
-		if [ $lang = "zh_CN" ]
283
-		then
284
-			lang="zh-cn"
285
-			subdir
286 193
 		fi
194
+	}	
287 195
 
288
-		# If the current language is "nb" use "no" instead
289
-		if [ $lang = "nb" ]
196
+	# Convert translations to directories such as website/torbrowser/nb/.
197
+	# Again, po4a will write the file and then delete it if less than 80% has been translated
198
+	function subdir {
199
+		# The location of the english wml file
200
+                english="$wmldir/$subdir/en/$wmlfile"
201
+
202
+		# Convert the files
203
+		po4a-translate -f wml -m "$english" -p "$file" -l "$wmldir/$subdir/$lang/$wmlfile" --master-charset utf-8 -L utf-8 -o customtag="$customtag" -o nodefault="$nodefault"
204
+
205
+		# Check to see if the file was written
206
+		if [ -e "$wmldir/$subdir/$lang/$wmlfile" ]
290 207
 		then
291
-			lang="no"
292
-			subdir
293
-		fi
208
+			# Remove last three lines in file
209
+			sed -i -e :a -e '$d;N;2,3ba' -e 'P;D' "$wmldir/$subdir/$lang/$wmlfile"
294 210
 
295
-		# If the current language is "sv" use "se" instead
296
-		if [ $lang = "sv" ]
211
+			# Remove a specific comment from a specific file
212
+			if [ $wmlfile == "download-easy.wml" ]			
297 213
 			then
298
-			lang="se"
299
-			subdir
214
+				translator_comment="# Translators: please point to the version of TBB in your language, if there is one."
215
+				sed -i "s/$translator_comment//" "$wmldir/$subdir/$lang/$wmlfile"
300 216
 			fi
301 217
 
302
-		# If the current language is "pl_PL" use "pl" instead
303
-		if [ $lang = "pl_PL" ]
218
+			# Include the English footer for most of the
219
+			# translations 
220
+			if [[ $lang != "ar" && $lang != "pl" ]]
304 221
 			then
305
-			lang="pl"
306
-			subdir
222
+				echo '#include "foot.wmi"' >> "$wmldir/$subdir/$lang/$wmlfile"
223
+			fi
307 224
 
308
-			# If the file was written, include the right
309
-			# header, menu files and footer
310
-			if [ -e "$wmldir/$subdir/$lang/$wmlfile" ]
225
+                        # If the translation is Polish, include the
226
+                        # correct header, menu files and footer
227
+			if [ $lang = "pl" ]
311 228
 			then
312
-				# Head
313 229
 				orig_head=`grep '#include "head.wmi"' "$wmldir/$subdir/$lang/$wmlfile"`
314 230
 				new_head=`echo $orig_head | sed s@head.wmi@pl/head.wmi@`
315 231
 				sed -i "s@$orig_head@$new_head@" "$wmldir/$subdir/$lang/$wmlfile"
... ...
@@ -334,17 +250,9 @@ for file in $po ; do
334 250
 				echo '#include "pl/foot.wmi"' >> "$wmldir/$subdir/$lang/$wmlfile"
335 251
 			fi
336 252
 
337
-		fi
338
-
339 253
 			# If the file is an Arabic translation, include the
340
-		# right header, css, menu files and footer
254
+			# correct header, css, menu files and footer
341 255
 			if [ $lang = "ar" ]
342
-		then
343
-			# Convert the file first
344
-			subdir
345
-
346
-			# If it was written, do the following
347
-			if [ -e "$wmldir/$subdir/$lang/$wmlfile" ]
348 256
 			then
349 257
 				# Head
350 258
 				orig_head=`grep '#include "head.wmi"' "$wmldir/$subdir/$lang/$wmlfile"`
... ...
@@ -371,10 +279,85 @@ for file in $po ; do
371 279
 				# Footer
372 280
 				echo '#include "ar/foot.wmi"' >> "$wmldir/$subdir/$lang/$wmlfile"
373 281
 			fi
282
+
283
+			# If the directory does not include sidenav.wmi,
284
+			# copy it from the English directory (only if 
285
+			# the English directory has this file)
286
+			if [[ ! -e "$wmldir/$subdir/$lang/sidenav.wmi" && -e "$wmldir/$subdir/en/sidenav.wmi" ]]
287
+			then
288
+				cp "$wmldir/$subdir/en/sidenav.wmi" "$wmldir/$subdir/$lang/"
289
+			fi
290
+		fi
291
+	}
292
+
293
+	# If $onedirup is equal to $lang, that means we do not have a
294
+	# subdirectory.
295
+	if [ $onedirup == $lang ]
296
+	then
297
+		# If the current subdirectory is "zh_CN" use "zh-cn" instead
298
+		if [ $subdir = "zh_CN" ]
299
+		then
300
+			subdir="zh-cn"
301
+			nosubdir
302
+		fi
303
+		
304
+		# If the current directory is "nb" use "no" instead
305
+		if [ $subdir = "nb" ]
306
+		then
307
+			subdir="no"
308
+			nosubdir
309
+		fi
310
+
311
+		# If the current directory is "sv" use "se" instead
312
+		if [ $subdir = "sv" ]
313
+		then
314
+			subdir="se"
315
+			nosubdir
316
+		fi
317
+
318
+		# If the current directory is "pl_PL" use "pl" instead
319
+		if [ $subdir = "pl_PL" ]
320
+		then
321
+			subdir="pl"
322
+			nosubdir
323
+		fi
324
+
325
+		# Convert everything else
326
+		if [[ $subdir != "en" && $subdir != "zh_CN" && $subdir != "nb" && $subdir != "sv" && $subdir != "pl_PL" ]]
327
+		then
328
+			nosubdir
329
+		fi
330
+	else
331
+		# If the current language is "zh_CN" use "zh-cn" instead
332
+		if [ $lang = "zh_CN" ]
333
+		then
334
+			lang="zh-cn"
335
+			subdir
336
+		fi
337
+
338
+		# If the current language is "nb" use "no" instead
339
+		if [ $lang = "nb" ]
340
+		then
341
+			lang="no"
342
+			subdir
343
+		fi
344
+
345
+		# If the current language is "sv" use "se" instead
346
+		if [ $lang = "sv" ]
347
+		then
348
+			lang="se"
349
+			subdir
350
+		fi
351
+	
352
+		# If the current language is "pl_PL" use "pl" instead
353
+		if [ $lang = "pl_PL" ]
354
+		then
355
+			lang="pl"
356
+			subdir
374 357
 		fi
375 358
 
376 359
 		# Convert everything else
377
-		if [[ $lang != "en" && $lang != "zh_CN" && $lang != "nb" && $lang != "sv" && $lang != "ar" ]]
360
+		if [[ $lang != "en" && $lang != "zh_CN" && $lang != "nb" && $lang != "sv" && $lang != "pl_PL" ]]
378 361
 		then
379 362
 			subdir
380 363
 		fi
381 364