-
Notifications
You must be signed in to change notification settings - Fork 21
/
messages.sh
executable file
·45 lines (34 loc) · 1.35 KB
/
messages.sh
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
#!/bin/bash
# Script to update translation files
# Generates ruletemplates/messages.h and calls lupdate on the entire project
# Ideally this would eventually be called in the CI when building the packages
# However, this will break not find all translations when ran with Qt < 5.9
# so for now this is ran manually all the time and results are committed to the
# repository
OUT="nymea-app/ruletemplates/messages.h"
echo "// This file is generated. Update it using ./messages.sh in the root source directory" > $OUT
echo "#include <QString>" >> $OUT
echo "const QString translations[] {" >> $OUT
for INPUTFILE in `ls nymea-app/ruletemplates/*json`; do
echo "Extracting strings from ruletemplate file $INPUTFILE"
FILEBASENAME=$(basename -- "$INPUTFILE")
FILEBASENAME="${FILEBASENAME%.*}"
while IFS= read -r LINE
do
if [[ $LINE == *"\"description\""* ]] || [[ $LINE == *"\"ruleNameTemplate\""* ]]; then
if [ $HASCONTENT -eq 1 ]; then
echo "," >> $OUT
fi
TYPE=`echo $LINE | cut -d ":" -f 1 | sed 's/"//g'`
STRING=`echo $LINE | cut -d ":" -f 2 | sed 's/,$//'`
echo -n "QT_TRANSLATE_NOOP(" >> $OUT
echo -n "\"$TYPE for $FILEBASENAME\", " >> $OUT
echo -n $STRING >> $OUT
echo -n ")" >> $OUT
HASCONTENT=1
fi
done < "$INPUTFILE"
done
echo "" >> $OUT
echo "};" >> $OUT
lupdate -no-obsolete nymea-app.pro