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.java 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 is the email address or URL to which the translators shall report 27# bugs in the untranslated strings: 28# - Strings which are not entire sentences, see the maintainer guidelines 29# in the GNU gettext documentation, section 'Preparing Strings'. 30# - Strings which use unclear terms or require additional context to be 31# understood. 32# - Strings which make invalid assumptions about notation of date, time or 33# money. 34# - Pluralisation problems. 35# - Incorrect English spelling. 36# - Incorrect formatting. 37# It can be your email address, or a mailing list address where translators 38# can write to without being subscribed, or the URL of a web page through 39# which the translators can contact you. 40MSGID_BUGS_ADDRESS = bug-gnu-gettext@gnu.org 41 42MSGMERGE = msgmerge 43MSGMERGE_UPDATE = @MSGMERGE@ --update 44MSGCAT = msgcat 45MSGINIT = msginit 46MSGCONV = msgconv 47MSGFILTER = msgfilter 48 49# This is computed as $(foreach file, $(POTFILES), $(top_srcdir)/$(file)) 50POTFILES_DEPS = @POTFILES_DEPS@ 51 52# This is computed as $(foreach lang, $(LINGUAS), $(srcdir)/$(lang).po) 53POFILES = @POFILES@ 54# This is computed as $(foreach lang, $(LINGUAS), $(lang).po-update) 55UPDATEPOFILES = @UPDATEPOFILES@ 56# This is computed as $(foreach lang, $(LINGUAS), $(lang).nop) 57DUMMYPOFILES = @DUMMYPOFILES@ 58# This is computed as $(foreach lang, $(LINGUAS), $(top_srcdir)/$(DOMAIN)_$(lang).properties) 59PROPERTIESFILES = @PROPERTIESFILES@ 60# This is computed as $(foreach lang, $(LINGUAS), $(top_srcdir)/$(DOMAIN)_$(lang).class) 61CLASSFILES = @CLASSFILES@ 62 63# This is computed as 64# $(foreach lang, user-specified subset of $(LINGUAS), $(DOMAIN)_$(lang).properties) 65CATALOGS = @JAVACATALOGS@ 66 67SUFFIXES = .po .sed .sin .nop .po-create .po-update 68 69.sin.sed: 70 sed -e '/^#/d' $< > t-$@ 71 mv t-$@ $@ 72 73 74all-local: stamp-po 75 76# $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no 77# internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because 78# we don't want to bother translators with empty POT files). We assume that 79# LINGUAS is empty in this case, i.e. $(POFILES) and $(PROPERTIESFILES) are 80# empty. In this case, stamp-po is a nop (i.e. a phony target). 81 82# stamp-po is a timestamp denoting the last time at which the CATALOGS have 83# been loosely updated. Its purpose is that when a developer or translator 84# checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS, 85# "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent 86# invocations of "make" will do nothing. This timestamp would not be necessary 87# if updating the $(CATALOGS) would always touch them; however, the rule for 88# $(POFILES) has been designed to not touch files that don't need to be 89# changed. 90stamp-po: $(srcdir)/$(DOMAIN).pot 91 test ! -f $(srcdir)/$(DOMAIN).pot || \ 92 $(MAKE) update-properties 93 @test ! -f $(srcdir)/$(DOMAIN).pot || { \ 94 echo "touch stamp-po" && \ 95 echo timestamp > stamp-poT && \ 96 mv stamp-poT stamp-po; \ 97 } 98 99# Note: Target 'all' must not depend on target '$(DOMAIN).pot-update', 100# otherwise packages like GCC can not be built if only parts of the source 101# have been downloaded. 102 103# This target rebuilds $(DOMAIN).pot; it is an expensive operation. 104# Note that $(DOMAIN).pot is not touched if it doesn't need to be changed. 105$(DOMAIN).pot-update: $(POTFILES_DEPS) remove-potcdate.sed 106 if LC_ALL=C grep 'GNU $(PACKAGE)' $(top_srcdir)/* 2>/dev/null | grep -v 'libtool:' >/dev/null; then \ 107 package_gnu='GNU '; \ 108 else \ 109 package_gnu=''; \ 110 fi; \ 111 if test -n '$(MSGID_BUGS_ADDRESS)'; then \ 112 msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \ 113 else \ 114 msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \ 115 fi; \ 116 case `$(XGETTEXT) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \ 117 '' | 0.[0-9] | 0.[0-9].* | 0.1[0-5] | 0.1[0-5].* | 0.16 | 0.16.[0-1]*) \ 118 $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \ 119 --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) @XGETTEXT_EXTRA_OPTIONS@ \ 120 --copyright-holder='$(COPYRIGHT_HOLDER)' \ 121 --msgid-bugs-address="$$msgid_bugs_address" \ 122 $(POTFILES) \ 123 ;; \ 124 *) \ 125 $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \ 126 --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) @XGETTEXT_EXTRA_OPTIONS@ \ 127 --copyright-holder='$(COPYRIGHT_HOLDER)' \ 128 --package-name="$${package_gnu}$(PACKAGE)" \ 129 --package-version='$(VERSION)' \ 130 --msgid-bugs-address="$$msgid_bugs_address" \ 131 $(POTFILES) \ 132 ;; \ 133 esac 134 test ! -f $(DOMAIN).po || { \ 135 if test -f $(srcdir)/$(DOMAIN).pot; then \ 136 sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \ 137 sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \ 138 if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \ 139 rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \ 140 else \ 141 rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \ 142 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \ 143 fi; \ 144 else \ 145 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \ 146 fi; \ 147 } 148 149# This rule has no dependencies: we don't need to update $(DOMAIN).pot at 150# every "make" invocation, only create it when it is missing. 151# Only "make $(DOMAIN).pot-update" or "make dist" will force an update. 152$(srcdir)/$(DOMAIN).pot: 153 $(MAKE) $(DOMAIN).pot-update 154 155# This target rebuilds a PO file if $(DOMAIN).pot has changed. 156# Note that a PO file is not touched if it doesn't need to be changed. 157$(POFILES): $(srcdir)/$(DOMAIN).pot 158 @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \ 159 if test -f "$(srcdir)/$${lang}.po"; then \ 160 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ 161 echo "$${cdcmd}$(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot"; \ 162 cd $(srcdir) && $(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot; \ 163 else \ 164 $(MAKE) $${lang}.po-create; \ 165 fi 166 167 168html ID: 169 170MOSTLYCLEANFILES = 171MOSTLYCLEANFILES += remove-potcdate.sed 172MOSTLYCLEANFILES += stamp-poT 173MOSTLYCLEANFILES += core core.* *.stackdump $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po 174 175MAINTAINERCLEANFILES = stamp-po 176 177EXTRA_DIST = remove-potcdate.sin LINGUAS $(POFILES) 178 179# Hidden from automake, but really activated. Works around an automake-1.5 bug. 180#distdir: distdir1 181distdir1: 182 $(MAKE) update-po 183 if test -f $(srcdir)/$(DOMAIN).pot; then \ 184 for file in $(DOMAIN).pot stamp-po; do \ 185 if test -f $$file; then d=.; else d=$(srcdir); fi; \ 186 cp -p $$d/$$file $(distdir)/$$file || exit 1; \ 187 done; \ 188 fi 189 190update-po: Makefile 191 $(MAKE) $(DOMAIN).pot-update 192 test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES) 193 $(MAKE) update-properties 194 195# General rule for creating PO files. 196 197.nop.po-create: 198 @lang=`echo $@ | sed -e 's/\.po-create$$//'`; \ 199 echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \ 200 exit 1 201 202# General rule for updating PO files. 203 204.nop.po-update: 205 @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \ 206 tmpdir=`pwd`; \ 207 echo "$$lang:"; \ 208 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ 209 echo "$${cdcmd}$(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \ 210 cd $(srcdir); \ 211 if $(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$tmpdir/$$lang.new.po; then \ 212 if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \ 213 rm -f $$tmpdir/$$lang.new.po; \ 214 else \ 215 if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \ 216 :; \ 217 else \ 218 echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \ 219 exit 1; \ 220 fi; \ 221 fi; \ 222 else \ 223 echo "msgmerge for $$lang.po failed!" 1>&2; \ 224 rm -f $$tmpdir/$$lang.new.po; \ 225 fi 226 227$(DUMMYPOFILES): 228 229update-properties: Makefile $(DOMAIN).pot $(POFILES) 230 @echo "$(MSGINIT) -i $(DOMAIN).pot --no-translator -l en --properties-output -o $(top_srcdir)/$(DOMAIN).properties"; \ 231 $(MSGINIT) -i $(DOMAIN).pot --no-translator -l en --properties-output -o $(top_srcdir)/$(DOMAIN).properties || { rm -f $(top_srcdir)/$(DOMAIN).properties; exit 1; } 232 @for f in $(POFILES); do \ 233 lang=`echo $$f | sed -e 's,.*/,,' -e 's,\.po$$,,'`; \ 234 echo "$(GMSGFMT) -c --statistics -o /dev/null $(srcdir)/$${lang}.po"; \ 235 $(GMSGFMT) -c --statistics -o /dev/null $(srcdir)/$${lang}.po || exit 1; \ 236 echo "$(MSGCAT) --properties-output -o $(top_srcdir)/$(DOMAIN)_$$lang.properties $(srcdir)/$${lang}.po"; \ 237 $(MSGCAT) --properties-output -o $(top_srcdir)/$(DOMAIN)_$$lang.properties.tmp $(srcdir)/$${lang}.po || exit 1; \ 238 mv $(top_srcdir)/$(DOMAIN)_$$lang.properties.tmp $(top_srcdir)/$(DOMAIN)_$$lang.properties || exit 1; \ 239 done 240 241# Alternatively, we could create classes instead of properties files. 242update-classes: Makefile $(DOMAIN).pot $(POFILES) 243 @echo "$(MSGINIT) -i $(DOMAIN).pot --no-translator -l en --properties-output -o $(top_srcdir)/$(DOMAIN).properties"; \ 244 $(MSGINIT) -i $(DOMAIN).pot --no-translator -l en --properties-output -o $(top_srcdir)/$(DOMAIN).properties || { rm -f $(top_srcdir)/$(DOMAIN).properties; exit 1; } 245 @for f in $(POFILES); do \ 246 lang=`echo $$f | sed -e 's,.*/,,' -e 's,\.po$$,,'`; \ 247 echo "$(GMSGFMT) -c --statistics -j -d $(top_srcdir) -r $(DOMAIN) -l $${lang} $(srcdir)/$${lang}.po"; \ 248 $(GMSGFMT) -c --statistics -j -d $(top_srcdir) -r $(DOMAIN) -l $${lang} $(srcdir)/$${lang}.po || exit 1; \ 249 done 250 251echo-catalogs: 252 @echo $(CATALOGS) 253