mym2: fixed missing French accents
[neverball] / scripts / extractpo.sh
1 #!/bin/sh
2 # This script extracts translatable messages from maps and sets.
3 # Copyright (C) 2006 Jean Privat
4 #
5 # Part of the Neverball project
6 # http://icculus.org/neverball/
7 #
8 # NEVERBALL is  free software; you can redistribute  it and/or modify
9 # it under the  terms of the GNU General  Public License as published
10 # by the Free  Software Foundation; either version 2  of the License,
11 # or (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful, but
14 # WITHOUT  ANY  WARRANTY;  without   even  the  implied  warranty  of
15 # MERCHANTABILITY or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU
16 # General Public License for more details.
17
18 test -n "$1" || exit 1
19
20 LC_ALL=C
21 export LC_ALL
22
23 cd "$1"
24
25 DATA="data"
26 SETS="$DATA/sets.txt"
27 COURSES="$DATA/courses.txt"
28
29 for i in $(cat "$SETS"); do
30     i="$DATA/$i"
31
32     # Only translate the two first lines
33     head -n 2 $i | while read -r d; do
34         echo
35         echo "#: $i"
36         echo "msgid \"$(echo "$d" | sed 's/\\/\\\\/g')\""
37         echo "msgstr \"\""
38     done
39 done
40
41 # the "echo | cat x -" forces the end of the last line
42 echo | cat "$COURSES" - | while read -r d; do
43     # Heuristic: description is non empty line without .txt inside
44     if test -n "$d" && echo "$d" | grep -v ".txt" &> /dev/null; then
45         echo
46         echo "#: $COURSES"
47         echo "msgid \"$(echo "$d" | sed 's/\\/\\\\/g')\""
48         echo "msgstr \"\""
49     fi
50 done
51
52 for i in $(find $DATA -name "*.map" | sort); do
53     # Only translatable string is "message"
54     grep -E "^\"message\"" "$i" | while read -r a b; do
55         echo
56         echo "#: $i"
57         echo "msgid $(echo "$b" | sed 's/\\/\\\\/g')"
58         echo "msgstr \"\""
59     done
60 done
61