PO-FILES= cs.po es.po hu.po fr.po de.po ro.po it.po pt.po
LANGUAGES=$(PO-FILES:.po=)

# Maybe this should be autogenerated by "configure".
LOCALEDIR=/usr/share/locale

# If other files will be translated, they must be also here:
CSOURCES=../ui/ui.c ../ui-hlp/menu.c \
../ui-hlp/play.c ../ui-hlp/ui_helper.c \
../engine/zoom.c ../engine/btrace.c \
../ui/dialog.c ../ui/filesel.c ../ui-hlp/render.c \
../ui/ui-drv/win32/ui_win32.c \
../ui/ui-drv/cocoa/AppController.m \
../ui/ui-drv/cocoa/CustomDialog.m


MO-FILES = $(LANGUAGES:=.mo)

all: $(MO-FILES)

install: $(MO-FILES)
	@for i in $(LANGUAGES); do \
	 /usr/bin/install -c -d $(DESTDIR)$(LOCALEDIR)/$$i/LC_MESSAGES; \
	 /usr/bin/install -c -m 444 $$i.mo $(DESTDIR)$(LOCALEDIR)/$$i/LC_MESSAGES/xaos.mo; \
	 done

install-win: $(MO-FILES)
	@for i in $(LANGUAGES); do \
	 /usr/bin/install -c -d $(DESTDIR)/locale/$$i/LC_MESSAGES; \
	 /usr/bin/install -c -m 444 $$i.mo $(DESTDIR)/locale/$$i/LC_MESSAGES/xaos.mo; \
	 done

clean:
	rm -f $(MO-FILES)

distclean: clean
	rm Makefile

messages.pot: $(CSOURCES)
	/usr/bin/xgettext -o messages.pot $(CSOURCES)

$(PO-FILES): messages.pot
	test -e $@
	/usr/bin/msgmerge $@ messages.pot > $@.new
	mv $@.new $@

$(MO-FILES): $(PO-FILES)
	/usr/bin/msgfmt -o $@ -c -v --statistics $(@:.mo=.po)

new-languages: Makefile
	@for i in $(LANGUAGES); do \
	 test -e $$i.po || cp messages.pot $$i.po; \
	 done
