Give table headings more meaningful names.
[mplayer/glamo.git] / help / help_create.sh
blob87a0ade4abf1f3f67529325281a2446bf9aef8cb
1 #!/bin/sh
2 # Create the messages header file from the master source file or a translation.
3 # Missing messages are filled in from the master message file and, if
4 # requested, character set conversion is performed.
6 if test -z $2 ; then
7 echo "Error: missing parameters"
8 echo "Usage: $0 <messages file> <character set>"
9 exit 1
12 MASTER=help/help_mp-en.h
13 TARGET=help_mp.h
15 TRANSLATION=$1
16 CHARSET=$2
18 missing_messages(){
19 curr=""
21 while read -r line; do
22 if echo "$line" | grep -q '^#define' ; then
23 curr=`printf "%s\n" "$line" | cut -d ' ' -f 2`
24 if grep -q "^#define $curr[ ]" "$TRANSLATION" ; then
25 curr=""
27 else
28 if [ -z "$line" ]; then
29 curr=""
33 if [ -n "$curr" ]; then
34 printf "%s\n" "$line"
36 done
39 cat <<EOF > "$TARGET"
40 /* WARNING! This is a generated file, do NOT edit.
41 * See the help/ subdirectory for the editable files. */
43 #ifndef MPLAYER_HELP_MP_H
44 #define MPLAYER_HELP_MP_H
46 EOF
48 cat "$TRANSLATION" >> "$TARGET"
50 cat <<EOF >> "$TARGET"
52 /* untranslated messages from the English master file */
54 EOF
56 if test "$MASTER" != "$TRANSLATION" ; then
57 missing_messages < "$MASTER" >> "$TARGET"
60 cat <<EOF >> "$TARGET"
62 #endif /* MPLAYER_HELP_MP_H */
63 EOF
65 if test $CHARSET != UTF-8 ; then
66 iconv -f UTF-8 -t "$CHARSET" "$TARGET" > "${TARGET}.tmp"
67 mv "${TARGET}.tmp" "$TARGET"