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