2018-03-10 01:05:34 +01:00
|
|
|
#!/bin/bash
|
|
|
|
ord() {
|
|
|
|
LC_CTYPE=C printf '%d' "'$1"
|
|
|
|
}
|
2018-03-10 12:22:01 +01:00
|
|
|
grep --include=\*.{coffee,tag} -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
|
2018-03-10 15:40:25 +01:00
|
|
|
grep --include=\*.{coffee,html,tag} -roh "$1" -e '\"__\([^\"]*\)\"' | while read -r line; do
|
2018-03-10 01:05:34 +01:00
|
|
|
len=$(( ${#line} - 6 ))
|
|
|
|
#echo $len
|
|
|
|
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
|
|
|
|
sort tmp.json > tmp1.json
|
|
|
|
awk '!a[$0]++' "tmp1.json" > tmp.json
|
|
|
|
sed '$ s/.$//' tmp.json > tmp1.json
|
|
|
|
# remove duplicate entry
|
2018-03-10 15:40:25 +01:00
|
|
|
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
|
2018-03-10 01:05:34 +01:00
|
|
|
rm tmp.json tmp1.json
|