-
Notifications
You must be signed in to change notification settings - Fork 2
/
js2sql
executable file
·30 lines (26 loc) · 929 Bytes
/
js2sql
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
#!/bin/bash
. config
VER="strings_$VERSION"
cd root_$VERSION
echo "begin;" > ../jsstrings_$VERSION.sql.temp
while read orig
do
if [[ "$orig" =~ mesquite|pillow ]]
then
echo $orig
find $orig -name '*.js' | xargs -if awk -v name=f 'BEGIN {FS="^[^\"'"'"']*[\"'"'"']|[\"'"'"'][^\"'"'"']*$"} $2 != "" {print name "\t" $2}' f | sort -u | \
sed "s/'/''/g;s|\\\\|\\\\\\\\|g" | \
(
printf -v IFS "\t"
while read file src
do
export src
echo "INSERT INTO trans VALUES('$src','','$file','$VER');" >> ../jsstrings_$VERSION.sql.temp
echo " === insert into trans values ('$src','', '$file', '$VER');" >&2
done
)
fi
done < <(find . -type d -path '*/locales/en-GB')
echo "commit;" >> ../jsstrings_$VERSION.sql.temp
native2ascii -reverse ../jsstrings_$VERSION.sql.temp ../jsstrings_$VERSION.sql
rm -f ../jsstrings_$VERSION.sql.temp