Merge svn changes up to r28348
[mplayer.git] / help / help_create.sh
blobccb756d6b9e1b634125e331d91947bdad722d8b7
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 MASTER=help/help_mp-en.h
7 TARGET=help_mp.h
9 TRANSLATION=$1
10 CHARSET=$2
12 missing_messages(){
13 curr=""
15 while read -r line; do
16 if echo "$line" | grep -q '^#define' ; then
17 curr=`printf "%s\n" "$line" | cut -d ' ' -f 2`
18 if grep -q "^#define $curr[ ]" "$TRANSLATION" ; then
19 curr=""
21 else
22 if [ -z "$line" ]; then
23 curr=""
27 if [ -n "$curr" ]; then
28 printf "%s\n" "$line"
30 done
33 cat <<EOF > "$TARGET"
34 /* WARNING! This is a generated file, do NOT edit.
35 * See the help/ subdirectory for the editable files. */
37 #ifndef MPLAYER_HELP_MP_H
38 #define MPLAYER_HELP_MP_H
40 EOF
42 cat "$TRANSLATION" >> "$TARGET"
44 cat <<EOF >> "$TARGET"
46 /* untranslated messages from the English master file */
48 EOF
50 if test "$MASTER" != "$TRANSLATION" ; then
51 missing_messages < "$MASTER" >> "$TARGET"
54 cat <<EOF >> "$TARGET"
56 #endif /* MPLAYER_HELP_MP_H */
57 EOF
59 if test $CHARSET != UTF-8 ; then
60 iconv -f UTF-8 -t "$CHARSET" "$TARGET" > "${TARGET}.tmp"
61 mv "${TARGET}.tmp" "$TARGET"