Package: hex-a-hop
Version: 0.0.20070315-2
Tags: l10n patch

Hi,

I noticed that the first help screen is not translatable by default as
xgettext has trouble extracting _("Welcome to " GAMENAME "!"). It doesn't
extract anything behind the macro. That's why I suggest to apply xgettext
on preprocessed files and attached a patch for it (apply it after applying
all patches from debian/patches/, I hope it is OK so).

(I had really a lot of trouble, often the package could not build
because of my changes as the previous patches could not be reverted.
I also created first a backup copy of the source directory with suffix
.orig (to patch later against it) which was always deleted by
dpkg-buildpackage!!!)

Since the preprocessed file hex_puzzzle.cpp (shouldn't is be renamed to
hex_puzzle.cpp?) includes not only the affected menus.h but also
level_list.h I merged both POT files (messages and levels) into one.
That's why I assume you merge your translations levels.es.po and
messages.es.po into es.po. I think this is better than maintaining two
files.

Please note that I now also update all translations during package build
(in the clean target which is called at the beginning of a new build).
Translations will never be outdated again!

The file debian/i18n/files.list should now be deleted, it is no longer
used.

PS: It is not obvious that the game (at least the help) insert explicit
linebreaks once it finds "  " in a message and starts a new paragraph on
"    ". If the POT file is distributed as well (and not only generated)
I suggest to document this at the beginning of this file so that these
comments are merged automatically into all <lang>.po files. I also
suggest to document other messages for translators in C++ files (just
prepend a /* TRANSLATORS: A hint for translators*/ before
difficult gettext messages as this is copied into PO files as well).

Jens
Nur in hex-a-hop-0.0.20070315.unchanged/debian/i18n: files.list.
diff -ur hex-a-hop-0.0.20070315.unchanged/debian/i18n/Makefile hex-a-hop-0.0.20070315/debian/i18n/Makefile
--- hex-a-hop-0.0.20070315.unchanged/debian/i18n/Makefile	2007-08-11 23:55:41.000000000 +0200
+++ hex-a-hop-0.0.20070315/debian/i18n/Makefile	2007-08-12 00:00:47.000000000 +0200
@@ -17,51 +17,44 @@
 
 LOCALEDIR=./
 
-all: messages.pot levels.pot build-stamp
+all: messages.pot build-stamp
 
-levels.pot:
-	@echo Creatting Templata \"[EMAIL PROTECTED]"
-	cd ../..; xgettext -k_ -o "debian/i18n/$@" level_list.h --from-code=iso-8859-1
-
-messages.pot:
-	@echo Creatting Templata \"[EMAIL PROTECTED]"
-	cd ../..; xgettext -k_ -o "debian/i18n/$@" -f debian/i18n/files.list --from-code=iso-8859-1
-
-%.tmp.po: levels.%.po messages.%.po
-	msgcat -o $@ $+
-
-%.tmp.po: %.po
-	cp $< $@
+# xgettext fails on _("Welcome to " GAMENAME "!") (doesn't extract anything
+# behind the macro, so we preprocess hex_puzzzle.cpp (which includes menus.h)
+# first
+hex_puzzzle_preprocessed.cpp: ../../hex_puzzzle.cpp ../../menus.h
+	$(CXX) $(CXXFLAGS) -E ../../hex_puzzzle.cpp -o $@
+
+messages.pot: hex_puzzzle_preprocessed.cpp
+	@echo Creating Template \"[EMAIL PROTECTED]"
+	cd ../..; xgettext --add-comments="TRANSLATORS:" -k_ -o "debian/i18n/$@" gfx.cpp debian/i18n/hex_puzzzle_preprocessed.cpp level_list.h --from-code=iso-8859-1
 
 build: build-stamp
 build-stamp:
-	@for i in `cat languages.list` ; do \
-		echo Setting Up Language \"$$i\" ; \
-		$(MAKE) $$i.tmp.po ; \
+	@for i in $$(cat languages.list); do \
+		echo Building \"$$i\" translation; \
+		msgfmt $$i.po -o $$i.mo ; \
 	done
-	@if ls *.tmp.po 2>/dev/null ; then  \
-		for f in *.tmp.po; do \
-			i=`basename $$f .tmp.po` ; \
-			echo Building Language \"$$i\" ; \
-			msgfmt $$f -o $$i.mo ; \
-		done \
-	fi
 	touch build-stamp
 
 clean:
 	#for f in *.po; do i=`echo $$f | awk 'BEGIN {FS="."} {print $$1}'`; rm -rf "$$i"; done
+	# Merge all (old) PO files with POT file to ship up-to-date files!
+	# We cannot touch source PO files during build but here is happens normally!?
+	$(MAKE) messages.pot
+	@for i in $$(cat languages.list); do \
+		echo Updating \"$$i\" translation; \
+		msgmerge --update $$i.po messages.pot ; \
+	done
 	rm -f *.mo
-	rm -f *.tmp.po
 	rm -f *.pot
+	rm -f hex_puzzzle_preprocessed.cpp
 	rm -f build-stamp
 
 install: build-stamp
-	if ls *.mo 2>/dev/null ; then \
-		for f in *.mo; do \
-			i=`basename $$f .mo` ; \
-			echo Installing Language \"$$i\" ; \
-			install -d $(LOCALEDIR)$$i ; \
-			install -p -d -m 755 $(LOCALEDIR)$$i/LC_MESSAGES ; \
-			install -m 644 $$f $(LOCALEDIR)$$i/LC_MESSAGES/hex-a-hop.mo ; \
-		done \
-	fi
+	@for i in $$(cat languages.list); do \
+		echo Installing \"$$i\" translation; \
+		install -d $(LOCALEDIR)$$i ; \
+		install -p -d -m 755 $(LOCALEDIR)$$i/LC_MESSAGES ; \
+		install -m 644 $$i.mo $(LOCALEDIR)$$i/LC_MESSAGES/hex-a-hop.mo ; \
+	done
diff -ur hex-a-hop-0.0.20070315.unchanged/debian/patches/gettext_i18n.patch hex-a-hop-0.0.20070315/debian/patches/gettext_i18n.patch
--- hex-a-hop-0.0.20070315.unchanged/debian/patches/gettext_i18n.patch	2007-08-11 23:55:41.000000000 +0200
+++ hex-a-hop-0.0.20070315/debian/patches/gettext_i18n.patch	2007-08-12 00:02:50.000000000 +0200
@@ -52,7 +52,7 @@
      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
  
-+#include "i18n.h"
++#include "i18n.h"
  
  //////////////////////////////////////////////////////
  // Config
@@ -413,8 +413,8 @@
      along with this program; if not, write to the Free Software
      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
-+
-+#include "i18n.h"
++
++#include "i18n.h"
  
  #include "state.h"
  
diff -ur hex-a-hop-0.0.20070315.unchanged/debian/rules hex-a-hop-0.0.20070315/debian/rules
--- hex-a-hop-0.0.20070315.unchanged/debian/rules	2007-08-11 23:55:41.000000000 +0200
+++ hex-a-hop-0.0.20070315/debian/rules	2007-08-12 00:03:37.000000000 +0200
@@ -29,7 +29,7 @@
 build-stamp: configure-stamp 
 	dh_testdir
 	$(MAKE) CXXFLAGS="$(CFLAGS)" NAME="hex-a-hop" DATA_DIR="/usr/share/games/hex-a-hop"
-	$(MAKE) -C debian/i18n
+	$(MAKE) CXXFLAGS="$(CFLAGS)" NAME="hex-a-hop" DATA_DIR="/usr/share/games/hex-a-hop" -C debian/i18n
 	touch $@
 
 clean:

Reply via email to