1# Example for use of GNU gettext. 2# Copyright (C) 2003-2006 Free Software Foundation, Inc. 3# This file is in the public domain. 4# 5# Makefile configuration - processed by automake. 6 7# List of files which contain translatable strings. 8POTFILES = \ 9 hello.cc 10 11# Usually the message domain is the same as the package name. 12DOMAIN = $(PACKAGE) 13 14# These options get passed to xgettext. 15XGETTEXT_OPTIONS = \ 16 --qt \ 17 --keyword=tr --flag=tr:1:pass-c-format --flag=tr:1:pass-qt-format \ 18 --keyword=translate:2 --flag=translate:2:pass-c-format --flag=translate:2:pass-qt-format \ 19 --keyword=QT_TR_NOOP --flag=QT_TR_NOOP:1:pass-c-format --flag=QT_TR_NOOP:1:pass-qt-format \ 20 --keyword=QT_TRANSLATE_NOOP:2 --flag=QT_TRANSLATE_NOOP:2:pass-c-format --flag=QT_TRANSLATE_NOOP:2:pass-qt-format \ 21 --keyword=_ --flag=_:1:pass-c-format --flag=_:1:pass-qt-format \ 22 --keyword=N_ --flag=N_:1:pass-c-format --flag=N_:1:pass-qt-format 23 24# This is the copyright holder that gets inserted into the header of the 25# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding 26# package. (Note that the msgstr strings, extracted from the package's 27# sources, belong to the copyright holder of the package.) Translators are 28# expected to transfer the copyright for their translations to this person 29# or entity, or to disclaim their copyright. The empty string stands for 30# the public domain; in this case the translators are expected to disclaim 31# their copyright. 32COPYRIGHT_HOLDER = Yoyodyne, Inc. 33 34# This is the email address or URL to which the translators shall report 35# bugs in the untranslated strings: 36# - Strings which are not entire sentences, see the maintainer guidelines 37# in the GNU gettext documentation, section 'Preparing Strings'. 38# - Strings which use unclear terms or require additional context to be 39# understood. 40# - Strings which make invalid assumptions about notation of date, time or 41# money. 42# - Pluralisation problems. 43# - Incorrect English spelling. 44# - Incorrect formatting. 45# It can be your email address, or a mailing list address where translators 46# can write to without being subscribed, or the URL of a web page through 47# which the translators can contact you. 48MSGID_BUGS_ADDRESS = bug-gnu-gettext@gnu.org 49 50MSGMERGE = msgmerge 51MSGMERGE_UPDATE = @MSGMERGE@ --update 52MSGINIT = msginit 53MSGCONV = msgconv 54MSGFILTER = msgfilter 55 56# This is computed as $(foreach file, $(POTFILES), $(top_srcdir)/$(file)) 57POTFILES_DEPS = @POTFILES_DEPS@ 58 59# This is computed as $(foreach lang, $(LINGUAS), $(srcdir)/$(lang).po) 60POFILES = @POFILES@ 61# This is computed as $(foreach lang, $(LINGUAS), $(lang).po-update) 62UPDATEPOFILES = @UPDATEPOFILES@ 63# This is computed as $(foreach lang, $(LINGUAS), $(lang).nop) 64DUMMYPOFILES = @DUMMYPOFILES@ 65# This is computed as $(foreach lang, $(LINGUAS), $(srcdir)/$(lang).qm) 66QMFILES = @QMFILES@ 67 68# This is computed as 69# $(foreach lang, user-specified subset of $(LINGUAS), $(lang).qm) 70CATALOGS = @QTCATALOGS@ 71 72SUFFIXES = .po .qm .sed .sin .nop .po-create .po-update 73 74.po.qm: 75 @lang=`echo $* | sed -e 's,.*/,,'`; \ 76 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ 77 echo "$${cdcmd}rm -f $${lang}.qm && $(GMSGFMT) -c --qt --statistics -o $${lang}.qm $${lang}.po"; \ 78 cd $(srcdir) && rm -f $${lang}.qm && $(GMSGFMT) -c --qt --statistics -o t-$${lang}.qm $${lang}.po && mv t-$${lang}.qm $${lang}.qm 79 80.sin.sed: 81 sed -e '/^#/d' $< > t-$@ 82 mv t-$@ $@ 83 84 85all-local: all-local-@USE_NLS@ 86 87all-local-yes: stamp-po 88all-local-no: 89 90# $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no 91# internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because 92# we don't want to bother translators with empty POT files). We assume that 93# LINGUAS is empty in this case, i.e. $(POFILES) and $(QMFILES) are empty. 94# In this case, stamp-po is a nop (i.e. a phony target). 95 96# stamp-po is a timestamp denoting the last time at which the CATALOGS have 97# been loosely updated. Its purpose is that when a developer or translator 98# checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS, 99# "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent 100# invocations of "make" will do nothing. This timestamp would not be necessary 101# if updating the $(CATALOGS) would always touch them; however, the rule for 102# $(POFILES) has been designed to not touch files that don't need to be 103# changed. 104stamp-po: $(srcdir)/$(DOMAIN).pot 105 test ! -f $(srcdir)/$(DOMAIN).pot || \ 106 test -z "$(QMFILES)" || $(MAKE) $(QMFILES) 107 @test ! -f $(srcdir)/$(DOMAIN).pot || { \ 108 echo "touch stamp-po" && \ 109 echo timestamp > stamp-poT && \ 110 mv stamp-poT stamp-po; \ 111 } 112 113# Note: Target 'all' must not depend on target '$(DOMAIN).pot-update', 114# otherwise packages like GCC can not be built if only parts of the source 115# have been downloaded. 116 117# This target rebuilds $(DOMAIN).pot; it is an expensive operation. 118# Note that $(DOMAIN).pot is not touched if it doesn't need to be changed. 119$(DOMAIN).pot-update: $(POTFILES_DEPS) remove-potcdate.sed 120 if test -n '$(MSGID_BUGS_ADDRESS)'; then \ 121 msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \ 122 else \ 123 msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \ 124 fi; \ 125 $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \ 126 --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \ 127 --copyright-holder='$(COPYRIGHT_HOLDER)' \ 128 --msgid-bugs-address="$$msgid_bugs_address" \ 129 $(POTFILES) 130 test ! -f $(DOMAIN).po || { \ 131 if test -f $(srcdir)/$(DOMAIN).pot; then \ 132 sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \ 133 sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \ 134 if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \ 135 rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \ 136 else \ 137 rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \ 138 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \ 139 fi; \ 140 else \ 141 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \ 142 fi; \ 143 } 144 145# This rule has no dependencies: we don't need to update $(DOMAIN).pot at 146# every "make" invocation, only create it when it is missing. 147# Only "make $(DOMAIN).pot-update" or "make dist" will force an update. 148$(srcdir)/$(DOMAIN).pot: 149 $(MAKE) $(DOMAIN).pot-update 150 151# This target rebuilds a PO file if $(DOMAIN).pot has changed. 152# Note that a PO file is not touched if it doesn't need to be changed. 153$(POFILES): $(srcdir)/$(DOMAIN).pot 154 @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \ 155 if test -f "$(srcdir)/$${lang}.po"; then \ 156 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ 157 echo "$${cdcmd}$(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot"; \ 158 cd $(srcdir) && $(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot; \ 159 else \ 160 $(MAKE) $${lang}.po-create; \ 161 fi 162 163 164install-data-local: install-data-local-@USE_NLS@ 165install-data-local-no: all-local 166install-data-local-yes: all-local 167 $(mkdir_p) $(DESTDIR)$(pkgdatadir)/locale 168 @catalogs='$(CATALOGS)'; \ 169 for cat in $$catalogs; do \ 170 cat=`basename $$cat`; \ 171 if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \ 172 $(INSTALL_DATA) $$realcat $(DESTDIR)$(pkgdatadir)/locale/$(DOMAIN)_$$cat; \ 173 echo "installing $$realcat as $(DESTDIR)$(pkgdatadir)/locale/$(DOMAIN)_$$cat"; \ 174 done 175 176installdirs-local: installdirs-local-@USE_NLS@ 177installdirs-local-no: 178installdirs-local-yes: 179 $(mkdir_p) $(DESTDIR)$(pkgdatadir)/locale 180 181uninstall-local: uninstall-local-@USE_NLS@ 182uninstall-local-no: 183uninstall-local-yes: 184 catalogs='$(CATALOGS)'; \ 185 for cat in $$catalogs; do \ 186 cat=`basename $$cat`; \ 187 rm -f $(DESTDIR)$(pkgdatadir)/locale/$(DOMAIN)_$$cat; \ 188 done 189 190html ID: 191 192MOSTLYCLEANFILES = 193MOSTLYCLEANFILES += remove-potcdate.sed 194MOSTLYCLEANFILES += stamp-poT 195MOSTLYCLEANFILES += core core.* *.stackdump $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po 196MOSTLYCLEANFILES += *.o 197 198MAINTAINERCLEANFILES = stamp-po $(QMFILES) 199 200EXTRA_DIST = remove-potcdate.sin LINGUAS $(POFILES) $(QMFILES) 201 202# Hidden from automake, but really activated. Works around an automake-1.5 bug. 203#distdir: distdir1 204distdir1: 205 $(MAKE) update-po 206 if test -f $(srcdir)/$(DOMAIN).pot; then \ 207 for file in $(DOMAIN).pot stamp-po; do \ 208 if test -f $$file; then d=.; else d=$(srcdir); fi; \ 209 cp -p $$d/$$file $(distdir)/$$file || exit 1; \ 210 done; \ 211 fi 212 213update-po: Makefile 214 $(MAKE) $(DOMAIN).pot-update 215 test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES) 216 $(MAKE) update-gmo 217 218# General rule for creating PO files. 219 220.nop.po-create: 221 @lang=`echo $@ | sed -e 's/\.po-create$$//'`; \ 222 echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \ 223 exit 1 224 225# General rule for updating PO files. 226 227.nop.po-update: 228 @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \ 229 tmpdir=`pwd`; \ 230 echo "$$lang:"; \ 231 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ 232 echo "$${cdcmd}$(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \ 233 cd $(srcdir); \ 234 if $(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$tmpdir/$$lang.new.po; then \ 235 if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \ 236 rm -f $$tmpdir/$$lang.new.po; \ 237 else \ 238 if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \ 239 :; \ 240 else \ 241 echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \ 242 exit 1; \ 243 fi; \ 244 fi; \ 245 else \ 246 echo "msgmerge for $$lang.po failed!" 1>&2; \ 247 rm -f $$tmpdir/$$lang.new.po; \ 248 fi 249 250$(DUMMYPOFILES): 251 252update-gmo: Makefile $(QMFILES) 253 @: 254