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