2 # This program creates the neverball.pot file from source code and level files.
4 # Copyright (C) 2006 Jean Privat
5 # Part of the Neverball Project http://icculus.org/neverball/
7 # NEVERBALL is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published
9 # by the Free Software Foundation; either version 2 of the License,
10 # or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # General Public License for more details.
20 COPYRIGHT="Robert Kooima"
21 BUGADDR="robert.kooima@gmail.com"
25 # First, extract from source
28 xgettext --from-code=UTF-8 --keyword=_ --keyword=N_ --keyword=sgettext -d "$DOMAIN" --copyright-holder="$COPYRIGHT" --msgid-bugs-address="$BUGADDR" -F -o "$POTFILE" {ball,putt,share}/*.[ch]
30 # Force encoding to UTF-8
31 sed -i "0,/^$/ s/charset=CHARSET/charset=UTF-8/" "$POTFILE"
33 # Second, extract from neverball sets and neverputt courses
34 echo "# Sets and courses"
35 for i in $(< data/sets.txt); do
38 # Only translate the two first lines
39 head -2 $i | while read -r d; do
43 echo "msgid \"${d//\\/\\\\}\""
48 # the "echo | cat x -" forces the end of the last line
49 echo | cat data/courses.txt - | while read -r d; do
50 # Heuristic: description is non empty line without .txt inside
51 if test -n "$d" && echo "$d" | grep -v ".txt" &> /dev/null; then
53 echo "#: data/courses.txt"
55 echo "msgid \"${d//\\/\\\\}\""
60 # Third, extracts from levels
62 find data -name "*.map" | sort | tee .map_list | wc -l
63 for i in `cat .map_list`; do
67 # Only translatable string is "message"
68 grep -E "^\"message\"" "$i" | while read -r a b; do
71 echo "msgid ${b//\\/\\\\}"
78 # Remove duplicates, to keep msgmerge from complaining
79 echo "# Removing duplicates."
80 msguniq -o "$POTFILE" -t UTF-8 "$POTFILE"