2020-01-08 14:41:52 +01:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# compare_lang.sh
|
|
|
|
# quick and dirty script to find missing lang strings in webmin lang files
|
|
|
|
#
|
|
|
|
# (c) https://github.com/gnadelwartz, 2020
|
|
|
|
#
|
2022-06-29 07:17:11 -04:00
|
|
|
# DISPLAY missing strings from one langfile:
|
2020-01-08 14:41:52 +01:00
|
|
|
#
|
|
|
|
# ./compare_lang.sh module/lang/xx
|
|
|
|
#
|
|
|
|
# UPDATE one langfile of a module with missing strings:
|
|
|
|
#
|
|
|
|
# ./compare_lang.sh module/lang/xx >>module/lang/xx
|
|
|
|
#
|
|
|
|
# UPDATE one langfile in ALL modules with missing strings:
|
|
|
|
#
|
|
|
|
# for FILE in webmin/*/lang/xx; do
|
|
|
|
# ./compare_lang.sh $FILE >>$FILE
|
|
|
|
# done
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# $1 = lang file to check for missing strings against en
|
|
|
|
|
|
|
|
ENGLISH="$(dirname "$1")/en"
|
|
|
|
|
|
|
|
if [ "$1" == "" -o ! -f "$1" ]
|
|
|
|
then
|
|
|
|
echo "file does not exist or no file given ..."
|
|
|
|
echo "usage: $0 file"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
while read message
|
|
|
|
do
|
|
|
|
# skip empty lines
|
|
|
|
[ "$message" == "" ] && continue
|
2022-06-29 07:17:11 -04:00
|
|
|
# skip comments, __noref and log_* messages
|
2020-01-08 15:46:41 +01:00
|
|
|
if [[ "$message" == "#"* ]] || [[ "$message" == "__norefs"* ]] || [[ "$message" == "log_"* ]]; then
|
2020-01-08 14:41:52 +01:00
|
|
|
echo "skip $message" 1>&2
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
# output missing lines
|
|
|
|
key="${message%%=*}"; [ "$key" == "$message" ] && continue
|
|
|
|
grep -e "^${key}=" "$1" >/dev/null || echo "${message}"
|
|
|
|
done < "${ENGLISH}"
|