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