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.
21 COPYRIGHT="Robert Kooima"
22 BUGADDR="robert.kooima@gmail.com"
26 COURSES="$DATA"/courses.txt
30 # First, extract from source
33 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]
35 # Force encoding to UTF-8
36 sed -i "0,/^$/ s/charset=CHARSET/charset=UTF-8/" "$POTFILE"
38 # Second, extract from neverball sets and neverputt courses
39 echo "# Sets and courses"
40 for i in $(< "$SETS"); do
41 # The file names in sets.txt don't have the prefix
44 # Only translate the two first lines
45 head -2 $i | while read -r d; do
49 echo "msgid \"${d//\\/\\\\}\""
54 # the "echo | cat x -" forces the end of the last line
55 echo | cat "$COURSES" - | while read -r d; do
56 # Heuristic: description is non empty line without .txt inside
57 if test -n "$d" && echo "$d" | grep -v ".txt" &> /dev/null; then
61 echo "msgid \"${d//\\/\\\\}\""
66 # Third, extracts from levels
68 find "$DATA" -name "*.map" | sort | tee .map_list | wc -l
69 for i in `cat .map_list`; do
73 # Only translatable string is "message"
74 grep -E "^\"message\"" "$i" | while read -r a b; do
77 echo "msgid ${b//\\/\\\\}"
84 # Remove duplicates, to keep msgmerge from complaining
85 echo "# Removing duplicates."
86 msguniq -o "$POTFILE" -t UTF-8 "$POTFILE"