make: Add support for gettext.mk

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2015-04-06 16:45:41 +00:00
commit 5206555d96
4 changed files with 72 additions and 0 deletions

53
make/gettext.mk Normal file
View file

@ -0,0 +1,53 @@
GETTEXT_LOCALE ?= $(notdir $(shell pwd))
include $(MODDIR)/make/defs.mk
include $(MODDIR)/make/rules.mk
GETTEXT_POT ?= $(PROJECT).pot
GETTEXT_PO ?= $(PROJECT).po
GETTEXT_MO ?= $(PROJECT).mo
GETTEXT_INPUT_DIRS ?= $(TOPDIR)/tools
GETTEXT_INPUT_FILES ?= $(foreach d,$(GETTEXT_INPUT_DIRS),\
$(shell find $d -name '*.php' -o -name '*.cpp'))
all:
clean: clean-mo
rm -rf *~ .*.swp
install: install_MO
all: $(GETTEXT_MO)
distclean: clean
extract: $(GETTEXT_POT)
clean-mo:
rm -f *.mo *.tmp
$(GETTEXT_POT): $(GETTEXT_INPUT_FILES)
xgettext --package-name $(PROJECT) --package-version $(DIST_VERSION) \
--default-domain $(PROJECT) \
--output $@.tmp $(GETTEXT_INPUT_FILES)
mv $@.tmp $@
init: $(GETTEXT_POT)
msginit --no-translator --locale $(GETTEXT_LOCALE) \
--output-file $(GETTEXT_PO).tmp --input $<
sed -i 's/charset=ASCII/charset=UTF-8/' $(GETTEXT_PO).tmp
mv $(GETTEXT_PO).tmp $(GETTEXT_PO)
merge: $(GETTEXT_POT)
msgmerge -v --lang $(GETTEXT_LOCALE) --output-file $(GETTEXT_PO).tmp \
$(wildcard $(GETTEXT_PO)) $<
mv $(GETTEXT_PO).tmp $(GETTEXT_PO)
edit: $(GETTEXT_POT)
poedit $(GETTEXT_PO)
$(GETTEXT_MO): $(GETTEXT_PO)
msgfmt --check --verbose --output-file $@.tmp $<
mv $@.tmp $@
#msginit --no-translator --locale es_MX --output-file $(PROJECT)_spanish.po --input $(PROJECT).pot
#sed --in-place $(PROJECT)_spanish.po --expression='/"hello, world!"/,/#: / s/""/"hola mundo"/'
#mkdir --parents ./es_MX.utf8/LC_MESSAGES
#msgfmt --check --verbose --output-file ./es_MX.utf8/LC_MESSAGES/$(PROJECT).mo $(PROJECT)_spanish.po