My l10n makefile

To easily gather .pot files, combine them with existing .po files and converting them to .mo files, I created this makefile for use with automake:

.PHONY: _site.pot backup
POFILES:=$(wildcard *.po)
NOW=$(shell date +%s)
 
all:    backup
        make $(POFILES:.po=.mo)
 
%.mo:   %.po
        echo Generating $@
        msgfmt -o $@ $< || echo -e "\033[33;1m $@ is wrong \033[0m"
 
%.po:   _site.pot
        if [ -e $@ ]; then \
        mv $@ $(@:.po=.potmp) ; msgmerge --no-fuzzy-matching $(@:.po=.potmp) _site.pot > $@ ; \
        rm $(@:.po=.potmp) ; \
        else \
        echo Creating new file ; cp _site.pot $@ ; \
        fi
 
_site.pot: 
        find /var/www/html -iname "*.php" | grep -v wpcode > my-php-files
        xgettext --from-code=utf-8 -d site -f my-php-files --keyword=_e --keyword=__ -o - | sed "s/CHARSET/UTF-8/" > _site.pot
        rm my-php-files
 
backup:
        mkdir -f .backup
        tar zcf .backup/backup-$(NOW).tgz *.po Makefile

Continue Reading…

© GeekLabInfo My l10n makefile is a post from GeekLab.info. You are free to copy materials from GeekLab.info, but you are required to link back to http://www.geeklab.info

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...