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 --keyword=wxGetTranslation:1 --keyword=wxGetTranslation:1,2 \ 17 --flag=wxGetTranslation:1:pass-c-format --flag=wxGetTranslation:2:pass-c-format \ 18 --keyword=wxTRANSLATE --flag=wxTRANSLATE:1:pass-c-format \ 19 --keyword=wxPLURAL:1,2 --flag=wxPLURAL:1:pass-c-format --flag=wxPLURAL:2:pass-c-format \ 20 --keyword=_ --flag=_:1:pass-c-format \ 21 --keyword=N_ --flag=N_:1:pass-c-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 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 53MSGMERGE = msgmerge 54MSGMERGE_UPDATE = @MSGMERGE@ --update 55MSGINIT = msginit 56MSGCONV = msgconv 57MSGFILTER = msgfilter 58 59# This is computed as $(foreach file, $(POTFILES), $(top_srcdir)/$(file)) 60POTFILES_DEPS = @POTFILES_DEPS@ 61 62# This is computed as $(foreach lang, $(LINGUAS), $(srcdir)/$(lang).po) 63POFILES = @POFILES@ 64# This is computed as $(foreach lang, $(LINGUAS), $(srcdir)/$(lang).gmo) 65GMOFILES = @GMOFILES@ 66# This is computed as $(foreach lang, $(LINGUAS), $(lang).po-update) 67UPDATEPOFILES = @UPDATEPOFILES@ 68# This is computed as $(foreach lang, $(LINGUAS), $(lang).nop) 69DUMMYPOFILES = @DUMMYPOFILES@ 70 71# This is computed as 72# $(foreach lang, user-specified subset of $(LINGUAS), $(lang).gmo) 73CATALOGS = @CATALOGS@ 74 75SUFFIXES = .po .gmo .mo .sed .sin .nop .po-create .po-update 76 77.po.mo: 78 @echo "$(MSGFMT) -c -o $@ $<"; \ 79 $(MSGFMT) -c -o t-$@ $< && mv t-$@ $@ 80 81.po.gmo: 82 @lang=`echo $* | sed -e 's,.*/,,'`; \ 83 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ 84 echo "$${cdcmd}rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o $${lang}.gmo $${lang}.po"; \ 85 cd $(srcdir) && rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o t-$${lang}.gmo $${lang}.po && mv t-$${lang}.gmo $${lang}.gmo 86 87.sin.sed: 88 sed -e '/^#/d' $< > t-$@ 89 mv t-$@ $@ 90 91 92all-local: all-local-@USE_NLS@ 93 94all-local-yes: stamp-po 95all-local-no: 96 97# $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no 98# internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because 99# we don't want to bother translators with empty POT files). We assume that 100# LINGUAS is empty in this case, i.e. $(POFILES) and $(GMOFILES) are empty. 101# In this case, stamp-po is a nop (i.e. a phony target). 102 103# stamp-po is a timestamp denoting the last time at which the CATALOGS have 104# been loosely updated. Its purpose is that when a developer or translator 105# checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS, 106# "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent 107# invocations of "make" will do nothing. This timestamp would not be necessary 108# if updating the $(CATALOGS) would always touch them; however, the rule for 109# $(POFILES) has been designed to not touch files that don't need to be 110# changed. 111stamp-po: $(srcdir)/$(DOMAIN).pot 112 test ! -f $(srcdir)/$(DOMAIN).pot || \ 113 test -z "$(GMOFILES)" || $(MAKE) $(GMOFILES) 114 @test ! -f $(srcdir)/$(DOMAIN).pot || { \ 115 echo "touch stamp-po" && \ 116 echo timestamp > stamp-poT && \ 117 mv stamp-poT stamp-po; \ 118 } 119 120# Note: Target 'all' must not depend on target '$(DOMAIN).pot-update', 121# otherwise packages like GCC can not be built if only parts of the source 122# have been downloaded. 123 124# This target rebuilds $(DOMAIN).pot; it is an expensive operation. 125# Note that $(DOMAIN).pot is not touched if it doesn't need to be changed. 126$(DOMAIN).pot-update: $(POTFILES_DEPS) remove-potcdate.sed 127 if test -n '$(MSGID_BUGS_ADDRESS)'; then \ 128 msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \ 129 else \ 130 msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \ 131 fi; \ 132 $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \ 133 --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \ 134 --copyright-holder='$(COPYRIGHT_HOLDER)' \ 135 --msgid-bugs-address="$$msgid_bugs_address" \ 136 $(POTFILES) 137 test ! -f $(DOMAIN).po || { \ 138 if test -f $(srcdir)/$(DOMAIN).pot; then \ 139 sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \ 140 sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \ 141 if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \ 142 rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \ 143 else \ 144 rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \ 145 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \ 146 fi; \ 147 else \ 148 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \ 149 fi; \ 150 } 151 152# This rule has no dependencies: we don't need to update $(DOMAIN).pot at 153# every "make" invocation, only create it when it is missing. 154# Only "make $(DOMAIN).pot-update" or "make dist" will force an update. 155$(srcdir)/$(DOMAIN).pot: 156 $(MAKE) $(DOMAIN).pot-update 157 158# This target rebuilds a PO file if $(DOMAIN).pot has changed. 159# Note that a PO file is not touched if it doesn't need to be changed. 160$(POFILES): $(srcdir)/$(DOMAIN).pot 161 @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \ 162 if test -f "$(srcdir)/$${lang}.po"; then \ 163 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ 164 echo "$${cdcmd}$(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot"; \ 165 cd $(srcdir) && $(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot; \ 166 else \ 167 $(MAKE) $${lang}.po-create; \ 168 fi 169 170 171install-data-local: install-data-local-@USE_NLS@ 172install-data-local-no: all-local 173install-data-local-yes: all-local 174 $(mkdir_p) $(DESTDIR)$(datadir) 175 @catalogs='$(CATALOGS)'; \ 176 for cat in $$catalogs; do \ 177 cat=`basename $$cat`; \ 178 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \ 179 dir=$(localedir)/$$lang/LC_MESSAGES; \ 180 $(mkdir_p) $(DESTDIR)$$dir; \ 181 if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \ 182 $(INSTALL_DATA) $$realcat $(DESTDIR)$$dir/$(DOMAIN).mo; \ 183 echo "installing $$realcat as $(DESTDIR)$$dir/$(DOMAIN).mo"; \ 184 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \ 185 if test -n "$$lc"; then \ 186 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \ 187 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \ 188 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ 189 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ 190 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \ 191 for file in *; do \ 192 if test -f $$file; then \ 193 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \ 194 fi; \ 195 done); \ 196 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ 197 else \ 198 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \ 199 :; \ 200 else \ 201 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \ 202 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ 203 fi; \ 204 fi; \ 205 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \ 206 ln -s ../LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \ 207 ln $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \ 208 cp -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \ 209 echo "installing $$realcat link as $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo"; \ 210 fi; \ 211 done; \ 212 done 213 214installdirs-local: installdirs-local-@USE_NLS@ 215installdirs-local-no: 216installdirs-local-yes: 217 $(mkdir_p) $(DESTDIR)$(datadir) 218 @catalogs='$(CATALOGS)'; \ 219 for cat in $$catalogs; do \ 220 cat=`basename $$cat`; \ 221 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \ 222 dir=$(localedir)/$$lang/LC_MESSAGES; \ 223 $(mkdir_p) $(DESTDIR)$$dir; \ 224 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \ 225 if test -n "$$lc"; then \ 226 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \ 227 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \ 228 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ 229 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ 230 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \ 231 for file in *; do \ 232 if test -f $$file; then \ 233 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \ 234 fi; \ 235 done); \ 236 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ 237 else \ 238 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \ 239 :; \ 240 else \ 241 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \ 242 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ 243 fi; \ 244 fi; \ 245 fi; \ 246 done; \ 247 done 248 249uninstall-local: uninstall-local-@USE_NLS@ 250uninstall-local-no: 251uninstall-local-yes: 252 catalogs='$(CATALOGS)'; \ 253 for cat in $$catalogs; do \ 254 cat=`basename $$cat`; \ 255 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \ 256 for lc in LC_MESSAGES $(EXTRA_LOCALE_CATEGORIES); do \ 257 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \ 258 done; \ 259 done 260 261html ID: 262 263MOSTLYCLEANFILES = 264MOSTLYCLEANFILES += remove-potcdate.sed 265MOSTLYCLEANFILES += stamp-poT 266MOSTLYCLEANFILES += core core.* *.stackdump $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po 267MOSTLYCLEANFILES += *.o 268 269DISTCLEANFILES = *.mo 270 271MAINTAINERCLEANFILES = stamp-po $(GMOFILES) 272 273EXTRA_DIST = remove-potcdate.sin LINGUAS $(POFILES) $(GMOFILES) 274 275# Hidden from automake, but really activated. Works around an automake-1.5 bug. 276#distdir: distdir1 277distdir1: 278 $(MAKE) update-po 279 if test -f $(srcdir)/$(DOMAIN).pot; then \ 280 for file in $(DOMAIN).pot stamp-po; do \ 281 if test -f $$file; then d=.; else d=$(srcdir); fi; \ 282 cp -p $$d/$$file $(distdir)/$$file || exit 1; \ 283 done; \ 284 fi 285 286update-po: Makefile 287 $(MAKE) $(DOMAIN).pot-update 288 test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES) 289 $(MAKE) update-gmo 290 291# General rule for creating PO files. 292 293.nop.po-create: 294 @lang=`echo $@ | sed -e 's/\.po-create$$//'`; \ 295 echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \ 296 exit 1 297 298# General rule for updating PO files. 299 300.nop.po-update: 301 @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \ 302 tmpdir=`pwd`; \ 303 echo "$$lang:"; \ 304 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ 305 echo "$${cdcmd}$(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \ 306 cd $(srcdir); \ 307 if $(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$tmpdir/$$lang.new.po; then \ 308 if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \ 309 rm -f $$tmpdir/$$lang.new.po; \ 310 else \ 311 if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \ 312 :; \ 313 else \ 314 echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \ 315 exit 1; \ 316 fi; \ 317 fi; \ 318 else \ 319 echo "msgmerge for $$lang.po failed!" 1>&2; \ 320 rm -f $$tmpdir/$$lang.new.po; \ 321 fi 322 323$(DUMMYPOFILES): 324 325update-gmo: Makefile $(GMOFILES) 326 @: 327