Specified with configure --lang.
Adds missing defines from english master file.
all: Makefile config.h $(PROG) $(SPROG)
-$(PROG): $(OBJS)
+msg.h: msg.en.h $(MSG_FILE)
+ @echo "Linking $(MSG_FILE) to msg.h"
+ @echo '// WARNING! This is a generated file. Do NOT edit.' > msg.h
+ @echo '// See msg.*.h for the editable files.' >> msg.h
+ @echo '#include "$(MSG_FILE)"' >> msg.h
+
+ifneq ($(MSG_FILE),msg.en.h)
+ @echo "Adding untranslated messages to msg.h"
+ @echo '// untranslated messages from the English master file:' >> msg.h
+ @./msg_diff.sh $(MSG_FILE) < msg.en.h >> msg.h
+endif
+
+$(PROG): msg.h $(OBJS)
$(CC) -o $(PROG) $(OBJS) $(LFLAGS) $(CFLAGS)
-$(SPROG): $(SOBJS)
+$(SPROG): msg.h $(SOBJS)
$(CC) -o $(SPROG) $(SOBJS) $(LFLAGS) $(CFLAGS)
.c.o:
tar -cvzof $$dir.tar.gz $$dir
clean:
- rm -f $(PROG) $(OBJS) $(SPROG) $(SOBJS) a.out
+ rm -f $(PROG) $(OBJS) $(SPROG) $(SOBJS) msg.h a.out
cleandir: clean
rm -f config.mak config.h
#include "board.h"
#include "curses.h"
#include "inet.h"
-#include "msg.en.h"
+#include "msg.h"
static struct option options[] = {
{ "ascii", 2, 0, 'a' },
--curses-hack)
CURSES_HACK=true
;;
+ --lang)
+ lang="$1"
+ shift
+ ;;
*)
cat << "END"
Usage: ./configure [options...]
--cextra <opt>: Set extra C flags
--lextra <opt>: Set extra linker flags
--curses-hack: Disable scroll-optimization for broken curses
+ --lang <code>: Preferred interface language (default "en")
END
exit 1
;;
rm -f test.c test.o a.out
+test -z "$lang" && lang=en
+MSG_FILE=msg.$lang.h
+if [ ! -f $MSG_FILE ]; then
+ echo "Error: $MSG_FILE not found"
+ exit
+fi
+
echo "Creating config.mak"
cat > config.mak << END
### Automatically generated by ./configure ###
LEXTRA = $LEXTRA
LFLAGS = $LEXTRA $LFLAGS
CFLAGS = \$(CEXTRA) \$(COPT)
+MSG_FILE = $MSG_FILE
END
echo "Creating config.h"
#include "curses.h"
#include "util.h"
#include "board.h"
-#include "msg.en.h"
+#include "msg.h"
#ifdef NCURSES_VERSION
# define HAVE_NCURSES
--- /dev/null
+#!/bin/sh
+
+# Copied help_diff.sh from the MPlayer project <http://www.mplayerhq.hu>
+# copyright MPlayer team
+
+# This script walks through the master (stdin) help/message file, and
+# prints (stdout) only those messages which are missing from the help
+# file given as parameter ($1).
+#
+# Example: msg_diff.sh msg.eo.h < msg.en.h > missing.h
+
+curr=""
+
+while read -r line; do
+ if echo "$line" | grep '^#define' > /dev/null 2>&1; then
+ curr=`printf "%s\n" "$line" | cut -d ' ' -f 2`
+ if grep "^#define $curr[ ]" $1 > /dev/null 2>&1; then
+ curr=""
+ fi
+ else
+ if [ -z "$line" ]; then
+ curr=""
+ fi
+ fi
+
+ if [ -n "$curr" ]; then
+ printf "%s\n" "$line"
+ fi
+done