| 1,98 → 1,103 |
| # Makefile for various po files. |
| ### Makefile for GNU gettext (.po) files |
| |
| srcdir = . |
| targetdir= ./LocaleData |
| |
| #CATALOGS = $(addsuffix .po, LINGUAS) |
| CATALOGS = $(LINGUAS) |
| CATOBJEXT = .po |
| CATALOGS = $(addsuffix $(CATOBJEXT), $(LINGUAS)) |
| MO_FILES = $(addsuffix .mo, $(LINGUAS)) |
| |
| XGETTEXT = xgettext |
| MSGMERGE = msgmerge |
| MSGFMT = msgfmt |
| XGETTEXT = xgettext |
| CATOBJEXT = .po |
| |
| ## Programming language: disable to let it be guessed based on filename suffix |
| prog_language = --language=PHP |
| |
| ## Character encoding of source files: disable for ASCII |
| encoding = --from-code=UTF-8 |
| |
| ## Translation keyword: disable to let it be determined based on the prog. language |
| # --keyword --keyword='_' --keyword='$$__' --keyword=__ --keyword=__x \ |
| # --keyword=__n:1,2 --keyword=__nx:1,2 --keyword=__xn:1,2 \ |
| # --keyword=__p:1c,2 --keyword=__np:1c,2,3 \ |
| # --keyword=__npx:1c,2,3 --keyword=N__ --keyword=N__n:1,2 \ |
| # --keyword=N__p:1c,2 --keyword=N__np:1c,2,3 --keyword=%__ |
| keywords = --keyword=tr |
| |
| include PACKAGE |
| |
| TD = $(strip $(TEXTDOMAIN)) |
| |
| default: help |
| srcfiles_list = $(srcdir)/POTFILES.in |
| srcfiles = $(shell cat $(srcfiles_list)) |
| |
| all: $(TD).pot update-po update-mo install |
| |
| .PHONY: help |
| help: |
| @echo "Available targets:" |
| @echo " pot - remake master catalog" |
| @echo " update-po - merge po files" |
| @echo " update-mo - regenerate mo files" |
| @echo " install - install mo files" |
| @echo " all - all of the above" |
| @echo 'Available targets:'; \ |
| echo ' pot - remake master catalog'; \ |
| echo ' update-po - merge po files'; \ |
| echo ' update-mo - regenerate mo files'; \ |
| echo ' install - install mo files'; \ |
| echo ' all - all of the above' |
| |
| POTFILES = $(srcdir)/POTFILES.in \ |
| $(shell cat $(srcdir)/POTFILES.in) |
| |
| .PHONY: pot |
| pot: $(TD).pot |
| |
| clean: |
| rm -f *~ *.bak *.mo |
| .PHONY: update-po |
| update-po: $(CATALOGS) |
| |
| # FIXME: The parameter --from-code is only needed if your sources contain |
| # any 8 bit data (even in comments). UTF-8 is only a guess here, but it |
| # will at least accept any 8 bit data. |
| # |
| # The parameter "--language=perl" is not strictly needed because the |
| # source language of all our files will be auto-detected by xgettext |
| # by their filename extension. You should even avoid this parameter |
| # if you want to extract strings from multiple source languages. |
| # --keyword --keyword='_' --keyword='$$__' --keyword=__ --keyword=__x \ |
| # --keyword=__n:1,2 --keyword=__nx:1,2 --keyword=__xn:1,2 \ |
| # --keyword=__p:1c,2 --keyword=__np:1c,2,3 \ |
| # --keyword=__npx:1c,2,3 --keyword=N__ --keyword=N__n:1,2 \ |
| # --keyword=N__p:1c,2 --keyword=N__np:1c,2,3 --keyword=%__ \ |
| $(TD).pot: $(POTFILES) |
| $(XGETTEXT) --output=$(srcdir)/$(TD).pox --from-code=utf-8 \ |
| --add-comments=TRANSLATORS: --files-from=$(srcdir)/POTFILES.in \ |
| --package-name="$(PACKAGE_NAME)" \ |
| --package-version="$(PACKAGE_VERSION)" \ |
| --copyright-holder="$(COPYRIGHT_HOLDER)" \ |
| --msgid-bugs-address="$(MSGID_BUGS_ADDRESS)" \ |
| rm -f $@ && mv $(TD).pox $@ |
| .PHONY: update-mo |
| update-mo: $(MO_FILES) |
| |
| .PHONY: install |
| install: $(MO_FILES) |
| cd $(srcdir); \ |
| @cd $(srcdir); \ |
| targetdir='$(targetdir)'; \ |
| languages='$(LINGUAS)'; \ |
| for lang in $$languages; do \ |
| mkdir -p "$$targetdir/$$lang/LC_MESSAGES" || exit 1; \ |
| dest="$$targetdir/$$lang/LC_MESSAGES/$(TD).mo"; \ |
| cat="$$lang.mo"; \ |
| echo "installing $$cat as $$dest"; \ |
| cp -f $$cat $$dest && chmod 644 $$dest || exit 1; \ |
| printf "Installing \`%s' as \`%s' ... " "$$cat" "$$dest"; \ |
| mkdir -p "$$targetdir/$$lang/LC_MESSAGES" || exit 1; \ |
| cp -f "$$cat" "$$dest" && chmod 644 "$$dest" || exit 1; \ |
| echo "done."; \ |
| done |
| |
| update-mo: $(MO_FILES) |
| .PHONY: all |
| all: install |
| |
| update-po: |
| $(MAKE) $(TD).pot |
| cd $(srcdir); \ |
| catalogs='$(CATALOGS)'; \ |
| for cat in $$catalogs; do \ |
| cat=`basename $$cat`; \ |
| lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \ |
| mv $$lang.po $$lang.old.po; \ |
| echo "$$lang:"; \ |
| if $(MSGMERGE) $$lang.old.po $(TD).pot -o $$lang.po; then \ |
| rm -f $$lang.old.po; \ |
| $(TD).pot: $(srcfiles) |
| @printf "Generating \`%s' from source files ... " "$(TD).pot"; \ |
| $(XGETTEXT) \ |
| --files-from='$(srcfiles_list)' \ |
| --output=$(TD).pot \ |
| $(prog_language) \ |
| $(encoding) \ |
| --join-existing \ |
| --add-comments=TRANSLATORS: \ |
| $(keywords) \ |
| --copyright-holder="$(COPYRIGHT_HOLDER)" \ |
| --package-name="$(PACKAGE_NAME)" \ |
| --package-version="$(PACKAGE_VERSION)" \ |
| --msgid-bugs-address="$(MSGID_BUGS_ADDRESS)"; \ |
| echo 'done.' |
| |
| $(CATALOGS): $(TD).pot |
| @printf "Updating \`%s' " "$@"; \ |
| po_file="$@"; \ |
| lang="$${po_file%$(CATOBJEXT)}"; \ |
| mv "$$lang.po" "$$lang.old.po"; \ |
| if $(MSGMERGE) -o "$$lang.po" "$$lang.old.po" "$(TD).pot"; then \ |
| rm -f "$$lang.old.po"; \ |
| else \ |
| echo "msgmerge for $$cat failed!"; \ |
| rm -f $$lang.po; \ |
| mv $$lang.old.po $$lang.po; \ |
| fi; \ |
| done |
| echo >&2 "$(MSGMERGE) for \`$@' failed!"; \ |
| rm -f "$$lang.po"; \ |
| mv "$$lang.old.po" "$$lang.po"; \ |
| fi |
| |
| .SUFFIXES: |
| .SUFFIXES: .po .mo |
| |
| .po.mo: |
| $(MSGFMT) --check --statistics --verbose -o $@ $< |
| |
| $(MO_FILES): $(CATALOGS) |
| @printf "Generating message catalog \`%s' ... " "$@";\ |
| mo_file="$@"; \ |
| po_file="$${mo_file%.mo}.po"; \ |
| $(MSGFMT) --check --statistics --verbose -o "$@" "$$po_file" |