MAPS := $(shell find data -name "*.map" \! -name "*.autosave.map")
SOLS := $(MAPS:%.map=%.sol)
+DESKTOPS := $(basename $(wildcard dist/*.desktop.in))
+
#------------------------------------------------------------------------------
%.o : %.c
%.sol : %.map $(MAPC_TARG)
$(MAPC) $< data
+%.desktop : %.desktop.in
+ sh scripts/translate-desktop.sh < $< > $@
+
#------------------------------------------------------------------------------
-all : $(BALL_TARG) $(PUTT_TARG) $(MAPC_TARG) sols locales
+all : $(BALL_TARG) $(PUTT_TARG) $(MAPC_TARG) sols locales desktops
$(BALL_TARG) : $(BALL_OBJS)
$(CC) $(ALL_CFLAGS) -o $(BALL_TARG) $(BALL_OBJS) $(LDFLAGS) $(ALL_LIBS)
$(MAKE) -C po
endif
+desktops : $(DESKTOPS)
+
clean-src :
$(RM) $(BALL_TARG) $(BALL_OBJS) $(BALL_DEPS)
$(RM) $(PUTT_TARG) $(PUTT_OBJS) $(PUTT_DEPS)
clean : clean-src
$(RM) $(SOLS)
+ $(RM) $(DESKTOPS)
$(MAKE) -C po clean
test : all
+++ /dev/null
-[Desktop Entry]
-Version=1.0
-Type=Application
-Name=Neverball
-Comment=A 3D arcade game with a ball
-Comment[fr]=Un jeu d'arcade 3D avec une balle
-Icon=neverball
-Exec=neverball
-Terminal=false
-Categories=Game;ArcadeGame;
--- /dev/null
+[Desktop Entry]
+Version=1.0
+Type=Application
+Name=Neverball
+Comment=A 3D arcade game with a ball
+Icon=neverball
+Exec=neverball
+Terminal=false
+Categories=Game;ArcadeGame;
+++ /dev/null
-[Desktop Entry]
-Version=1.0
-Type=Application
-Name=Neverputt
-Comment=A 3D mini golf game
-Comment[fr]=Un jeu de minigolf en 3D
-Icon=neverputt
-Exec=neverputt
-Terminal=false
-Categories=Game;ArcadeGame;
--- /dev/null
+[Desktop Entry]
+Version=1.0
+Type=Application
+Name=Neverputt
+Comment=A 3D mini golf game
+Icon=neverputt
+Exec=neverputt
+Terminal=false
+Categories=Game;ArcadeGame;
msgid "item/coin/coin"
msgstr "item/coin/euro_coin"
+msgid "A 3D arcade game with a ball"
+msgstr "Un jeu d'arcade 3D avec une balle"
+
+msgid "A 3D mini golf game"
+msgstr "Un jeu de minigolf en 3D"
+
#~ msgid "Mode"
#~ msgstr "Mode"
#~ msgid "Follow the yellow lick road..."
#!/bin/sh
-# This script extracts translatable messages from maps and sets.
+# This script extracts translatable messages from maps, sets and
+# desktop files.
# Copyright (C) 2006 Jean Privat
#
# Part of the Neverball project
SETS="$DATA/sets.txt"
COURSES="$DATA/courses.txt"
+print_msg() {
+ string=$1
+ file=$2
+ comment=$3
+
+ echo
+ if [ "$comment" != "" ]; then
+ echo "#. $comment"
+ fi
+ echo "#: $file"
+ echo "msgid \"$string\""
+ echo "msgstr \"\""
+}
+
for i in $(cat "$SETS"); do
i="$DATA/$i"
# Only translate the two first lines
head -n 2 $i | while read -r d; do
- echo
- echo "#: $i"
- echo "msgid \"$(echo "$d" | sed 's/\\/\\\\/g')\""
- echo "msgstr \"\""
+ msg=$(echo "$d" | sed 's/\\/\\\\/g')
+ print_msg "$msg" "$i"
done
done
echo | cat "$COURSES" - | while read -r d; do
# Heuristic: description is non empty line without .txt inside
if test -n "$d" && echo "$d" | grep -v ".txt" &> /dev/null; then
- echo
- echo "#: $COURSES"
- echo "msgid \"$(echo "$d" | sed 's/\\/\\\\/g')\""
- echo "msgstr \"\""
+ msg=$(echo "$d" | sed 's/\\/\\\\/g')
+ print_msg "$msg" "$COURSES"
fi
done
for i in $(find $DATA -name "*.map" | sort); do
# Only translatable string is "message"
grep -E "^\"message\"" "$i" | while read -r a b; do
- echo
- echo "#: $i"
- echo "msgid $(echo "$b" | sed 's/\\/\\\\/g')"
- echo "msgstr \"\""
+ msg=$(echo "$b" | sed 's/\\/\\\\/g; s/^"\(.*\)"$/\1/')
+ print_msg "$msg" "$i"
done
done
+for i in dist/*.desktop.in; do
+ msg=$(grep '^Comment=' $i | sed 's/^Comment=//')
+ if [ "$msg" != "" ]; then
+ print_msg "$msg" "$i" "Desktop entry comment"
+ fi
+done
+
--- /dev/null
+#!/bin/sh
+# This script reads a .desktop file from stdin and prints the same file, with
+# up-to-date translations, to stdout.
+
+while read line; do
+ # Remove translations
+ if echo $line | grep '^.*\[.*\]=' > /dev/null; then
+ continue
+ fi
+
+ echo $line
+
+ # Generate translations if current line is translatable
+ if echo $line | grep '^Comment=' > /dev/null; then
+ msgid=`echo $line | sed 's/^Comment=//'`
+ for i in po/*.po; do
+ lang=`basename $i | sed 's/\.po//'`
+ msgstr=`msgattrib --translated --no-obsolete --no-fuzzy $i \
+ | msggrep --no-location --no-wrap --msgid -F -e "$msgid" \
+ | tail -n 1 | sed 's/^msgstr "\(.*\)"$/\1/'`
+ if [ "$msgstr" != "" ]; then
+ echo "Comment[$lang]=$msgstr"
+ fi
+ done
+ fi
+done