Re: The internationalization tutorial.



[ ... ]
Most people using gtkmm do so with
autotools, so that is what the tutorial is geared towards.  If people
use other build systems and would like to contribute documentation for
doing the same thing with their preferred tools, i would think that it
would be gladly accepted and included into the gtkmm tutorial.
I don't use the auto... stuff myself, as it is way to complex for my taste. And that's complexity that doesn't really buy you what you're supposed to get, in my experience (you pretty much have to use gcc and GNU make anyway in most projects, for instance...)

But enough on that, the point is that I have some simple make rules for setup of the translation files, in the form of a special set of a "common" makefile typically included by Makefile on the "po" directory, and it is included below.

The Makefile may look something like:

DOMAIN=pcap-prime
top_srcdir=..

POFILES = no.po fr.po

include $(top_srcdir)/../include/make/po.mk

Actually, there's another include file, too, setting up variables like MSGFMT and XGETTEXT, but I'm sure you'll figure out what these are supposed to contain.

Maybe I ought to post all this elsewhere...

- Toralf





# Usage: In Makefile,
#	 DOMAIN=<gettext domain>
#	 PO_FILES=<lang1>.po [ <lang2>.po ... ]
#	 [ top_srcdir=<starting point for source file scan> ]
#	 include po.mk	


ifndef top_srcdir
top_srcdir=..
endif

CATALOGS = $(patsubst %.po,%.gmo,$(POFILES))
POTFILES = $(addprefix $(top_srcdir)/, $(shell cat POTFILES.in))

all: all-yes

all-yes: $(CATALOGS)
all-no:


$(DOMAIN).pot: $(POTFILES) POTFILES.in
	-chmod +w $@ 2>/dev/null
	$(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
	  --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \
	  --files-from=POTFILES.in \
	  --copyright-holder='$(COPYRIGHT_HOLDER)'
	-egrep -v '^("POT-Creation-Date: .*"$$|#:)' $(DOMAIN).po > $(DOMAIN).1po
	-egrep -v '^("POT-Creation-Date: .*"$$|#:)' $(DOMAIN).pot > $(DOMAIN).2po 2>/dev/null
	if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \
	  rm -f $(DOMAIN).po; touch $@; \
	else \
	  mv $(DOMAIN).po $@; \
	fi
	rm -f $(DOMAIN).1po $(DOMAIN).2po

$(POFILES): $(DOMAIN).pot
	-chmod +w $@ $ ~ 2>/dev/null
	$(MSGMERGE_UPDATE) $@ $<
	touch $@ 

install: $(CATALOGS)
	@for cat in $(CATALOGS); do \
	  lang=`basename $$cat .gmo`; \
	  dir=$(localedir)/$$lang/LC_MESSAGES; \
	  $(GINSTALL) -m 775 -d $$dir; \
	  $(GINSTALL) -m 444 $$cat $$dir/$(DOMAIN).mo; \
	  echo -e "\tinstalling $$cat as $(DESTDIR)$$dir/$(DOMAIN).mo"; \
	done

cinstall:
	@if ! $(MAKE) -q $(CATALOGS); then \
	   $(MAKE) install; \
	fi

%.mo: %.po
	@echo "$(MSGFMT) -c -o $@ $<"; \
	$(MSGFMT) -c -o t-$@ $< && mv t-$@ $@

%.gmo: %.po
	@echo "$(GMSGFMT) -c --statistics -o $@ $<"; \
	rm -f $@ && $(GMSGFMT) -c --statistics -o t-$@ $< && mv t-$@ $@

update-po: 

# *** Generate input file list - but only if it doesn't exist already.
POTFILES.in:
	find $(top_srcdir) -name "*.[chC]" | grep -v "/CVS/" | sed "s!^$(top_srcdir)/!!" > $@

# Some targets that exist in our other rule sets, and may thus be called when
# looping po with other directories; define as "null" rules here so make
# won't choke on them.
do_install dsoV clean clobber rmtargets bin_install lib_install etc_install depend dist:
	@true


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]