# Copyright (C) 1996,1997 Robert H”hne, see COPYING.RH for details 
# This file is part of RHIDE. 

srcdir=$(RHIDESRC)/po
VPATH=$(srcdir)

project=
po_files=
src_files=$(po_files) msgcat.c msgcat.gpr msgcat.mak makefile \
	$(addsuffix .po,$(LANGUAGES)) \
	readme.lan makefile.src rhide.env rhide.var
#	$(addsuffix .cat,$(LANGUAGES))

update_files=msgcat.gpr msgcat.mak
cfg_files=msgcat.gpr msgcat.mak

subdirs=
po_subdirs=..

include $(RHIDESRC)/common.mak

ifeq ($(msgfmt),)
msgfmt=msgfmt
endif

ifeq ($(xgettext),)
xgettext=xgettext
endif

MSGCAT=./msgcat.exe

_po_list: po_list
	sed -e 's,^../,,' -e 's, ../, ,g' po_list > _po_list

potfiles.po: _po_list
	$(xgettext) --default-domain=potfiles --add-comments --keyword=_ \
	  --keyword=__ --directory=$(RHIDESRC) --omit-header \
	  --add-location $(shell cat _po_list)
	touch $@
	rm -f _po_list

T=$(subst /,\,$@)

# I'm using now my own program to merge previous translations
# the rule here translates only the exact matchings. If you 
# want translate all the needed strings, look in the file
# msgcat.c for a description of it's usage
MSGCAT_OPTIONS=-s

$(addsuffix .po,$(LANGUAGES)): potfiles.po $(MSGCAT)
	-cp -f $@ $(subst .po,.bak,$@)
	$(MSGCAT) $(MSGCAT_OPTIONS) -cat $(subst .po,.cat,$@) \
	  $(wildcard $@) $< $@
	
%.mo: %.po
	-$(msgfmt) -o $@ $<
	touch $@

languages: $(addsuffix .mo,$(LANGUAGES))

languages.src: $(addsuffix .po,$(LANGUAGES))

%.ins: %.mo
	$(INSTALL_DIR) $(locale_prefix)/$(install_localedir)/$*/LC_MESSAGES
	$(INSTALL_DATA) $< $(locale_prefix)/$(install_localedir)/$*/LC_MESSAGES/$(PACKAGE).mo
	echo $(install_localedir)/$*/LC_MESSAGES/$(PACKAGE).mo >> $(logfile)

install.languages.start:
	rm -f $(logfile)

install.languages: languages install.languages.start \
	  $(addsuffix .ins,$(LANGUAGES))

install:: install.languages

include msgcat.mak

%.zip: %.po
	rm -f $@
	zip -9j $@ $< $(subst .po,.cat,$<) potfiles.po $(MSGCAT) $(msgfmt) \
	  $(srcdir)/readme.lan
	
$(addsuffix .zip,$(LANGUAGES)): $(MSGCAT)

lang_packages: $(addsuffix .zip,$(LANGUAGES))
