Fix score loader improperly reading player names with spaces
[neverball] / scripts / translate-desktop.sh
1 #!/bin/sh
2 # This script reads a .desktop file from stdin and prints the same file, with
3 # up-to-date translations, to stdout.
4
5 while read line; do
6     # Remove translations
7     if echo $line | grep '^.*\[.*\]=' > /dev/null; then
8         continue
9     fi
10
11     echo $line
12
13     # Generate translations if current line is translatable
14     if echo $line | grep '^Comment=' > /dev/null; then
15         msgid=`echo $line | sed 's/^Comment=//'`
16         for i in po/*.po; do
17             lang=`basename $i | sed 's/\.po//'`
18             msgstr=`msgattrib --translated --no-obsolete --no-fuzzy $i \
19                     | msggrep --no-location --no-wrap --msgid -F -e "$msgid" \
20                     | tail -n 1 | sed 's/^msgstr "\(.*\)"$/\1/'`
21             if [ "$msgstr" != "" ]; then
22                 echo "Comment[$lang]=$msgstr"
23             fi
24         done
25     fi
26 done