-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsqlite2translation
executable file
·93 lines (86 loc) · 5.59 KB
/
sqlite2translation
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
. config
cd translation_$VERSION
if [ -d "translation/com" ]
then
echo "Delete translation_$VERSION/translation/com first"
exit
fi
if [ -d "translation_unfinished/com" ]
then
echo "Delete translation_$VERSION/translation_unfinished/com first"
exit
fi
#cp -fR ru/* translation/
cd source
#find . -name '*.translation' -exec sed -i 's/^\([^\t]*\t\).*$/\1/g' {} \;
find . \( -name '*.translation' -or -name '*.properties' -or -name '*.js' -or -name '*.xml' \) -print -exec sh -c '
printf -v IFS "\t\r";
(cat {};echo) | sed "s/'"'"'/'"''"'/g" | while read src rest;
do
echo "? $src";
[ -n "$src" ] || continue;
file={};
if [ "${file%.properties}" != "$file" ];
then
key=$(echo "$src" | awk "BEGIN {FS=\"([[:space:]]*=[[:space:]]*)|\\r\"} {print \$1}");
val=$(echo "$src" | awk "BEGIN {FS=\"([[:space:]]*=[[:space:]]*)|\\r\"} {print \$2}");
src="$key";
echo "key: $key";
echo "val: $val";
[ -n "$src" ] || continue;
tran=$(sqlite3 ../../kindle_loc.sqlite "select tran from trans where src='"'"'$src'"'"' and file='"'"'{}'"'"' and ver='"'"''$VERSION''"'"' ;" );
[ -n "$tran" ] || tran=$(sqlite3 ../../kindle_loc.sqlite "select tran from trans where src='"'"'$src'"'"' and file='"'"'{}'"'"' and ver='"'"'5.4.4'"'"' ;" );
[ -n "$tran" ] || tran=$(sqlite3 ../../kindle_loc.sqlite "select tran from trans where src='"'"'$src'"'"' and file='"'"'{}'"'"' and ver='"'"'5.4.3'"'"' ;" );
[ -n "$tran" ] || tran=$(sqlite3 ../../kindle_loc.sqlite "select tran from trans where src='"'"'$src'"'"' and file='"'"'{}'"'"' and ver='"'"'5.4.2'"'"' ;" );
[ -n "$tran" ] || tran=$(sqlite3 ../../kindle_loc.sqlite "select tran from trans where src='"'"'$src'"'"' and file='"'"'{}'"'"' and ver='"'"'4.1'"'"' ;" );
[ -n "$tran" ] || tran=$(sqlite3 ../../kindle_loc.sqlite "select tran from trans where src='"'"'$src'"'"' and file='"'"'{}'"'"' and ver='"'"'3.4'"'"' ;" );
[ -n "$tran" ] || tran=$(sqlite3 ../../kindle_loc.sqlite "select tran from trans where src='"'"'$src'"'"' and file='"'"'{}'"'"' and ver='"'"'3.1'"'"' ;" );
[ -n "$tran" ] || tran=$(sqlite3 ../../kindle_loc.sqlite "select tran from trans where src='"'"'$src'"'"' and file='"'"'{}'"'"' and ver='"'"'3.0'"'"' ;" );
[ -n "$tran" ] || tran=$(sqlite3 ../../kindle_loc.sqlite "select tran from trans where src='"'"'$src'"'"' and ver='"'"'5.4.2'"'"' ;" | sort -u | sed "s/$/#or#/g" | tr -d '"'"'\n'"'"');
[ -n "$tran" ] || tran=$(sqlite3 ../../kindle_loc.sqlite "select tran from trans where src='"'"'$src'"'"' and ver not like '"'"'strings_%'"'"' ;" | sort -u | sed "s/$/#or#/g" | tr -d '"'"'\n'"'"');
src="$val";
[ -n "$tran" ] || tran=$(sqlite3 ../../kindle_loc.sqlite "select tran from trans where src='"'"'$src'"'"' and ver not like '"'"'strings_%'"'"' ;" | sort -u | sed "s/$/#or#/g" | tr -d '"'"'\n'"'"');
[ -n "$tran" ] || tran="$val";
else
tran=$(sqlite3 ../../kindle_loc.sqlite "select tran from trans where src='"'"'$src'"'"' and file='"'"'{}'"'"' and ver='"'"''$VERSION''"'"' ;" );
[ -n "$tran" ] || tran=$(sqlite3 ../../kindle_loc.sqlite "select tran from trans where src='"'"'$src'"'"' and file='"'"'{}'"'"' and ver='"'"'5.4.4'"'"' ;" );
[ -n "$tran" ] || tran=$(sqlite3 ../../kindle_loc.sqlite "select tran from trans where src='"'"'$src'"'"' and file='"'"'{}'"'"' and ver='"'"'5.4.3'"'"' ;" );
[ -n "$tran" ] || tran=$(sqlite3 ../../kindle_loc.sqlite "select tran from trans where src='"'"'$src'"'"' and file='"'"'{}'"'"' and ver='"'"'5.4.2'"'"' ;" );
[ -n "$tran" ] || tran=$(sqlite3 ../../kindle_loc.sqlite "select tran from trans where src='"'"'$src'"'"' and file='"'"'{}'"'"' and ver='"'"'4.1'"'"' ;" );
[ -n "$tran" ] || tran=$(sqlite3 ../../kindle_loc.sqlite "select tran from trans where src='"'"'$src'"'"' and file='"'"'{}'"'"' and ver='"'"'3.4'"'"' ;" );
[ -n "$tran" ] || tran=$(sqlite3 ../../kindle_loc.sqlite "select tran from trans where src='"'"'$src'"'"' and file='"'"'{}'"'"' and ver='"'"'3.1'"'"' ;" );
[ -n "$tran" ] || tran=$(sqlite3 ../../kindle_loc.sqlite "select tran from trans where src='"'"'$src'"'"' and file='"'"'{}'"'"' and ver='"'"'3.0'"'"' ;" );
[ -n "$tran" ] || tran=$(sqlite3 ../../kindle_loc.sqlite "select tran from trans where src='"'"'$src'"'"' and ver='"'"'5.4.2'"'"' ;" | sort -u | sed "s/$/#or#/g" | tr -d '"'"'\n'"'"');
[ -n "$tran" ] || tran=$(sqlite3 ../../kindle_loc.sqlite "select tran from trans where src='"'"'$src'"'"' and ver not like '"'"'strings_%'"'"' ;" | sort -u | sed "s/$/#or#/g" | tr -d '"'"'\n'"'"');
fi;
trantr=${tran###or#}
trantr=${trantr%#or#}
echo "-> $trantr";
[ "${key:0:1}" == "#" ] || key="$key=";
dir=$(dirname ../translation/{});
untdir=$(dirname ../translation_unfinished/{});
[ -d "$dir" ] || mkdir -p "$dir";
if [ "${file%.properties}" != "$file" ];
then
printf "%s%s\r\n" "$key" "$trantr" | sed "s/'"''"'/'"'"'/g" >> ../translation/{};
[ -n "$val" ] || tran=x
else
printf "%s\t%s\r\n" "$src" "$trantr" | sed "s/'"''"'/'"'"'/g" >> ../translation/{};
fi;
if [ -z "$trantr" ] || printf "%s" "$trantr" | grep -q "#or#" ;
then
[ -d "$untdir" ] || mkdir -p "$untdir";
if [ "${file%.properties}" != "$file" ];
then
printf "%s%s\r\n" "$key" "$trantr" | sed "s/'"''"'/'"'"'/g" >> ../translation_unfinished/{};
else
printf "%s\t%s\r\n" "$src" "$trantr" | sed "s/'"''"'/'"'"'/g" >> ../translation_unfinished/{};
fi;
fi;
done;
' \;
cd ../translation_unfinished
rm -f nottranslated.zip
zip -r nottranslated.zip *
#[ -n "$tran" ] || tran=$(sqlite3 ../../kindle_loc.sqlite "select tran from trans where src='"'"'$src'"'"' and ver='"'"'3.0'"'"' ;" | sort -u | sed "s/$/#or#/g" | tr -d '"'"'\n'"'"' | sed "s/#or#$//g");