2018-03-10 01:05:34 +01:00
|
|
|
#!/bin/bash
|
2018-03-15 11:00:24 +01:00
|
|
|
# Copyright 2017-2018 Xuan Sang LE <xsang.le AT gmail DOT com>
|
|
|
|
|
|
|
|
# AnTOS Web desktop is is licensed under the GNU General Public
|
|
|
|
# License v3.0, see the LICENCE file for more information
|
|
|
|
|
|
|
|
# This program is free software: you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License as
|
|
|
|
# published by the Free Software Foundation, either version 3 of
|
|
|
|
# the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# General Public License for more details.
|
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
#along with this program. If not, see https://www.gnu.org/licenses/.
|
|
|
|
|
2018-03-10 01:05:34 +01:00
|
|
|
ord() {
|
|
|
|
LC_CTYPE=C printf '%d' "'$1"
|
|
|
|
}
|
2020-05-18 18:53:59 +02:00
|
|
|
grep --include=\*.{coffee} -roh "$1" -e '__("[^"]*"' | while read -r line ; do
|
2018-03-10 01:05:34 +01:00
|
|
|
SUBSTRING=$(echo $line| cut -d'"' -f 2)
|
2018-03-10 15:40:25 +01:00
|
|
|
if test -f "$2" && [ ! -z "$(grep -F "\"$SUBSTRING\":" "$2")" ]
|
|
|
|
then
|
|
|
|
echo "Ignore: $SUBSTRING"
|
|
|
|
else
|
|
|
|
echo -e "\t\"$SUBSTRING\":\"$SUBSTRING\"," >> "tmp.json"
|
|
|
|
fi
|
2018-03-10 01:05:34 +01:00
|
|
|
done
|
2020-05-18 18:53:59 +02:00
|
|
|
grep --include=\*.{coffee,html} -roh "$1" -e '\"__([^\"]*)\"' | while read -r line; do
|
2018-03-10 01:05:34 +01:00
|
|
|
len=$(( ${#line} - 6 ))
|
|
|
|
#echo $len
|
2018-03-17 23:46:37 +01:00
|
|
|
#echo $line
|
2018-03-10 01:05:34 +01:00
|
|
|
SUBSTRING=${line:4:len}
|
|
|
|
#echo $SUBSTRING
|
2018-03-10 15:40:25 +01:00
|
|
|
if test -f "$2" && [ ! -z "$(grep -F "\"$SUBSTRING\":" "$2")" ]
|
|
|
|
then
|
|
|
|
echo "Ignore: $SUBSTRING"
|
|
|
|
else
|
|
|
|
echo -e "\t\"$SUBSTRING\":\"$SUBSTRING\"," >> "tmp.json"
|
|
|
|
fi
|
2018-03-10 01:05:34 +01:00
|
|
|
done
|
2018-03-17 23:46:37 +01:00
|
|
|
if test -f tmp.json
|
2018-03-10 15:40:25 +01:00
|
|
|
then
|
2018-03-17 23:46:37 +01:00
|
|
|
sort tmp.json > tmp1.json
|
|
|
|
awk '!a[$0]++' "tmp1.json" > tmp.json
|
|
|
|
sed '$ s/.$//' tmp.json > tmp1.json
|
|
|
|
# remove duplicate entry
|
|
|
|
if test -f $2
|
|
|
|
then
|
|
|
|
cp $2 "$2.old"
|
|
|
|
sed '$ s/.$//' $2 > tmp.json
|
|
|
|
cat tmp.json > $2
|
|
|
|
echo "," >> $2
|
|
|
|
cat tmp1.json >> $2
|
|
|
|
echo "}" >> "$2"
|
|
|
|
else
|
|
|
|
echo "{"> "$2"
|
|
|
|
cat tmp1.json >> "$2"
|
|
|
|
echo "}" >> "$2"
|
|
|
|
fi
|
|
|
|
rm tmp.json tmp1.json
|
2018-03-10 15:40:25 +01:00
|
|
|
else
|
2018-03-17 23:46:37 +01:00
|
|
|
echo "Nothing change"
|
|
|
|
fi
|