forked from dsmid/kindle-pw2-l10n-cs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
transifex-waf2sql
executable file
·51 lines (45 loc) · 1.21 KB
/
transifex-waf2sql
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
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
. config
#cp -f kindle_loc.sqlite kindle_loc.sqlite.4.1.old
#cp -f kindle_loc.sqlite.3.4 kindle_loc.sqlite
report() {
[ "$src" == '“' ] && return 1
[ "$src" == '”' ] && return 1
echo "Filtered out: $src"
return 0
}
VER="5.0.3"
cd transifex/src/$VER/waf
echo "begin;" > ../../../../waf_$VER.sql
find . -name "*.properties" -path "./$HACKLANG/*" | while read item
do
cs="$item"
en=${cs//\/$HACKLANG\//\/en_US\/}
echo $en
project=${en#./en_US/}
prpath=${project#*/}
project=${project%%/*}
engb=./opt/var/local/mesquite/$project/locales/en-GB/$prpath
engb=${engb%.properties}.js
OLDIFS=$IFS
IFS="="
echo "Processing $cs"
while read -u5 key1 czech;read -u6 key2 eng
do
[ -n "$key1" ] || continue
[ -n "$czech" ] || continue
[ "$czech" != "$eng" ] || continue
if [ "$key1" == "$key2" ]
then
echo -e "\t$eng = $czech"
eng=$(sed "s/'/''/g" <<<"$eng")
czech=$(sed "s/'/''/g" <<<"$czech")
echo "insert into trans values ('$eng','$czech', '$engb', '$VER');" >> ../../../../waf_$VER.sql
else
echo "keys do not match: '$key1' vs '$key2'" >&2
fi
done 5<"$cs" 6<"$en"
IFS=$OLDIFS
echo
done
echo "commit;" >> ../../../../waf_$VER.sql