Minor tweaks in TRANSLATIONS.
[neverball] / extractpo.sh
index 15233f1..5ee9472 100755 (executable)
 # MERCHANTABILITY or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU
 # General Public License for more details.
 
-              
+set -B
+
 POTFILE="$1"
 DOMAIN="$2"
 COPYRIGHT="Robert Kooima"
 BUGADDR="robert.kooima@gmail.com"
 
+DATA=data
+SETS="$DATA"/sets.txt
+COURSES="$DATA"/courses.txt
+
 export LC_ALL=C
 
 # First, extract from source
@@ -32,26 +37,26 @@ sed -i "0,/^$/ s/charset=CHARSET/charset=UTF-8/" "$POTFILE"
 
 # Second, extract from neverball sets and neverputt courses
 echo "# Sets and courses"
-for i in $(< data/sets.txt); do
-       i=${i/#/data/}
+for i in $(< "$SETS"); do
+       i="$DATA"/"$i"
 
        # Only translate the two first lines
        head -2 $i | while read -r d; do
                echo
                echo "#: $i"
-               # Convert \ to \\ 
+               # Convert \ to \\
                echo "msgid \"${d//\\/\\\\}\""
                echo "msgstr \"\""
        done >> $POTFILE
 done
 
 # the "echo | cat x -" forces the end of the last line
-echo | cat data/courses.txt - | while read -r d; do
+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 "#: $i"
-               # Convert \ to \\ 
+               echo "#: $COURSES"
+               # Convert \ to \\
                echo "msgid \"${d//\\/\\\\}\""
                echo "msgstr \"\""
        fi
@@ -59,7 +64,7 @@ done >> $POTFILE
 
 # Third, extracts from levels
 echo -n "# Levels: "
-find data -name "*.map" | sort | tee .map_list | wc -l
+find "$DATA" -name "*.map" | sort | tee .map_list | wc -l
 for i in `cat .map_list`; do
        # Check encoding?
        # file --mime $i
@@ -79,4 +84,3 @@ rm .map_list
 echo "# Removing duplicates."
 msguniq -o "$POTFILE" -t UTF-8 "$POTFILE"
 
-# vim:noet:sts=8: