forked from dsmid/kindle-pw2-l10n-cs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
transifex-framework2sql
executable file
·46 lines (40 loc) · 1.12 KB
/
transifex-framework2sql
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
#!/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
}
cd transifex/src/5.0.3/framework
VER="5.0.3"
echo "begin;" > ../../../../framework_$VER.sql
find . -name "*_$HACKLANG.properties" | while read item
do
cs="$item"
en=${cs%_$HACKLANG.properties}_en_US.properties
engb=${cs%_$HACKLANG.properties}_en_GB.translation
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');" >> ../../../../framework_$VER.sql
else
echo "keys do not match: '$key1' vs '$key2'" >&2
fi
done 5<"$cs" 6<"$en"
IFS=$OLDIFS
echo
done
echo "commit;" >> ../../../../framework_$VER.sql