mirror of
https://github.com/torproject/webwml.git
synced 2024-11-30 13:10:33 +00:00
because functions are nice
This commit is contained in:
parent
a368df455c
commit
b01071c7bb
184
po2wml.sh
184
po2wml.sh
@ -83,170 +83,112 @@ for file in $po ; do
|
||||
|
||||
# Time to write the translated wml file.
|
||||
# The translated document is written if 80% or more of the po
|
||||
# file has been translated.
|
||||
# Example: Use '-k 21' to set this number down to 21%.
|
||||
|
||||
# The nice thing with po4a-translate is that it will only write
|
||||
# the translated document if 80% or more has been translated.
|
||||
# But it will delete the wml if less than 80% has been
|
||||
# file has been translated. Example: Use '-k 21' to set this
|
||||
# number down to 21%. Also, po4a-translate will only write the
|
||||
# translated document if 80% or more has been translated.
|
||||
# However, it will delete the wml if less than 80% has been
|
||||
# translated. To avoid having our current, translated wml files
|
||||
# deleted, we first convert the po to a temp wml. If this file
|
||||
# was written, we'll rename it.
|
||||
# deleted, convert the po to a temp wml first. If this file was
|
||||
# actually written, rename it to wml.
|
||||
|
||||
# If $onedirup is equal to $lang, that means we do not have a
|
||||
# subdirectory. Also, we don't want to convert english po back
|
||||
# to english wml.
|
||||
if [ $onedirup == $lang ]
|
||||
then
|
||||
# Convert translations to directories such as website/nb/.
|
||||
function nosubdir {
|
||||
# The location of the english wml file
|
||||
english="$wmldir/en/$wmlfile"
|
||||
|
||||
# Convert the files
|
||||
po4a-translate -f wml -m "$english" -p "$file" -l "$wmldir/$subdir/tmp-$wmlfile" --master-charset utf-8 -L utf-8 -o customtag="$customtag" -o nodefault="$nodefault"
|
||||
|
||||
# Check to see if the file was written
|
||||
if [ -e "$wmldir/$subdir/tmp-$wmlfile" ]
|
||||
then
|
||||
mv "$wmldir/$subdir/tmp-$wmlfile" "$wmldir/$subdir/$wmlfile"
|
||||
|
||||
# Remove last three lines in file
|
||||
sed -i -e :a -e '$d;N;2,3ba' -e 'P;D' "$wmldir/$subdir/$wmlfile"
|
||||
|
||||
# Include foot.wmi
|
||||
echo "#include <foot.wmi>" >> "$wmldir/$subdir/$wmlfile"
|
||||
fi
|
||||
}
|
||||
|
||||
# Convert translations to directories such as website/torbrowser/nb/.
|
||||
function subdir {
|
||||
# The location of the english wml file
|
||||
english="$wmldir/$subdir/en/$wmlfile"
|
||||
|
||||
# Convert the files
|
||||
po4a-translate -f wml -m "$english" -p "$file" -l "$wmldir/$subdir/$lang/tmp-$wmlfile" --master-charset utf-8 -L utf-8 -o customtag="$customtag" -o nodefault="$nodefault"
|
||||
|
||||
# Check to see if the file was written
|
||||
if [ -e "$wmldir/$subdir/$lang/tmp-$wmlfile" ]
|
||||
then
|
||||
mv "$wmldir/$subdir/$lang/tmp-$wmlfile" "$wmldir/$subdir/$lang/$wmlfile"
|
||||
|
||||
# Remove last three lines in file
|
||||
sed -i -e :a -e '$d;N;2,3ba' -e 'P;D' "$wmldir/$subdir/$lang/$wmlfile"
|
||||
|
||||
# Include foot.wmi
|
||||
echo "#include <foot.wmi>" >> "$wmldir/$subdir/$lang/$wmlfile"
|
||||
fi
|
||||
}
|
||||
|
||||
# If $onedirup is equal to $lang, that means we do not have a
|
||||
# subdirectory.
|
||||
if [ $onedirup == $lang ]
|
||||
then
|
||||
# If the current subdirectory is "zh_CN" use "zh-cn" instead
|
||||
if [ $subdir = "zh_CN" ]
|
||||
then
|
||||
po4a-translate -f wml -m "$english" -p "$file" -l "$wmldir/zh-cn/tmp-$wmlfile" --master-charset utf-8 -L utf-8 -o customtag="$customtag" -o nodefault="$nodefault"
|
||||
|
||||
# Check to see if the file was written
|
||||
if [ -e "$wmldir/zh-cn/tmp-$wmlfile" ]
|
||||
then
|
||||
mv "$wmldir/zh-cn/tmp-$wmlfile" "$wmldir/zh-cn/$wmlfile"
|
||||
|
||||
# Remove last three lines in file
|
||||
sed -i -e :a -e '$d;N;2,3ba' -e 'P;D' "$wmldir/zh-cn/$wmlfile"
|
||||
|
||||
# Include foot.wmi
|
||||
echo "#include <foot.wmi>" >> "$wmldir/zh-cn/$wmlfile"
|
||||
fi
|
||||
subdir="zh-cn"
|
||||
nosubdir
|
||||
fi
|
||||
|
||||
# If the current directory is "nb" use "no" instead
|
||||
if [ $subdir = "nb" ]
|
||||
then
|
||||
po4a-translate -f wml -m "$english" -p "$file" -l "$wmldir/no/tmp-$wmlfile" --master-charset utf-8 -L utf-8 -o customtag="$customtag" -o nodefault="$nodefault"
|
||||
|
||||
# Check to see if the file was written
|
||||
if [ -e "$wmldir/no/tmp-$wmlfile" ]
|
||||
then
|
||||
mv "$wmldir/no/tmp-$wmlfile" "$wmldir/no/$wmlfile"
|
||||
|
||||
# Remove last three lines in file
|
||||
sed -i -e :a -e '$d;N;2,3ba' -e 'P;D' "$wmldir/no/$wmlfile"
|
||||
|
||||
# Include foot.wmi
|
||||
echo "#include <foot.wmi>" >> "$wmldir/no/$wmlfile"
|
||||
fi
|
||||
subdir="no"
|
||||
nosubdir
|
||||
fi
|
||||
|
||||
# If the current directory is "sv" use "se" instead
|
||||
if [ $subdir = "sv" ]
|
||||
then
|
||||
po4a-translate -f wml -m "$english" -p "$file" -l "$wmldir/se/tmp-$wmlfile" --master-charset utf-8 -L utf-8 -o customtag="$customtag" -o nodefault="$nodefault"
|
||||
|
||||
# Check to see if the file was written
|
||||
if [ -e "$wmldir/se/tmp-$wmlfile" ]
|
||||
then
|
||||
mv "$wmldir/se/tmp-$wmlfile" "$wmldir/se/$wmlfile"
|
||||
|
||||
# Remove last three lines in file
|
||||
sed -i -e :a -e '$d;N;2,3ba' -e 'P;D' "$wmldir/se/$wmlfile"
|
||||
|
||||
# Include foot.wmi
|
||||
echo "#include <foot.wmi>" >> "$wmldir/se/$wmlfile"
|
||||
|
||||
fi
|
||||
subdir="se"
|
||||
nosubdir
|
||||
fi
|
||||
|
||||
# Convert everything else
|
||||
if [[ $subdir != "en" && $subdir != "zh_CN" && $subdir != "nb" && $subdir != "sv" ]]
|
||||
then
|
||||
po4a-translate -f wml -m "$english" -p "$file" -l "$wmldir/$subdir/tmp-$wmlfile" --master-charset utf-8 -L utf-8 -o customtag="$customtag" -o nodefault="$nodefault"
|
||||
|
||||
# Check to see if the file was written
|
||||
if [ -e "$wmldir/$subdir/tmp-$wmlfile" ]
|
||||
then
|
||||
mv "$wmldir/$subdir/tmp-$wmlfile" "$wmldir/$subdir/$wmlfile"
|
||||
|
||||
# Remove last three lines in file
|
||||
sed -i -e :a -e '$d;N;2,3ba' -e 'P;D' "$wmldir/$subdir/$wmlfile"
|
||||
|
||||
# Include foot.wmi
|
||||
echo "#include <foot.wmi>" >> "$wmldir/$subdir/$wmlfile"
|
||||
fi
|
||||
nosubdir
|
||||
fi
|
||||
else
|
||||
# The location of the english wml file
|
||||
english="$wmldir/$subdir/en/$wmlfile"
|
||||
|
||||
# If the current language is "zh_CN" use "zh-cn" instead
|
||||
if [ $lang = "zh_CN" ]
|
||||
then
|
||||
po4a-translate -f wml -m "$english" -p "$file" -l "$wmldir/$subdir/zh-cn/tmp-$wmlfile" --master-charset utf-8 -L utf-8 -o customtag="$customtag" -o nodefault="$nodefault"
|
||||
|
||||
# Check to see if the file was written
|
||||
if [ -e "$wmldir/$subdir/zh-cn/tmp-$wmlfile" ]
|
||||
then
|
||||
mv "$wmldir/$subdir/zh-cn/tmp-$wmlfile" "$wmldir/$subdir/zh-cn/$wmlfile"
|
||||
|
||||
# Remove last three lines in file
|
||||
sed -i -e :a -e '$d;N;2,3ba' -e 'P;D' "$wmldir/$subdir/zh-cn/$wmlfile"
|
||||
|
||||
# Include foot.wmi
|
||||
echo "#include <foot.wmi>" >> "$wmldir/$subdir/zh-cn/$wmlfile"
|
||||
fi
|
||||
lang="zh-cn"
|
||||
subdir
|
||||
fi
|
||||
|
||||
# If the current language is "nb" use "no" instead
|
||||
if [ $lang = "nb" ]
|
||||
then
|
||||
po4a-translate -f wml -m "$english" -p "$file" -l "$wmldir/$subdir/no/tmp-$wmlfile" --master-charset utf-8 -L utf-8 -o customtag="$customtag" -o nodefault="$nodefault"
|
||||
|
||||
# Check to see if the file was written
|
||||
if [ -e "$wmldir/$subdir/no/tmp-$wmlfile" ]
|
||||
then
|
||||
mv "$wmldir/$subdir/no/tmp-$wmlfile" "$wmldir/$subdir/no/$wmlfile"
|
||||
|
||||
# Remove last three lines in file
|
||||
sed -i -e :a -e '$d;N;2,3ba' -e 'P;D' "$wmldir/$subdir/no/$wmlfile"
|
||||
|
||||
# Include foot.wmi
|
||||
echo "#include <foot.wmi>" >> "$wmldir/$subdir/no/$wmlfile"
|
||||
fi
|
||||
lang="no"
|
||||
subdir
|
||||
fi
|
||||
|
||||
# If the current language is "sv" use "se" instead
|
||||
if [ $lang = "sv" ]
|
||||
then
|
||||
po4a-translate -f wml -m "$english" -p "$file" -l "$wmldir/$subdir/se/tmp-$wmlfile" --master-charset utf-8 -L utf-8 -o customtag="$customtag" -o nodefault="$nodefault"
|
||||
|
||||
# Check to see if the file was written
|
||||
if [ -e "$wmldir/$subdir/se/tmp-$wmlfile" ]
|
||||
then
|
||||
mv "$wmldir/$subdir/se/tmp-$wmlfile" "$wmldir/$subdir/se/$wmlfile"
|
||||
|
||||
# Remove last three lines in file
|
||||
sed -i -e :a -e '$d;N;2,3ba' -e 'P;D' "$wmldir/$subdir/se/$wmlfile"
|
||||
|
||||
# Include foot.wmi
|
||||
echo "#include <foot.wmi>" >> "$wmldir/$subdir/se/$wmlfile"
|
||||
fi
|
||||
lang="se"
|
||||
subdir
|
||||
fi
|
||||
|
||||
# Convert everything else
|
||||
if [[ $lang != "en" && $lang != "zh_CN" && $lang != "nb" && $lang != "sv" ]]
|
||||
then
|
||||
po4a-translate -f wml -m "$english" -p "$file" -l "$wmldir/$subdir/$lang/tmp-$wmlfile" --master-charset utf-8 -L utf-8 -o customtag="$customtag" -o nodefault="$nodefault"
|
||||
|
||||
# Check to see if the file was written
|
||||
if [ -e "$wmldir/$subdir/$lang/tmp-$wmlfile" ]
|
||||
then
|
||||
mv "$wmldir/$subdir/$lang/tmp-$wmlfile" "$wmldir/$subdir/$lang/$wmlfile"
|
||||
|
||||
# Remove last three lines in file
|
||||
sed -i -e :a -e '$d;N;2,3ba' -e 'P;D' "$wmldir/$subdir/$lang/$wmlfile"
|
||||
|
||||
# Include foot.wmi
|
||||
echo "#include <foot.wmi>" >> "$wmldir/$subdir/$lang/$wmlfile"
|
||||
fi
|
||||
subdir
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user