-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrowdin-fetch-fix.sh
39 lines (33 loc) · 1.24 KB
/
crowdin-fetch-fix.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/sh
# To run under Windows use MozillaBuild package - https://forum.palemoon.org/viewtopic.php?f=19&t=13556
LANG=en_US.utf8
if [ "$1" = "" ]; then
printf "\nUse $0 locale\n" && exit 1
fi
if [ ! -f $1.zip ]; then
printf "\n$1.zip not exists\n" && exit 1
fi
currdir=$(pwd)
temp_dir=$(mktemp -d /tmp/crowdin.XXXXXX)
trap "rm -rf $temp_dir" 0 2 3 15
printf "\n unzipping $1.zip ... "
unzip -q $1.zip -d $temp_dir
if [ $? -eq 0 ]; then
printf "done\n"
else
printf "\n\n$1.zip broken\n" && exit 1
fi
printf " processing *.properties ... "
find $temp_dir/ -name "*.properties" -exec perl crowdin-filter.pl {} \;
printf "done\n"
printf " processing *.dtd ... "
find $temp_dir/ -name "*.dtd" -exec sed -i 's/\&\([\.a-zA-Z0-9]*\);/\&\1;/g;s/{\[=-/</g;s/-=\]}/>/g' {} \; &> /dev/null
find $temp_dir/ -name "netError.dtd" -exec sed -i 's/\</</g;s/\>/>/g' {} \; &> /dev/null
find $temp_dir/ \( -name "aboutRights.dtd" -o -name "aboutSessionRestore.dtd" -o -name "printPageSetup.dtd" \
-o -name "printPreview.dtd" -o -name "printProgress.dtd" \) -exec sed -i 's/%/\%/g' {} \; &> /dev/null
printf "done\n"
printf " zipping result to $1-fix.zip ... "
cd $temp_dir/$1
zip -q -r $currdir/$1-fix.zip *
cd $currdir
printf "done\n"