#
# make translations with gettext
#


PYTHON_FILES:=$(shell find keepnote -name '*.py')
SRC_FILES=$(PYTHON_FILES) keepnote/rc/keepnote.glade.h
INTLTOOL_EXTRACT:=$(shell which intltool || echo /usr/share/intltool-debian/intltool-extract)
LOCALE_DIR=keepnote/rc/locale

#=============================================================================
# rules

# make messages file, extracts all strings in _()
extract:
	xgettext --from-code=utf-8 -k_ -kN_ \
	-o gettext/messages.pot $(SRC_FILES)


# make a new translation
new:
	msginit -l $(LANG) -o gettext/$(LANG).po --input gettext/messages.pot

# update language file with new strings
update:
	msgmerge -N -U gettext/$(LANG).po gettext/messages.pot

# make translations for application
make:
	mkdir -p $(LOCALE_DIR)/$(LANG)/LC_MESSAGES/
	msgfmt gettext/$(LANG).po -o $(LOCALE_DIR)/$(LANG)/LC_MESSAGES/keepnote.mo

#=============================================================================
# depends

keepnote/rc/keepnote.glade.h: keepnote/rc/keepnote.glade
	$(INTLTOOL_EXTRACT) --type=gettext/glade keepnote/rc/keepnote.glade

