1 # Example for use of GNU gettext.
2 # This file is in the public domain.
4 # Makefile configuration - processed by automake.
6 # List of files which contain translatable strings.
10 # Usually the message domain is the same as the package name.
13 # These options get passed to xgettext.
14 XGETTEXT_OPTIONS = --keyword=_ --flag=_:1:pass-tcl-format
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
24 COPYRIGHT_HOLDER = Yoyodyne, Inc.
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
32 # - Strings which make invalid assumptions about notation of date, time or
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.
40 MSGID_BUGS_ADDRESS = bug-gnu-gettext@gnu.org
42 # These options get passed to msgmerge.
43 # Useful options are in particular:
44 # --previous to keep previous msgids of translated messages,
45 # --quiet to reduce the verbosity.
46 MSGMERGE_OPTIONS = --quiet
49 MSGMERGE_UPDATE = @MSGMERGE@ --update
54 # This is computed as $(foreach file, $(POTFILES), $(top_srcdir)/$(file))
55 POTFILES_DEPS = @POTFILES_DEPS@
57 # This is computed as $(foreach lang, $(LINGUAS), $(srcdir)/$(lang).po)
59 # This is computed as $(foreach lang, $(LINGUAS), $(lang).po-update)
60 UPDATEPOFILES = @UPDATEPOFILES@
61 # This is computed as $(foreach lang, $(LINGUAS), $(lang).nop)
62 DUMMYPOFILES = @DUMMYPOFILES@
63 # This is computed as $(foreach lang, $(LINGUAS), $(srcdir)/$(frob $(lang)).msg)
67 # $(foreach lang, user-specified subset of $(LINGUAS), $(frob $(lang)).msg)
68 CATALOGS = @TCLCATALOGS@
70 SUFFIXES = .sed .sin .nop .po-create .po-update
73 sed -e '/^#/d' $< > t-$@
77 all-local: all-local-@USE_NLS@
79 all-local-yes: stamp-po
82 # $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no
83 # internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because
84 # we don't want to bother translators with empty POT files). We assume that
85 # LINGUAS is empty in this case, i.e. $(POFILES) and $(MSGFILES) are empty.
86 # In this case, stamp-po is a nop (i.e. a phony target).
88 # stamp-po is a timestamp denoting the last time at which the CATALOGS have
89 # been loosely updated. Its purpose is that when a developer or translator
90 # checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS,
91 # "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent
92 # invocations of "make" will do nothing. This timestamp would not be necessary
93 # if updating the $(CATALOGS) would always touch them; however, the rule for
94 # $(POFILES) has been designed to not touch files that don't need to be
96 stamp-po: $(srcdir)/$(DOMAIN).pot
97 test ! -f $(srcdir)/$(DOMAIN).pot || \
98 test -z "$(MSGFILES)" || $(MAKE) $(MSGFILES)
99 @test ! -f $(srcdir)/$(DOMAIN).pot || { \
100 echo "touch stamp-po" && \
101 echo timestamp > stamp-poT && \
102 mv stamp-poT stamp-po; \
105 # Note: Target 'all' must not depend on target '$(DOMAIN).pot-update',
106 # otherwise packages like GCC can not be built if only parts of the source
107 # have been downloaded.
109 # This target rebuilds $(DOMAIN).pot; it is an expensive operation.
110 # Note that $(DOMAIN).pot is not touched if it doesn't need to be changed.
111 $(DOMAIN).pot-update: $(POTFILES_DEPS) remove-potcdate.sed
112 if LC_ALL=C grep 'GNU $(PACKAGE)' $(top_srcdir)/* 2>/dev/null | grep -v 'libtool:' >/dev/null; then \
113 package_gnu='GNU '; \
117 if test -n '$(MSGID_BUGS_ADDRESS)'; then \
118 msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \
120 msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \
122 case `$(XGETTEXT) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \
123 '' | 0.[0-9] | 0.[0-9].* | 0.1[0-5] | 0.1[0-5].* | 0.16 | 0.16.[0-1]*) \
124 $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
125 --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) @XGETTEXT_EXTRA_OPTIONS@ \
126 --copyright-holder='$(COPYRIGHT_HOLDER)' \
127 --msgid-bugs-address="$$msgid_bugs_address" \
131 $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
132 --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) @XGETTEXT_EXTRA_OPTIONS@ \
133 --copyright-holder='$(COPYRIGHT_HOLDER)' \
134 --package-name="$${package_gnu}$(PACKAGE)" \
135 --package-version='$(VERSION)' \
136 --msgid-bugs-address="$$msgid_bugs_address" \
140 test ! -f $(DOMAIN).po || { \
141 if test -f $(srcdir)/$(DOMAIN).pot; then \
142 sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \
143 sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \
144 if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \
145 rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \
147 rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \
148 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
151 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
155 # This rule has no dependencies: we don't need to update $(DOMAIN).pot at
156 # every "make" invocation, only create it when it is missing.
157 # Only "make $(DOMAIN).pot-update" or "make dist" will force an update.
158 $(srcdir)/$(DOMAIN).pot:
159 $(MAKE) $(DOMAIN).pot-update
161 # This target rebuilds a PO file if $(DOMAIN).pot has changed.
162 # Note that a PO file is not touched if it doesn't need to be changed.
163 $(POFILES): $(srcdir)/$(DOMAIN).pot
164 @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
165 if test -f "$(srcdir)/$${lang}.po"; then \
166 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
167 echo "$${cdcmd}$(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} $${lang}.po $(DOMAIN).pot"; \
169 && { case `$(MSGMERGE_UPDATE) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \
170 '' | 0.[0-9] | 0.[0-9].* | 0.1[0-7] | 0.1[0-7].*) \
171 $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) $${lang}.po $(DOMAIN).pot;; \
173 $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} $${lang}.po $(DOMAIN).pot;; \
177 $(MAKE) $${lang}.po-create; \
181 install-data-local: install-data-local-@USE_NLS@
182 install-data-local-no: all-local
183 install-data-local-yes: all-local
184 $(MKDIR_P) $(DESTDIR)$(pkgdatadir)/msgs
185 @catalogs='$(CATALOGS)'; \
186 for cat in $$catalogs; do \
187 cat=`basename $$cat`; \
188 if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \
189 $(INSTALL_DATA) $$realcat $(DESTDIR)$(pkgdatadir)/msgs/$$cat; \
190 echo "installing $$realcat as $(DESTDIR)$(pkgdatadir)/msgs/$$cat"; \
193 installdirs-local: installdirs-local-@USE_NLS@
194 installdirs-local-no:
195 installdirs-local-yes:
196 $(MKDIR_P) $(DESTDIR)$(pkgdatadir)/msgs
198 uninstall-local: uninstall-local-@USE_NLS@
201 catalogs='$(CATALOGS)'; \
202 for cat in $$catalogs; do \
203 cat=`basename $$cat`; \
204 rm -f $(DESTDIR)$(pkgdatadir)/msgs/$$cat; \
210 MOSTLYCLEANFILES += remove-potcdate.sed
211 MOSTLYCLEANFILES += stamp-poT
212 MOSTLYCLEANFILES += core core.* *.stackdump $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po
213 MOSTLYCLEANFILES += *.o
215 MAINTAINERCLEANFILES = stamp-po $(MSGFILES)
217 EXTRA_DIST = remove-potcdate.sin LINGUAS $(POFILES) $(MSGFILES)
219 # Hidden from automake, but really activated. Works around an automake-1.5 bug.
223 if test -f $(srcdir)/$(DOMAIN).pot; then \
224 for file in $(DOMAIN).pot stamp-po; do \
225 if test -f $$file; then d=.; else d=$(srcdir); fi; \
226 cp -p $$d/$$file $(distdir)/$$file || exit 1; \
231 $(MAKE) $(DOMAIN).pot-update
232 test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES)
235 # General rule for creating PO files.
238 @lang=`echo $@ | sed -e 's/\.po-create$$//'`; \
239 echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \
242 # General rule for updating PO files.
245 @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \
248 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
249 echo "$${cdcmd}$(MSGMERGE) $(MSGMERGE_OPTIONS) --lang=$$lang $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \
251 if { case `$(MSGMERGE) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \
252 '' | 0.[0-9] | 0.[0-9].* | 0.1[0-7] | 0.1[0-7].*) \
253 $(MSGMERGE) $(MSGMERGE_OPTIONS) -o $$tmpdir/$$lang.new.po $$lang.po $(DOMAIN).pot;; \
255 $(MSGMERGE) $(MSGMERGE_OPTIONS) --lang=$$lang -o $$tmpdir/$$lang.new.po $$lang.po $(DOMAIN).pot;; \
258 if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
259 rm -f $$tmpdir/$$lang.new.po; \
261 if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
264 echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
269 echo "msgmerge for $$lang.po failed!" 1>&2; \
270 rm -f $$tmpdir/$$lang.new.po; \
275 update-msg: Makefile $(MSGFILES)