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:1,1t --keyword=tr:1,2c,2t --keyword=tr:1,1,2c,3t --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 tells whether or not to prepend "GNU " prefix to the package 34# name that gets inserted into the header of the $(DOMAIN).pot file. 35# Possible values are "yes", "no", or empty. If it is empty, try to 36# detect it automatically by scanning the files in $(top_srcdir) for 37# "GNU packagename" string. 38PACKAGE_GNU = no 39 40# This is the email address or URL to which the translators shall report 41# bugs in the untranslated strings: 42# - Strings which are not entire sentences, see the maintainer guidelines 43# in the GNU gettext documentation, section 'Preparing Strings'. 44# - Strings which use unclear terms or require additional context to be 45# understood. 46# - Strings which make invalid assumptions about notation of date, time or 47# money. 48# - Pluralisation problems. 49# - Incorrect English spelling. 50# - Incorrect formatting. 51# It can be your email address, or a mailing list address where translators 52# can write to without being subscribed, or the URL of a web page through 53# which the translators can contact you. 54MSGID_BUGS_ADDRESS = bug-gettext@gnu.org 55 56# These options get passed to msgmerge. 57# Useful options are in particular: 58# --previous to keep previous msgids of translated messages, 59# --quiet to reduce the verbosity. 60MSGMERGE_OPTIONS = --quiet 61 62# These options get passed to msginit. 63# If you want to disable line wrapping when writing PO files, add 64# --no-wrap to MSGMERGE_OPTIONS, XGETTEXT_OPTIONS, and 65# MSGINIT_OPTIONS. 66MSGINIT_OPTIONS = 67 68MSGMERGE = @MSGMERGE@ 69MSGMERGE_UPDATE = @MSGMERGE@ --update 70MSGMERGE_FOR_MSGFMT_OPTION = @MSGMERGE_FOR_MSGFMT_OPTION@ 71MSGINIT = msginit 72MSGCONV = msgconv 73MSGFILTER = msgfilter 74 75# This is computed as $(foreach file, $(POTFILES), $(top_srcdir)/$(file)) 76POTFILES_DEPS = @POTFILES_DEPS@ 77 78# This is computed as $(foreach lang, $(LINGUAS), $(srcdir)/$(lang).po) 79POFILES = @POFILES@ 80# This is computed as $(foreach lang, $(LINGUAS), $(lang).po-update) 81UPDATEPOFILES = @UPDATEPOFILES@ 82# This is computed as $(foreach lang, $(LINGUAS), $(lang).nop) 83DUMMYPOFILES = @DUMMYPOFILES@ 84# This is computed as $(foreach lang, $(LINGUAS), $(srcdir)/$(lang).qm) 85QMFILES = @QMFILES@ 86 87# This is computed as 88# $(foreach lang, user-specified subset of $(LINGUAS), $(lang).qm) 89CATALOGS = @QTCATALOGS@ 90 91SUFFIXES = .po .qm .sed .sin .nop .po-create .po-update 92 93# The .pot file, stamp-po, .po files, and .qm files appear in release tarballs. 94# The GNU Coding Standards say in 95# <https://www.gnu.org/prep/standards/html_node/Makefile-Basics.html>: 96# "GNU distributions usually contain some files which are not source files 97# ... . Since these files normally appear in the source directory, they 98# should always appear in the source directory, not in the build directory. 99# So Makefile rules to update them should put the updated files in the 100# source directory." 101# Therefore we put these files in the source directory, not the build directory. 102 103# During .po -> .qm conversion, take into account the most recent changes to 104# the .pot file. This eliminates the need to update the .po files when the 105# .pot file has changed, which would be troublesome if the .po files are put 106# under version control. 107$(QMFILES): $(srcdir)/$(DOMAIN).pot 108.po.qm: 109 @lang=`echo $* | sed -e 's,.*/,,'`; \ 110 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ 111 echo "$${cdcmd}rm -f $${lang}.qm && $(MSGMERGE) $(MSGMERGE_FOR_MSGFMT_OPTION) -o $${lang}.1po $${lang}.po $(DOMAIN).pot && $(GMSGFMT) -c --qt --statistics --verbose -o $${lang}.qm $${lang}.1po && rm -f $${lang}.1po"; \ 112 cd $(srcdir) && \ 113 rm -f $${lang}.qm && \ 114 $(MSGMERGE) $(MSGMERGE_FOR_MSGFMT_OPTION) -o $${lang}.1po $${lang}.po $(DOMAIN).pot && \ 115 $(GMSGFMT) -c --qt --statistics --verbose -o t-$${lang}.qm $${lang}.1po && \ 116 mv t-$${lang}.qm $${lang}.qm && \ 117 rm -f $${lang}.1po 118 119.sin.sed: 120 sed -e '/^#/d' $< > t-$@ 121 mv t-$@ $@ 122 123 124all-local: all-local-@USE_NLS@ 125 126all-local-yes: $(srcdir)/stamp-po 127all-local-no: 128 129# $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no 130# internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because 131# we don't want to bother translators with empty POT files). We assume that 132# LINGUAS is empty in this case, i.e. $(POFILES) and $(QMFILES) are empty. 133# In this case, $(srcdir)/stamp-po is a nop (i.e. a phony target). 134 135# $(srcdir)/stamp-po is a timestamp denoting the last time at which the CATALOGS 136# have been loosely updated. Its purpose is that when a developer or translator 137# checks out the package from a version control system, and the $(DOMAIN).pot 138# file is not under version control, "make" will update the $(DOMAIN).pot and 139# the $(CATALOGS), but subsequent invocations of "make" will do nothing. This 140# timestamp would not be necessary if updating the $(CATALOGS) would always 141# touch them; however, the rule for $(POFILES) has been designed to not touch 142# files that don't need to be changed. 143$(srcdir)/stamp-po: $(srcdir)/$(DOMAIN).pot 144 test ! -f $(srcdir)/$(DOMAIN).pot || \ 145 test -z "$(QMFILES)" || $(MAKE) $(QMFILES) 146 @test ! -f $(srcdir)/$(DOMAIN).pot || { \ 147 echo "touch $(srcdir)/stamp-po" && \ 148 echo timestamp > $(srcdir)/stamp-poT && \ 149 mv $(srcdir)/stamp-poT $(srcdir)/stamp-po; \ 150 } 151 152# Note: Target 'all' must not depend on target '$(DOMAIN).pot-update', 153# otherwise packages like GCC can not be built if only parts of the source 154# have been downloaded. 155 156# This target rebuilds $(DOMAIN).pot; it is an expensive operation. 157# Note that $(DOMAIN).pot is not touched if it doesn't need to be changed. 158# The determination of whether the package xyz is a GNU one is based on the 159# heuristic whether some file in the top level directory mentions "GNU xyz". 160# If GNU 'find' is available, we avoid grepping through monster files. 161$(DOMAIN).pot-update: $(POTFILES_DEPS) remove-potcdate.sed 162 package_gnu="$(PACKAGE_GNU)"; \ 163 test -n "$$package_gnu" || { \ 164 if { if (LC_ALL=C find --version) 2>/dev/null | grep GNU >/dev/null; then \ 165 LC_ALL=C find -L $(top_srcdir) -maxdepth 1 -type f -size -10000000c -exec grep -i 'GNU $(PACKAGE)' /dev/null '{}' ';' 2>/dev/null; \ 166 else \ 167 LC_ALL=C grep -i 'GNU $(PACKAGE)' $(top_srcdir)/* 2>/dev/null; \ 168 fi; \ 169 } | grep -v 'libtool:' >/dev/null; then \ 170 package_gnu=yes; \ 171 else \ 172 package_gnu=no; \ 173 fi; \ 174 }; \ 175 if test "$$package_gnu" = "yes"; then \ 176 package_prefix='GNU '; \ 177 else \ 178 package_prefix=''; \ 179 fi; \ 180 if test -n '$(MSGID_BUGS_ADDRESS)'; then \ 181 msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \ 182 else \ 183 msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \ 184 fi; \ 185 case `$(XGETTEXT) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \ 186 '' | 0.[0-9] | 0.[0-9].* | 0.1[0-5] | 0.1[0-5].* | 0.16 | 0.16.[0-1]*) \ 187 $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \ 188 --add-comments=TRANSLATORS: \ 189 --copyright-holder='$(COPYRIGHT_HOLDER)' \ 190 --msgid-bugs-address="$$msgid_bugs_address" \ 191 $(XGETTEXT_OPTIONS) @XGETTEXT_EXTRA_OPTIONS@ \ 192 $(POTFILES) \ 193 ;; \ 194 *) \ 195 $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \ 196 --add-comments=TRANSLATORS: \ 197 --copyright-holder='$(COPYRIGHT_HOLDER)' \ 198 --package-name="$${package_prefix}$(PACKAGE)" \ 199 --package-version='$(VERSION)' \ 200 --msgid-bugs-address="$$msgid_bugs_address" \ 201 $(XGETTEXT_OPTIONS) @XGETTEXT_EXTRA_OPTIONS@ \ 202 $(POTFILES) \ 203 ;; \ 204 esac 205 test ! -f $(DOMAIN).po || { \ 206 if test -f $(srcdir)/$(DOMAIN).pot-header; then \ 207 sed -e '1,/^#$$/d' < $(DOMAIN).po > $(DOMAIN).1po && \ 208 cat $(srcdir)/$(DOMAIN).pot-header $(DOMAIN).1po > $(DOMAIN).po && \ 209 rm -f $(DOMAIN).1po \ 210 || exit 1; \ 211 fi; \ 212 if test -f $(srcdir)/$(DOMAIN).pot; then \ 213 sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \ 214 sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \ 215 if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \ 216 rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \ 217 else \ 218 rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \ 219 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \ 220 fi; \ 221 else \ 222 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \ 223 fi; \ 224 } 225 226# This rule has no dependencies: we don't need to update $(DOMAIN).pot at 227# every "make" invocation, only create it when it is missing. 228# Only "make $(DOMAIN).pot-update" or "make dist" will force an update. 229$(srcdir)/$(DOMAIN).pot: 230 $(MAKE) $(DOMAIN).pot-update 231 232# This target rebuilds a PO file if $(DOMAIN).pot has changed. 233# Note that a PO file is not touched if it doesn't need to be changed. 234$(POFILES): $(srcdir)/$(DOMAIN).pot 235 @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \ 236 if test -f "$(srcdir)/$${lang}.po"; then \ 237 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ 238 echo "$${cdcmd}$(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} --previous $${lang}.po $(DOMAIN).pot"; \ 239 cd $(srcdir) \ 240 && { case `$(MSGMERGE_UPDATE) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \ 241 '' | 0.[0-9] | 0.[0-9].* | 0.1[0-5] | 0.1[0-5].*) \ 242 $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) $${lang}.po $(DOMAIN).pot;; \ 243 0.1[6-7] | 0.1[6-7].*) \ 244 $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --previous $${lang}.po $(DOMAIN).pot;; \ 245 *) \ 246 $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} --previous $${lang}.po $(DOMAIN).pot;; \ 247 esac; \ 248 }; \ 249 else \ 250 $(MAKE) $${lang}.po-create; \ 251 fi 252 253 254install-data-local: install-data-local-@USE_NLS@ 255install-data-local-no: all-local 256install-data-local-yes: all-local 257 $(MKDIR_P) $(DESTDIR)$(pkgdatadir)/locale 258 @catalogs='$(CATALOGS)'; \ 259 for cat in $$catalogs; do \ 260 cat=`basename $$cat`; \ 261 if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \ 262 $(INSTALL_DATA) $$realcat $(DESTDIR)$(pkgdatadir)/locale/$(DOMAIN)_$$cat; \ 263 echo "installing $$realcat as $(DESTDIR)$(pkgdatadir)/locale/$(DOMAIN)_$$cat"; \ 264 done 265 266installdirs-local: installdirs-local-@USE_NLS@ 267installdirs-local-no: 268installdirs-local-yes: 269 $(MKDIR_P) $(DESTDIR)$(pkgdatadir)/locale 270 271uninstall-local: uninstall-local-@USE_NLS@ 272uninstall-local-no: 273uninstall-local-yes: 274 catalogs='$(CATALOGS)'; \ 275 for cat in $$catalogs; do \ 276 cat=`basename $$cat`; \ 277 rm -f $(DESTDIR)$(pkgdatadir)/locale/$(DOMAIN)_$$cat; \ 278 done 279 280html ID: 281 282MOSTLYCLEANFILES = 283MOSTLYCLEANFILES += remove-potcdate.sed 284MOSTLYCLEANFILES += stamp-poT 285MOSTLYCLEANFILES += core core.* *.stackdump $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po 286MOSTLYCLEANFILES += *.o 287 288MAINTAINERCLEANFILES = $(DOMAIN).pot stamp-po $(QMFILES) 289 290EXTRA_DIST = remove-potcdate.sin LINGUAS $(POFILES) $(QMFILES) 291 292# Hidden from automake, but really activated. Works around an automake-1.5 bug. 293#distdir: distdir1 294distdir1: 295 $(MAKE) update-po 296 $(MAKE) $(srcdir)/stamp-po 297 @if test -f $(srcdir)/$(DOMAIN).pot; then \ 298 for file in $(DOMAIN).pot stamp-po; do \ 299 if test -f $$file; then d=.; else d=$(srcdir); fi; \ 300 cp -p $$d/$$file $(distdir)/$$file || exit 1; \ 301 done; \ 302 else \ 303 case $(XGETTEXT) in \ 304 :) echo "Warning: Creating a tarball without '$(DOMAIN).pot', because a suitable 'xgettext' program was not found in PATH." 1>&2;; \ 305 *) echo "Warning: Creating a tarball without '$(DOMAIN).pot', because 'xgettext' found no strings to extract. Check the POTFILES and the XGETTEXT_OPTIONS in the Makefile.am file." 1>&2;; \ 306 esac; \ 307 fi 308 309update-po: Makefile 310 $(MAKE) $(DOMAIN).pot-update 311 test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES) 312 $(MAKE) update-gmo 313 314# General rule for creating PO files. 315 316.nop.po-create: 317 @lang=`echo $@ | sed -e 's/\.po-create$$//'`; \ 318 echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \ 319 exit 1 320 321# General rule for updating PO files. 322 323.nop.po-update: 324 @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \ 325 tmpdir=`pwd`; \ 326 echo "$$lang:"; \ 327 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ 328 echo "$${cdcmd}$(MSGMERGE) $(MSGMERGE_OPTIONS) --lang=$$lang --previous $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \ 329 cd $(srcdir); \ 330 if { case `$(MSGMERGE) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \ 331 '' | 0.[0-9] | 0.[0-9].* | 0.1[0-5] | 0.1[0-5].*) \ 332 $(MSGMERGE) $(MSGMERGE_OPTIONS) -o $$tmpdir/$$lang.new.po $$lang.po $(DOMAIN).pot;; \ 333 0.1[6-7] | 0.1[6-7].*) \ 334 $(MSGMERGE) $(MSGMERGE_OPTIONS) --previous -o $$tmpdir/$$lang.new.po $$lang.po $(DOMAIN).pot;; \ 335 *) \ 336 $(MSGMERGE) $(MSGMERGE_OPTIONS) --lang=$$lang --previous -o $$tmpdir/$$lang.new.po $$lang.po $(DOMAIN).pot;; \ 337 esac; \ 338 }; then \ 339 if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \ 340 rm -f $$tmpdir/$$lang.new.po; \ 341 else \ 342 if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \ 343 :; \ 344 else \ 345 echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \ 346 exit 1; \ 347 fi; \ 348 fi; \ 349 else \ 350 echo "msgmerge for $$lang.po failed!" 1>&2; \ 351 rm -f $$tmpdir/$$lang.new.po; \ 352 fi 353 354$(DUMMYPOFILES): 355 356update-gmo: Makefile $(QMFILES) 357 @: 358