XGETTEXTFLAGS=--indent --foreign-user
MSGMERGEFLAGS=--indent
MSGFMTFLAGS=--statistics

.SUFFIXES: .po .mo
.PHONY: all .po .mo .po.mo locale messages en.po
all: locale
messages: en.po

## To update translations probably what you want to do is:
# make en.po          [extracts english strings from source code]
# make cleanmo        [deletes binary mo files]
# make                [updates non-english po files with latest en.po strings]
# (edit the po files)
# make                [creates binary mo files from non-english po files]
#
#
## modify these when more languages are added ###################################
#make en.po; make cleanmo; make
locale: de.mo es.mo fr.mo it.mo nl.mo

install-locale: locale
	install -m 0644 de.mo $(LOCALEPATH)/de/LC_MESSAGES/${binname}.mo
	install -m 0644 es.mo $(LOCALEPATH)/es/LC_MESSAGES/${binname}.mo
	install -m 0644 fr.mo $(LOCALEPATH)/fr/LC_MESSAGES/${binname}.mo
	install -m 0644 it.mo $(LOCALEPATH)/it/LC_MESSAGES/${binname}.mo
	install -m 0644 nl.mo $(LOCALEPATH)/nl/LC_MESSAGES/${binname}.mo

uninstall-locale:
	rm -f $(LOCALEPATH)/de/LC_MESSAGES/${binname}.mo
	rm -f $(LOCALEPATH)/es/LC_MESSAGES/${binname}.mo
	rm -f $(LOCALEPATH)/fr/LC_MESSAGES/${binname}.mo
	rm -f $(LOCALEPATH)/it/LC_MESSAGES/${binname}.mo
	rm -f $(LOCALEPATH)/nl/LC_MESSAGES/${binname}.mo


## no user-serviceable parts below ##############################################

en.po:
	cp -f $@ $@~
	xgettext $(XGETTEXTFLAGS) -D .. -k_ $(SOURCES) $(STDSOURCES) -o $@.extracted
	msgmerge $(MSGMERGEFLAGS) -o $@ $@~ $@.extracted
	rm -f $@.extracted

.po.mo: en.po
	test -f $^ || touch $^
	cp -f $^ $^~
	msgmerge $(MSGMERGEFLAGS) -o $^.new $^~ en.po && mv -f $^.new $^
	@echo " "
	msgfmt $(MSGFMTFLAGS) $^ -o $@
	@echo " "

cleanmo:
	rm -f *.mo

cleanpo~:
	rm -f *.po~

include ../Makefile
UPCLIENT_VERSION = `sed -n 's/"//g;/\#define UPCLIENT_VERSION /s///p' ../version.h`
