-
Notifications
You must be signed in to change notification settings - Fork 2
/
acx2sql
executable file
·64 lines (56 loc) · 2.2 KB
/
acx2sql
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
#!/bin/bash
. config
VER="strings_$VERSION"
rm -rf build/acx
cd root_$VERSION
root=$PWD
echo "begin;" > $root/../acxstrings_$VERSION.sql.temp
orig=./opt/amazon/acw
while read acx
do
echo ACX: $acx
[ -d "$root/../build/acx/$acx" ] || mkdir -p "$root/../build/acx/$acx"
cp -f $acx $root/../build/acx/$acx/
cd $root/../build/acx/$acx/
unzip $(basename "$acx")
cd $root
done < <(find $orig -name '*.acx')
cd $root/../translation_$VERSION/acx_tweaks
while read tweak
do
echo "Copying tweak $tweak"
tdir=$(dirname "$tweak")
[ -d "$root/../build/acx/$tdir" ] || mkdir -p "$root/../build/acx/$tdir"
cp -f "$tweak" $root/../build/acx/"$tweak"
done < <(find . -type f )
cd $root/../build/acx
find $orig -path '*/locales/en-gb/*.js' -exec bash -c 'js={}; mv -f {} {}.ee; js-beautify -o {} {}.ee; rm -f {}.ee' \; -print | xargs -if awk -v name=f 'BEGIN {FS="^[^\"'"'"']*[\"'"'"']|[\"'"'"'][^\"'"'"']*$"} $2 != "" {print name "\t" $2}' f | sort -u | \
sed "s/'/''/g;s|\\\\|\\\\\\\\|g" | \
(
cd $root
printf -v IFS "\t"
while read file src
do
export src
echo "INSERT INTO trans VALUES('$src','','$file','$VER');" >> $root/../acxstrings_$VERSION.sql.temp
echo " === insert into trans values ('$src','', '$file', '$VER');" >&2
done
)
cd $root/../build/acx
find $orig -path '*/config.xml' -print | xargs -if awk -v name=f 'BEGIN {FS="^[^<]*<name [^>]*xml:lang=\"en-gb\">|</name>.*$"} $2 != "" {print name "\t" $2}' f | sort -u | \
sed "s/'/''/g;s|\\\\|\\\\\\\\|g" | \
(
cd $root
printf -v IFS "\t"
while read file src
do
export src
[ -n "$src" ] || continue
echo "INSERT INTO trans VALUES('$src','','$file','$VER');" >> $root/../acxstrings_$VERSION.sql.temp
echo " === insert into trans values ('$src','', '$file', '$VER');" >&2
done
)
cd $root
echo "commit;" >> $root/../acxstrings_$VERSION.sql.temp
native2ascii -reverse $root/../acxstrings_$VERSION.sql.temp $root/../acxstrings_$VERSION.sql
rm -f $root/../acxstrings_$VERSION.sql.temp