Mercurial > mplayer.hg
comparison help/help_create.sh @ 26878:73921138ff30
Move messages header file creation to a separate shell script.
author | diego |
---|---|
date | Tue, 27 May 2008 22:03:21 +0000 |
parents | |
children | eb42079ed5f7 |
comparison
equal
deleted
inserted
replaced
26877:4ab1cfcee430 | 26878:73921138ff30 |
---|---|
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. | |
5 | |
6 MASTER=help/help_mp-en.h | |
7 TARGET=help_mp.h | |
8 | |
9 TRANSLATION=$1 | |
10 CHARSET=$2 | |
11 | |
12 missing_messages(){ | |
13 curr="" | |
14 | |
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="" | |
20 fi | |
21 else | |
22 if [ -z "$line" ]; then | |
23 curr="" | |
24 fi | |
25 fi | |
26 | |
27 if [ -n "$curr" ]; then | |
28 printf "%s\n" "$line" | |
29 fi | |
30 done | |
31 } | |
32 | |
33 cat <<EOF > "$TARGET" | |
34 /* WARNING! This is a generated file, do NOT edit. | |
35 * See the help/ subdirectory for the editable files. */ | |
36 | |
37 #ifndef MPLAYER_HELP_MP_H | |
38 #define MPLAYER_HELP_MP_H | |
39 | |
40 EOF | |
41 | |
42 cat "$TRANSLATION" >> "$TARGET" | |
43 | |
44 cat <<EOF >> "$TARGET" | |
45 | |
46 /* untranslated messages from the English master file */ | |
47 | |
48 EOF | |
49 | |
50 if test "$MASTER" != "$TRANSLATION" ; then | |
51 missing_messages < "$MASTER" >> "$TARGET" | |
52 fi | |
53 | |
54 cat <<EOF >> "$TARGET" | |
55 | |
56 #endif /* MPLAYER_HELP_MP_H */ | |
57 EOF | |
58 | |
59 if test $CHARSET != UTF-8 ; then | |
60 iconv -f UTF-8 -t "$CHARSET" "$TARGET" > "${TARGET}.tmp" | |
61 mv "${TARGET}.tmp" "$TARGET" | |
62 fi |