0471b290c9a9c91d8b98460302f658f7f2d6c38d
Runa A. Sandvik put the scripts in website

Runa A. Sandvik authored 15 years ago

1) #!/bin/bash
2) #
3) # Author: Runa Sandvik, <runa.sandvik@gmail.com>
4) # Google Summer of Code 2009
5) # 
6) # This is Free Software (GPLv3)
7) # http://www.gnu.org/licenses/gpl-3.0.txt
8) #
9) # This script will convert all the translated po files back to wml
10) # files.
11) #
12) # For more information, see the HOWTO and README in
13) # translation/tools/gsoc09.
14) #
15) 
16) ### start config ###
17) 
18) # Location of the wml files
19) wmldir="$PWD"
20) 
21) # Location of the po files,
Runa A. Sandvik updated scripts with new path

Runa A. Sandvik authored 14 years ago

22) podir="`dirname $wmldir`/translation/projects/website/po"
Runa A. Sandvik put the scripts in website

Runa A. Sandvik authored 15 years ago

23) 
24) # A lot of the wml files have custom tags. These tags have been defined
25) # in website/include/versions.wmi. Tags that people usually forget to close,
26) # as well as tags that are not defined in versions.wmi have been added.
27) # See: https://svn.torproject.org/svn/website/trunk/include/versions.wmi
Steven Murdoch Add a link tag for svnproje...

Steven Murdoch authored 14 years ago

28) customtag=`echo $(cat "$wmldir/include/versions.wmi" | awk '{ printf "<%s> " , $2 }' | sed 's/<>//g') "<svnsandbox> <svnwebsite> <svnprojects> <input> <hr> <br> <img> <gitblob>"`
Runa A. Sandvik put the scripts in website

Runa A. Sandvik authored 15 years ago

29) 
30) # We also need to use the nodefault option of po4a; space separated list
31) # of tags that the module should not try to set by default in any
32) # category. For now, we only need the input tag.
33) nodefault='<input>'
34) 
35) ### end config ###
36) 
37) # Create a lockfile to make sure that only one instance of the script
38) # can run at any time.
39) LOCKFILE=po2wml.lock
40) 
41) if lockfile -! -l 60 -r 3 "$LOCKFILE"; 
42) then
43) 	echo "unable to acquire lock" >2
44) 	exit 1
45) fi
46) 
47) trap "rm -f '$PWD/$LOCKFILE'" exit
48) 
49) # Check if translation/projects/website exist, i.e. has been checked out
50) if [ ! -d $podir ]
51) then
52) 	echo "Have you remembered to check out translation/projects/website?"
53) 	exit 1
54) fi
55) 
56) # cd to the right directory so we can commit the files later
57) cd "$wmldir"
58) 
59) # We need to find the po files
60) po=`find $podir -regex '^'$podir'/.*/.*\.po' -type f`
61) 
62) # For every wml, update po
63) for file in $po ; do
Runa A. Sandvik call validate.py before con...

Runa A. Sandvik authored 13 years ago

64) 
65) 	# Validate input and write results to a log file
66) 	validate_script="`dirname $wmldir`/translation/tools/validate.py"
Runa A. Sandvik updated script and new tran...

Runa A. Sandvik authored 13 years ago

67) 	validate_log="`dirname $wmldir`/validate/website-validate.log"
Runa A. Sandvik call validate.py before con...

Runa A. Sandvik authored 13 years ago

68) 	python "$validate_script" -i "$file" -l	"$validate_log"
Runa A. Sandvik put the scripts in website

Runa A. Sandvik authored 15 years ago

69) 	
70) 	# Get the basename of the file we are dealing with
71) 	pofile=`basename $file`
72) 
73) 	# Strip the file for its original extension and the translation
74) 	# priority, and add .wml
75) 	wmlfile="`echo $pofile | cut -d . -f 2`.wml"	
76) 
77) 	# Find out what directory the file is in.
78) 	indir=`dirname $file`
79) 
80) 	# We also need to know what one directory up is
81) 	onedirup=`dirname $indir`
82) 
83) 	# We need to find out what subdirectory we are in
84) 	subdir=`dirname $file | sed "s#$onedirup/##"`
85) 
86) 	# And which language we are dealing with
87) 	lang=`dirname $indir | sed "s#$podir/##"`
88) 
89) 	# Time to write the translated wml file.
90) 	# The translated document is written if 80% or more of the po
Runa A. Sandvik because functions are nice

Runa A. Sandvik authored 14 years ago

91) 	# file has been translated. Example: Use '-k 21' to set this
92) 	# number down to 21%. Also, po4a-translate will only write the
93) 	# translated document if 80% or more has been translated.
94) 	# However, it will delete the wml if less than 80% has been
Runa A. Sandvik put the scripts in website

Runa A. Sandvik authored 15 years ago

95) 	# translated. To avoid having our current, translated wml files
Runa A. Sandvik because functions are nice

Runa A. Sandvik authored 14 years ago

96) 	# deleted, convert the po to a temp wml first. If this file was
97) 	# actually written, rename it to wml.
Runa A. Sandvik put the scripts in website

Runa A. Sandvik authored 15 years ago

98) 
Runa A. Sandvik because functions are nice

Runa A. Sandvik authored 14 years ago

99) 	# Convert translations to directories such as website/nb/.
100) 	function nosubdir {
Runa A. Sandvik put the scripts in website

Runa A. Sandvik authored 15 years ago

101) 		# The location of the english wml file
102) 		english="$wmldir/en/$wmlfile"
103) 
Runa A. Sandvik do not keep old translations

Runa A. Sandvik authored 14 years ago

104) 		# Convert the translated file. Note that po4a will write the file and then delete it if less than 80% has been translated
105) 		po4a-translate -f wml -m "$english" -p "$file" -l "$wmldir/$subdir/$wmlfile" --master-charset utf-8 -L utf-8 -o customtag="$customtag" -o nodefault="$nodefault"
Runa A. Sandvik because functions are nice

Runa A. Sandvik authored 14 years ago

106) 
107) 		# Check to see if the file was written
Runa A. Sandvik do not keep old translations

Runa A. Sandvik authored 14 years ago

108)                 if [ -e "$wmldir/$subdir/$wmlfile" ]
Runa A. Sandvik if the directory is zh_CN w...

Runa A. Sandvik authored 14 years ago

109) 		then
Runa A. Sandvik because functions are nice

Runa A. Sandvik authored 14 years ago

110)                         # Remove last three lines in file
111) 			sed -i -e :a -e '$d;N;2,3ba' -e 'P;D' "$wmldir/$subdir/$wmlfile"
112) 
Runa A. Sandvik automatically fix mirrors.w...

Runa A. Sandvik authored 14 years ago

113) 			# If the file is mirrors.wml, include mirrors-table.wmi
114) 			if [ $wmlfile == "mirrors.wml" ]
115) 			then
116) 				sed -i 's/<!--PO4ASHARPBEGIN/#/' "$wmldir/$subdir/$wmlfile"
117) 				sed -i 's/PO4ASHARPEND-->//' "$wmldir/$subdir/$wmlfile"
118) 			fi
Runa A. Sandvik make sure arabic translatio...

Runa A. Sandvik authored 13 years ago

119) 
Runa A. Sandvik update po2wml to include Po...

Runa A. Sandvik authored 13 years ago

120) 			# Include the English footer for most of the
121) 			# translations
Runa A. Sandvik Move download/en/lang.wmi t...

Runa A. Sandvik authored 13 years ago

122) 			if [[ $subdir != "ar" && $subdir != "pl" && $subdir != "de" && $subdir != "fa" ]]
Runa A. Sandvik make sure arabic translatio...

Runa A. Sandvik authored 13 years ago

123) 			then
Runa A. Sandvik make sure arabic translatio...

Runa A. Sandvik authored 13 years ago

124) 				echo '#include "foot.wmi"' >> "$wmldir/$subdir/$wmlfile"
Runa A. Sandvik make sure arabic translatio...

Runa A. Sandvik authored 13 years ago

125) 			fi
Runa A. Sandvik update po2wml to include Po...

Runa A. Sandvik authored 13 years ago

126) 
Runa A. Sandvik update po2wml to make thing...

Runa A. Sandvik authored 13 years ago

127) 			# If the translation is Polish, include the
128) 			# correct header, menu files and footer
129) 			if [ $subdir = "pl" ]
130) 			then
131) 				# Head
132) 				orig_head=`grep '#include "head.wmi"' "$wmldir/$subdir/$wmlfile"`
133) 				new_head=`echo $orig_head | sed s@head.wmi@pl/head.wmi@`
134) 				sed -i "s@$orig_head@$new_head@" "$wmldir/$subdir/$wmlfile"
135) 
136) 				# Side (not all files include this)
137) 				orig_side=`grep '#include "side.wmi"' "$wmldir/$subdir/$wmlfile"`
138) 				if [ -n "$orig_side" ]
139) 				then
140) 					new_side=`echo '#include "pl/side.wmi"'`
141) 					sed -i "s@$orig_side@$new_side@" "$wmldir/$subdir/$wmlfile"
142) 				fi
143) 
144) 				# Info (not all files include this)
145) 				orig_info=`grep '#include "info.wmi"' "$wmldir/$subdir/$wmlfile"`
146) 				if [ -n "$orig_info" ]
147) 				then
148) 					new_info=`echo '#include "pl/info.wmi"'`
149) 					sed -i "s@$orig_info@$new_info@" "$wmldir/$subdir/$wmlfile"
150) 				fi
151) 
152) 				# Footer
153) 				echo '#include "pl/foot.wmi"' >> "$wmldir/$subdir/$wmlfile"
154) 			fi
155) 
Runa A. Sandvik make sure we include the Ge...

Runa A. Sandvik authored 13 years ago

156)                         # If the translation is German, include the
157)                         # correct header, menu files and footer
158)                         if [ $subdir = "de" ]
159)                         then
160)                                 # Head
161)                                 orig_head=`grep '#include "head.wmi"' "$wmldir/$subdir/$wmlfile"`
162)                                 new_head=`echo $orig_head | sed s@head.wmi@de/head.wmi@`
163)                                 sed -i "s@$orig_head@$new_head@" "$wmldir/$subdir/$wmlfile"
164) 
165)                                 # Side (not all files include this)
166)                                 orig_side=`grep '#include "side.wmi"' "$wmldir/$subdir/$wmlfile"`
167)                                 if [ -n "$orig_side" ]
168)                                 then
169)                                         new_side=`echo '#include "de/side.wmi"'`
170)                                         sed -i "s@$orig_side@$new_side@" "$wmldir/$subdir/$wmlfile"
171)                                 fi  
172) 
173)                                 # Info (not all files include this)
174)                                 orig_info=`grep '#include "info.wmi"' "$wmldir/$subdir/$wmlfile"`
175)                                 if [ -n "$orig_info" ]
176)                                 then
177)                                         new_info=`echo '#include "de/info.wmi"'`
178)                                         sed -i "s@$orig_info@$new_info@" "$wmldir/$subdir/$wmlfile"
179)                                 fi  
180) 
181)                                 # Footer
182)                                 echo '#include "de/foot.wmi"' >> "$wmldir/$subdir/$wmlfile"
183)                         fi  
184) 
Runa A. Sandvik update po2wml to make thing...

Runa A. Sandvik authored 13 years ago

185) 			# If the translation is Arabic, include the
186) 			# correct header, css, menu files and footer
187) 			if [ $subdir = "ar" ]
188) 			then
189) 				# Head
190) 				orig_head=`grep '#include "head.wmi"' "$wmldir/$subdir/$wmlfile"`
191) 				temp_head=`echo $orig_head | sed s@head.wmi@ar/head.wmi@`
192) 				new_head=`echo $temp_head 'STYLESHEET="css/master-rtl.css"'`
193) 				sed -i "s@$orig_head@$new_head@" "$wmldir/$subdir/$wmlfile"
194) 
195) 				# Side (not all files include this)
196) 				orig_side=`grep '#include "side.wmi"' "$wmldir/$subdir/$wmlfile"`
197) 				if [ -n "$orig_side" ]
198) 				then
199) 					new_side=`echo '#include "ar/side.wmi"'`
200) 					sed -i "s@$orig_side@$new_side@" "$wmldir/$subdir/$wmlfile"
201) 				fi
202) 
203) 				# Info (not all files include this)
204) 				orig_info=`grep '#include "info.wmi"' "$wmldir/$subdir/$wmlfile"`
205) 				if [ -n "$orig_info" ]
206) 				then
207) 					new_info=`echo '#include "ar/info.wmi"'`
208) 					sed -i "s@$orig_info@$new_info@" "$wmldir/$subdir/$wmlfile"
209) 				fi
210) 
211) 				# Footer
212) 				echo '#include "ar/foot.wmi"' >> "$wmldir/$subdir/$wmlfile"
213) 			fi
214) 
Andrew Lewman make a farsi exception as w...

Andrew Lewman authored 13 years ago

215) 			# If the translation is Farsi, include the
216) 			# correct header, css, menu files and footer
217) 			if [ $subdir = "fa" ]
218) 			then
219) 				# Head
220) 				orig_head=`grep '#include "head.wmi"' "$wmldir/$subdir/$wmlfile"`
221) 				temp_head=`echo $orig_head | sed s@head.wmi@fa/head.wmi@`
222) 				new_head=`echo $temp_head 'STYLESHEET="css/master-rtl.css"'`
223) 				sed -i "s@$orig_head@$new_head@" "$wmldir/$subdir/$wmlfile"
224) 
225) 				# Side (not all files include this)
226) 				orig_side=`grep '#include "side.wmi"' "$wmldir/$subdir/$wmlfile"`
227) 				if [ -n "$orig_side" ]
228) 				then
229) 					new_side=`echo '#include "fa/side.wmi"'`
230) 					sed -i "s@$orig_side@$new_side@" "$wmldir/$subdir/$wmlfile"
231) 				fi
232) 
233) 				# Info (not all files include this)
234) 				orig_info=`grep '#include "info.wmi"' "$wmldir/$subdir/$wmlfile"`
235) 				if [ -n "$orig_info" ]
236) 				then
237) 					new_info=`echo '#include "fa/info.wmi"'`
238) 					sed -i "s@$orig_info@$new_info@" "$wmldir/$subdir/$wmlfile"
239) 				fi
240) 
241) 				# Footer
242) 				echo '#include "fa/foot.wmi"' >> "$wmldir/$subdir/$wmlfile"
243) 			fi
244) 
Runa A. Sandvik update po2wml to include Po...

Runa A. Sandvik authored 13 years ago

245) 			# If the directory does not include sidenav.wmi,
246) 			# copy it from the English directory (only if
247) 			# the English directory has this file)
248) 			if [[ ! -e "$wmldir/$subdir/sidenav.wmi" && -e "$wmldir/en/sidenav.wmi" ]]
249) 			then
250) 				cp "$wmldir/en/sidenav.wmi" "$wmldir/$subdir"
251) 			fi
Runa A. Sandvik because functions are nice

Runa A. Sandvik authored 14 years ago

252) 		fi
253) 	}	
Runa A. Sandvik if the directory is zh_CN w...

Runa A. Sandvik authored 14 years ago

254) 
Runa A. Sandvik do not keep old translations

Runa A. Sandvik authored 14 years ago

255) 	# Convert translations to directories such as website/torbrowser/nb/.
256) 	# Again, po4a will write the file and then delete it if less than 80% has been translated
Runa A. Sandvik because functions are nice

Runa A. Sandvik authored 14 years ago

257) 	function subdir {
258) 		# The location of the english wml file
259)                 english="$wmldir/$subdir/en/$wmlfile"
Runa A. Sandvik remove last three lines of...

Runa A. Sandvik authored 14 years ago

260) 
Runa A. Sandvik because functions are nice

Runa A. Sandvik authored 14 years ago

261) 		# Convert the files
Runa A. Sandvik fix download.wml when we co...

Runa A. Sandvik authored 13 years ago

262) 		if [ $wmlfile = "download.wml" ]
263) 		then
264) 			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" -o ontagerror="silent"
265) 		else
266) 			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"
267) 		fi
Runa A. Sandvik remove last three lines of...

Runa A. Sandvik authored 14 years ago

268) 
Runa A. Sandvik because functions are nice

Runa A. Sandvik authored 14 years ago

269) 		# Check to see if the file was written
Runa A. Sandvik do not keep old translations

Runa A. Sandvik authored 14 years ago

270) 		if [ -e "$wmldir/$subdir/$lang/$wmlfile" ]
Runa A. Sandvik because functions are nice

Runa A. Sandvik authored 14 years ago

271) 		then
272) 			# Remove last three lines in file
273) 			sed -i -e :a -e '$d;N;2,3ba' -e 'P;D' "$wmldir/$subdir/$lang/$wmlfile"
274) 
Runa A. Sandvik updated translations for th...

Runa A. Sandvik authored 13 years ago

275) 			# Remove a specific comment from a specific file
276) 			if [ $wmlfile == "download-easy.wml" ]			
277) 			then
278) 				translator_comment="# Translators: please point to the version of TBB in your language, if there is one."
279) 				sed -i "s/$translator_comment//" "$wmldir/$subdir/$lang/$wmlfile"
280) 			fi
Runa A. Sandvik remove translator comments...

Runa A. Sandvik authored 13 years ago

281) 
Runa A. Sandvik fix download.wml when we co...

Runa A. Sandvik authored 13 years ago

282) 			# Fix download.wml
283)                         if [ $wmlfile = "download.wml" ]
284) 			then
285) 				sed -i 's/<!--PO4ASHARPBEGINinclude <lang.wmi>/#include <lang.wmi>/g' "$wmldir/$subdir/$lang/$wmlfile"
286) 				sed -i 's/<!--PO4ASHARPBEGINinclude <foot.wmi>//g' "$wmldir/$subdir/$lang/$wmlfile"
287) 				sed -i 's/<!--PO4ASHARPBEGIN//g;s/PO4ASHARPEND-->//g' "$wmldir/$subdir/$lang/$wmlfile"
288) 				echo "#include <foot.wmi>" >> "$wmldir/$subdir/$lang/$wmlfile"
289) 			fi
290) 
Runa A. Sandvik update po2wml to include Po...

Runa A. Sandvik authored 13 years ago

291) 			# Include the English footer for most of the
292) 			# translations 
Runa A. Sandvik Move download/en/lang.wmi t...

Runa A. Sandvik authored 13 years ago

293) 			if [[ $lang != "ar" && $lang != "pl" && $lang != "de" && $lang != "fa" ]]
Runa A. Sandvik make sure arabic translatio...

Runa A. Sandvik authored 13 years ago

294) 			then
Runa A. Sandvik make sure arabic translatio...

Runa A. Sandvik authored 13 years ago

295) 				echo '#include "foot.wmi"' >> "$wmldir/$subdir/$lang/$wmlfile"
Runa A. Sandvik make sure arabic translatio...

Runa A. Sandvik authored 13 years ago

296) 			fi
Runa A. Sandvik update po2wml to include Po...

Runa A. Sandvik authored 13 years ago

297) 
Runa A. Sandvik updated the script to inclu...

Runa A. Sandvik authored 13 years ago

298) 			# If the file is overview.wml, make sure we
299) 			# include the correct set of images
300) 			if [ $wmlfile = "overview.wml" ] && [[ $lang = "de" || $lang = "es" || $lang = "fr" || 
301) 				$lang = "ja" || $lang = "nl" || $lang = "no" || $lang = "pl" || $lang = "ru" || 
302) 				$lang = "zh" ]]
303) 			then
304) 				sed -i "s/htw1.png/htw1_$lang.png/" "$wmldir/$subdir/$lang/$wmlfile"
305) 				sed -i "s/htw2.png/htw2_$lang.png/" "$wmldir/$subdir/$lang/$wmlfile"
306) 				sed -i "s/htw3.png/htw3_$lang.png/" "$wmldir/$subdir/$lang/$wmlfile"
307) 			fi
308) 
Runa A. Sandvik update po2wml to make thing...

Runa A. Sandvik authored 13 years ago

309)                         # If the translation is Polish, include the
310)                         # correct header, menu files and footer
311) 			if [ $lang = "pl" ]
312) 			then
313) 				orig_head=`grep '#include "head.wmi"' "$wmldir/$subdir/$lang/$wmlfile"`
314) 				new_head=`echo $orig_head | sed s@head.wmi@pl/head.wmi@`
315) 				sed -i "s@$orig_head@$new_head@" "$wmldir/$subdir/$lang/$wmlfile"
316) 
317) 				# Side (not all files include this)
318) 				orig_side=`grep '#include "side.wmi"' "$wmldir/$subdir/$lang/$wmlfile"`
319) 				if [ -n "$orig_side" ]
320) 				then
321) 					new_side=`echo '#include "pl/side.wmi"'`
322) 					sed -i "s@$orig_side@$new_side@" "$wmldir/$subdir/$lang/$wmlfile"
323) 				fi
324) 
325) 				# Info (not all files include this)
326) 				orig_info=`grep '#include "info.wmi"' "$wmldir/$subdir/$lang/$wmlfile"`
327) 				if [ -n "$orig_info" ]
328) 				then
329) 					new_info=`echo '#include "pl/info.wmi"'`
330) 					sed -i "s@$orig_info@$new_info@" "$wmldir/$subdir/$lang/$wmlfile"
331) 				fi
332) 
333) 				# Footer
334) 				echo '#include "pl/foot.wmi"' >> "$wmldir/$subdir/$lang/$wmlfile"
335) 			fi
336) 
Runa A. Sandvik make sure we include the Ge...

Runa A. Sandvik authored 13 years ago

337)                         # If the translation is German, include the
338)                         # correct header, menu files and footer
339)                         if [ $lang = "de" ]
340)                         then
341)                                 orig_head=`grep '#include "head.wmi"' "$wmldir/$subdir/$lang/$wmlfile"`
342)                                 new_head=`echo $orig_head | sed s@head.wmi@de/head.wmi@`
343)                                 sed -i "s@$orig_head@$new_head@" "$wmldir/$subdir/$lang/$wmlfile"
344) 
345)                                 # Side (not all files include this)
346)                                 orig_side=`grep '#include "side.wmi"' "$wmldir/$subdir/$lang/$wmlfile"`
347)                                 if [ -n "$orig_side" ]
348)                                 then
349)                                         new_side=`echo '#include "de/side.wmi"'`
350)                                         sed -i "s@$orig_side@$new_side@" "$wmldir/$subdir/$lang/$wmlfile"
351)                                 fi
352) 
353)                                 # Info (not all files include this)
354)                                 orig_info=`grep '#include "info.wmi"' "$wmldir/$subdir/$lang/$wmlfile"`
355)                                 if [ -n "$orig_info" ]
356)                                 then
357)                                         new_info=`echo '#include "de/info.wmi"'`
358)                                         sed -i "s@$orig_info@$new_info@" "$wmldir/$subdir/$lang/$wmlfile"
359)                                 fi
360) 
361)                                 # Footer
362)                                 echo '#include "de/foot.wmi"' >> "$wmldir/$subdir/$lang/$wmlfile"
Runa A. Sandvik get the po2wml script ready...

Runa A. Sandvik authored 13 years ago

363) 
364) 				# If the file is tor-doc-windows, make
365) 				# sure we include the German video
366) 				if [ $wmlfile = "tor-doc-windows.wml" ]
367) 				then
Runa A. Sandvik update the script to includ...

Runa A. Sandvik authored 13 years ago

368) 					orig_video=`grep src=\"https:\/\/media.torproject.org\/video\/2009-install-and-use-tor.ogv\" "$wmldir/$subdir/$lang/$wmlfile"`
Runa A. Sandvik include both the English an...

Runa A. Sandvik authored 13 years ago

369) 					translated_video=`echo "<p>Das nachfolgende Video, wurde von SemperVideo erstellt.</p> <p><video id=\"v1\" src=\"https://media.torproject.org/video/2011-install-and-use-tor-de.ogv\" autobuffer=\"true\" controls=\"controls\"></video></p>"`
370) 					new_video=`echo "$orig_video $translated_video"`
Runa A. Sandvik update the script to includ...

Runa A. Sandvik authored 13 years ago

371) 				
372) 					sed -i "s@$orig_video@$new_video@" "$wmldir/$subdir/$lang/$wmlfile"
Runa A. Sandvik get the po2wml script ready...

Runa A. Sandvik authored 13 years ago

373) 				fi
Runa A. Sandvik make sure we include the Ge...

Runa A. Sandvik authored 13 years ago

374)                         fi
375) 
Runa A. Sandvik update po2wml to make thing...

Runa A. Sandvik authored 13 years ago

376) 			# If the file is an Arabic translation, include the
377) 			# correct header, css, menu files and footer
378) 			if [ $lang = "ar" ]
379) 			then
380) 				# Head
381) 				orig_head=`grep '#include "head.wmi"' "$wmldir/$subdir/$lang/$wmlfile"`
382) 				temp_head=`echo $orig_head | sed s@head.wmi@ar/head.wmi@`
383) 				new_head=`echo $temp_head 'STYLESHEET="css/master-rtl.css"'`
384) 				sed -i "s@$orig_head@$new_head@" "$wmldir/$subdir/$lang/$wmlfile"
385) 
386) 				# Side (not all files include this)
387) 				orig_side=`grep '#include "side.wmi"' "$wmldir/$subdir/$lang/$wmlfile"`
388) 				if [ -n "$orig_side" ]
389) 				then
390) 					new_side=`echo '#include "ar/side.wmi"'`
391) 					sed -i "s@$orig_side@$new_side@" "$wmldir/$subdir/$lang/$wmlfile"
392) 				fi
393) 
394) 				# Info (not all files include this)
395) 				orig_info=`grep '#include "info.wmi"' "$wmldir/$subdir/$lang/$wmlfile"`
396) 				if [ -n "$orig_info" ]
397) 				then
398) 					new_info=`echo '#include "ar/info.wmi"'`
399) 					sed -i "s@$orig_info@$new_info@" "$wmldir/$subdir/$lang/$wmlfile"
400) 				fi
401) 
402) 				# Footer
403) 				echo '#include "ar/foot.wmi"' >> "$wmldir/$subdir/$lang/$wmlfile"
404) 			fi
405) 
Runa A. Sandvik update script to include va...

Runa A. Sandvik authored 13 years ago

406)                         # If the file is a Farsi translation, include the
407)                         # correct header, css, menu files and footer
408)                         if [ $lang = "fa" ]
409)                         then
410)                                 # Head
411)                                 orig_head=`grep '#include "head.wmi"' "$wmldir/$subdir/$lang/$wmlfile"`
412)                                 temp_head=`echo $orig_head | sed s@head.wmi@fa/head.wmi@`
413)                                 new_head=`echo $temp_head 'STYLESHEET="css/master-rtl.css"'`
414)                                 sed -i "s@$orig_head@$new_head@" "$wmldir/$subdir/$lang/$wmlfile"
415) 
416)                                 # Side (not all files include this)
417)                                 orig_side=`grep '#include "side.wmi"' "$wmldir/$subdir/$lang/$wmlfile"`
418)                                 if [ -n "$orig_side" ]
419)                                 then
420)                                         new_side=`echo '#include "fa/side.wmi"'`
421)                                         sed -i "s@$orig_side@$new_side@" "$wmldir/$subdir/$lang/$wmlfile"
422)                                 fi
423) 
424)                                 # Info (not all files include this)
425)                                 orig_info=`grep '#include "info.wmi"' "$wmldir/$subdir/$lang/$wmlfile"`
426)                                 if [ -n "$orig_info" ]
427)                                 then
428)                                         new_info=`echo '#include "fa/info.wmi"'`
429)                                         sed -i "s@$orig_info@$new_info@" "$wmldir/$subdir/$lang/$wmlfile"
430)                                 fi
431) 
432)                                 # Footer
433)                                 echo '#include "fa/foot.wmi"' >> "$wmldir/$subdir/$lang/$wmlfile"
434)                         fi
435) 
Runa A. Sandvik update po2wml to include Po...

Runa A. Sandvik authored 13 years ago

436) 			# If the directory does not include sidenav.wmi,
437) 			# copy it from the English directory (only if 
438) 			# the English directory has this file)
439) 			if [[ ! -e "$wmldir/$subdir/$lang/sidenav.wmi" && -e "$wmldir/$subdir/en/sidenav.wmi" ]]
440) 			then
441) 				cp "$wmldir/$subdir/en/sidenav.wmi" "$wmldir/$subdir/$lang/"
442) 			fi
Runa A. Sandvik because functions are nice

Runa A. Sandvik authored 14 years ago

443) 		fi
444) 	}
445) 
446) 	# If $onedirup is equal to $lang, that means we do not have a
447) 	# subdirectory.
448) 	if [ $onedirup == $lang ]
449) 	then
Runa A. Sandvik updated the script to handl...

Runa A. Sandvik authored 13 years ago

450) 		# If the current directory is "pl_PL" use "pl" instead
451) 		if [ $subdir = "pl_PL" ]
Runa A. Sandvik we want pt-br not pt_BR, up...

Runa A. Sandvik authored 13 years ago

452) 		then
Runa A. Sandvik updated the script to handl...

Runa A. Sandvik authored 13 years ago

453) 			subdir="pl"
Runa A. Sandvik we want pt-br not pt_BR, up...

Runa A. Sandvik authored 13 years ago

454) 			nosubdir
455) 		fi
Runa A. Sandvik updated the script to handl...

Runa A. Sandvik authored 13 years ago

456) 
Runa A. Sandvik quick fix for nb and sv

Runa A. Sandvik authored 14 years ago

457) 		# If the current directory is "nb" use "no" instead
458) 		if [ $subdir = "nb" ]
459) 		then
Runa A. Sandvik because functions are nice

Runa A. Sandvik authored 14 years ago

460) 			subdir="no"
461) 			nosubdir
Runa A. Sandvik quick fix for nb and sv

Runa A. Sandvik authored 14 years ago

462) 		fi
463) 
464) 		# If the current directory is "sv" use "se" instead
465) 		if [ $subdir = "sv" ]
466) 		then
Runa A. Sandvik because functions are nice

Runa A. Sandvik authored 14 years ago

467) 			subdir="se"
468) 			nosubdir
Runa A. Sandvik quick fix for nb and sv

Runa A. Sandvik authored 14 years ago

469) 		fi
470) 
Runa A. Sandvik problem in po2wml finally f...

Runa A. Sandvik authored 13 years ago

471)                 # If the current subdirectory is of the form "xx_XX",
472)                 # rename to "xx-xx" instead (except for pl_PL)
473)                 if [[ $subdir =~ "_" && $subdir != "pl_PL" ]]
474)                 then
475)                         subdir="`echo $subdir | sed s/_/-/ | tr '[A-Z]' '[a-z]'`"
476)                         nosubdir
477)                 fi  
478) 
Runa A. Sandvik if the directory is zh_CN w...

Runa A. Sandvik authored 14 years ago

479) 		# Convert everything else
Runa A. Sandvik updated the script to handl...

Runa A. Sandvik authored 13 years ago

480) 		if [[ $subdir != "en" && $subdir != "pl_PL" && ! ($subdir =~ "_") && $subdir != "nb" && $subdir != "sv" ]]
Runa A. Sandvik put the scripts in website

Runa A. Sandvik authored 15 years ago

481) 		then
Runa A. Sandvik because functions are nice

Runa A. Sandvik authored 14 years ago

482) 			nosubdir
Runa A. Sandvik put the scripts in website

Runa A. Sandvik authored 15 years ago

483) 		fi
484) 	else
Runa A. Sandvik updated the script to handl...

Runa A. Sandvik authored 13 years ago

485) 		# If the current language is "pl_PL" use "pl" instead
486) 		if [ $lang = "pl_PL" ]
Runa A. Sandvik we want pt-br not pt_BR, up...

Runa A. Sandvik authored 13 years ago

487) 		then
Runa A. Sandvik yet another minor fix for p...

Runa A. Sandvik authored 13 years ago

488) 			lang="pl"
Runa A. Sandvik we want pt-br not pt_BR, up...

Runa A. Sandvik authored 13 years ago

489) 			subdir
490) 		fi
491) 
Runa A. Sandvik quick fix for nb and sv

Runa A. Sandvik authored 14 years ago

492) 		# If the current language is "nb" use "no" instead
493) 		if [ $lang = "nb" ]
494) 		then
Runa A. Sandvik because functions are nice

Runa A. Sandvik authored 14 years ago

495) 			lang="no"
496) 			subdir
Runa A. Sandvik quick fix for nb and sv

Runa A. Sandvik authored 14 years ago

497) 		fi
498) 
499) 		# If the current language is "sv" use "se" instead
500) 		if [ $lang = "sv" ]
501) 		then
Runa A. Sandvik because functions are nice

Runa A. Sandvik authored 14 years ago

502) 			lang="se"
503) 			subdir
Runa A. Sandvik quick fix for nb and sv

Runa A. Sandvik authored 14 years ago

504) 		fi
Runa A. Sandvik problem in po2wml finally f...

Runa A. Sandvik authored 13 years ago

505) 
506)                 # If the current languge is of the form "xx_XX", rename
507)                 # to "xx-xx" instead (except for pl_PL)
508)                 if [[ $lang =~ "_" && $lang != "pl_PL" ]]
509)                 then
510)                         lang="`echo $lang | sed s/_/-/ | tr '[A-Z]' '[a-z]'`"
511)                         subdir
512)                 fi
513) 
Runa A. Sandvik if the directory is zh_CN w...

Runa A. Sandvik authored 14 years ago

514) 		# Convert everything else
Runa A. Sandvik updated the script to handl...

Runa A. Sandvik authored 13 years ago

515) 		if [[ $lang != "en" && $lang != "pl_PL" && ! ($lang =~ "_") && $lang != "nb" && $lang != "sv" ]]
Runa A. Sandvik put the scripts in website

Runa A. Sandvik authored 15 years ago

516) 		then
Runa A. Sandvik because functions are nice

Runa A. Sandvik authored 14 years ago

517) 			subdir