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