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.
8 hello-1.pl.in hello-2.pl.in
10 # Usually the message domain is the same as the package name.
13 # These options get passed to xgettext.
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
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
34 COPYRIGHT_HOLDER = Yoyodyne, Inc.
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
42 # - Strings which make invalid assumptions about notation of date, time or
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.
50 MSGID_BUGS_ADDRESS = bug-gnu-gettext@gnu.org
52 # This is the list of locale categories, beyond LC_MESSAGES, for which the
53 # message catalogs shall be used. It is usually empty.
54 EXTRA_LOCALE_CATEGORIES =
56 # These options get passed to msgmerge.
57 # Useful options are in particular:
58 # --previous to keep previous msgids of translated messages,
59 # --quiet to reduce the verbosity.
60 MSGMERGE_OPTIONS = --quiet
63 MSGMERGE_UPDATE = @MSGMERGE@ --update
68 # This is computed as $(foreach file, $(POTFILES), $(top_srcdir)/$(file))
69 POTFILES_DEPS = @POTFILES_DEPS@
71 # This is computed as $(foreach lang, $(LINGUAS), $(srcdir)/$(lang).po)
73 # This is computed as $(foreach lang, $(LINGUAS), $(srcdir)/$(lang).gmo)
75 # This is computed as $(foreach lang, $(LINGUAS), $(lang).po-update)
76 UPDATEPOFILES = @UPDATEPOFILES@
77 # This is computed as $(foreach lang, $(LINGUAS), $(lang).nop)
78 DUMMYPOFILES = @DUMMYPOFILES@
81 # $(foreach lang, user-specified subset of $(LINGUAS), $(lang).gmo)
84 SUFFIXES = .po .gmo .mo .sed .sin .nop .po-create .po-update
87 @echo "$(MSGFMT) -c -o $@ $<"; \
88 $(MSGFMT) -c -o t-$@ $< && mv t-$@ $@
91 @lang=`echo $* | sed -e 's,.*/,,'`; \
92 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
93 echo "$${cdcmd}rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics --verbose -o $${lang}.gmo $${lang}.po"; \
94 cd $(srcdir) && rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics --verbose -o t-$${lang}.gmo $${lang}.po && mv t-$${lang}.gmo $${lang}.gmo
97 sed -e '/^#/d' $< > t-$@
101 all-local: all-local-@USE_NLS@
103 all-local-yes: stamp-po
106 # $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no
107 # internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because
108 # we don't want to bother translators with empty POT files). We assume that
109 # LINGUAS is empty in this case, i.e. $(POFILES) and $(GMOFILES) are empty.
110 # In this case, stamp-po is a nop (i.e. a phony target).
112 # stamp-po is a timestamp denoting the last time at which the CATALOGS have
113 # been loosely updated. Its purpose is that when a developer or translator
114 # checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS,
115 # "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent
116 # invocations of "make" will do nothing. This timestamp would not be necessary
117 # if updating the $(CATALOGS) would always touch them; however, the rule for
118 # $(POFILES) has been designed to not touch files that don't need to be
120 stamp-po: $(srcdir)/$(DOMAIN).pot
121 test ! -f $(srcdir)/$(DOMAIN).pot || \
122 test -z "$(GMOFILES)" || $(MAKE) $(GMOFILES)
123 @test ! -f $(srcdir)/$(DOMAIN).pot || { \
124 echo "touch stamp-po" && \
125 echo timestamp > stamp-poT && \
126 mv stamp-poT stamp-po; \
129 # Note: Target 'all' must not depend on target '$(DOMAIN).pot-update',
130 # otherwise packages like GCC can not be built if only parts of the source
131 # have been downloaded.
133 # This target rebuilds $(DOMAIN).pot; it is an expensive operation.
134 # Note that $(DOMAIN).pot is not touched if it doesn't need to be changed.
135 $(DOMAIN).pot-update: $(POTFILES_DEPS) remove-potcdate.sed
136 if LC_ALL=C grep 'GNU $(PACKAGE)' $(top_srcdir)/* 2>/dev/null | grep -v 'libtool:' >/dev/null; then \
137 package_gnu='GNU '; \
141 if test -n '$(MSGID_BUGS_ADDRESS)'; then \
142 msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \
144 msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \
146 case `$(XGETTEXT) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \
147 '' | 0.[0-9] | 0.[0-9].* | 0.1[0-5] | 0.1[0-5].* | 0.16 | 0.16.[0-1]*) \
148 $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
149 --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) @XGETTEXT_EXTRA_OPTIONS@ \
150 --copyright-holder='$(COPYRIGHT_HOLDER)' \
151 --msgid-bugs-address="$$msgid_bugs_address" \
155 $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
156 --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) @XGETTEXT_EXTRA_OPTIONS@ \
157 --copyright-holder='$(COPYRIGHT_HOLDER)' \
158 --package-name="$${package_gnu}$(PACKAGE)" \
159 --package-version='$(VERSION)' \
160 --msgid-bugs-address="$$msgid_bugs_address" \
164 test ! -f $(DOMAIN).po || { \
165 if test -f $(srcdir)/$(DOMAIN).pot; then \
166 sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \
167 sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \
168 if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \
169 rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \
171 rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \
172 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
175 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
179 # This rule has no dependencies: we don't need to update $(DOMAIN).pot at
180 # every "make" invocation, only create it when it is missing.
181 # Only "make $(DOMAIN).pot-update" or "make dist" will force an update.
182 $(srcdir)/$(DOMAIN).pot:
183 $(MAKE) $(DOMAIN).pot-update
185 # This target rebuilds a PO file if $(DOMAIN).pot has changed.
186 # Note that a PO file is not touched if it doesn't need to be changed.
187 $(POFILES): $(srcdir)/$(DOMAIN).pot
188 @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
189 if test -f "$(srcdir)/$${lang}.po"; then \
190 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
191 echo "$${cdcmd}$(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} $${lang}.po $(DOMAIN).pot"; \
193 && { case `$(MSGMERGE_UPDATE) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \
194 '' | 0.[0-9] | 0.[0-9].* | 0.1[0-7] | 0.1[0-7].*) \
195 $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) $${lang}.po $(DOMAIN).pot;; \
197 $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} $${lang}.po $(DOMAIN).pot;; \
201 $(MAKE) $${lang}.po-create; \
205 install-data-local: install-data-local-@USE_NLS@
206 install-data-local-no: all-local
207 install-data-local-yes: all-local
208 $(mkdir_p) $(DESTDIR)$(datadir)
209 @catalogs='$(CATALOGS)'; \
210 for cat in $$catalogs; do \
211 cat=`basename $$cat`; \
212 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
213 dir=$(localedir)/$$lang/LC_MESSAGES; \
214 $(mkdir_p) $(DESTDIR)$$dir; \
215 if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \
216 $(INSTALL_DATA) $$realcat $(DESTDIR)$$dir/$(DOMAIN).mo; \
217 echo "installing $$realcat as $(DESTDIR)$$dir/$(DOMAIN).mo"; \
218 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
219 if test -n "$$lc"; then \
220 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
221 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
222 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
223 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
224 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
226 if test -f $$file; then \
227 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
230 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
232 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
235 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
236 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
239 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
240 ln -s ../LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
241 ln $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
242 cp -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
243 echo "installing $$realcat link as $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo"; \
248 installdirs-local: installdirs-local-@USE_NLS@
249 installdirs-local-no:
250 installdirs-local-yes:
251 $(mkdir_p) $(DESTDIR)$(datadir)
252 @catalogs='$(CATALOGS)'; \
253 for cat in $$catalogs; do \
254 cat=`basename $$cat`; \
255 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
256 dir=$(localedir)/$$lang/LC_MESSAGES; \
257 $(mkdir_p) $(DESTDIR)$$dir; \
258 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
259 if test -n "$$lc"; then \
260 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
261 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
262 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
263 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
264 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
266 if test -f $$file; then \
267 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
270 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
272 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
275 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
276 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
283 uninstall-local: uninstall-local-@USE_NLS@
286 catalogs='$(CATALOGS)'; \
287 for cat in $$catalogs; do \
288 cat=`basename $$cat`; \
289 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
290 for lc in LC_MESSAGES $(EXTRA_LOCALE_CATEGORIES); do \
291 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
298 MOSTLYCLEANFILES += remove-potcdate.sed
299 MOSTLYCLEANFILES += stamp-poT
300 MOSTLYCLEANFILES += core core.* *.stackdump $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po
301 MOSTLYCLEANFILES += *.o
303 DISTCLEANFILES = *.mo
305 MAINTAINERCLEANFILES = stamp-po $(GMOFILES)
307 EXTRA_DIST = remove-potcdate.sin LINGUAS $(POFILES) $(GMOFILES)
309 # Hidden from automake, but really activated. Works around an automake-1.5 bug.
313 if test -f $(srcdir)/$(DOMAIN).pot; then \
314 for file in $(DOMAIN).pot stamp-po; do \
315 if test -f $$file; then d=.; else d=$(srcdir); fi; \
316 cp -p $$d/$$file $(distdir)/$$file || exit 1; \
321 $(MAKE) $(DOMAIN).pot-update
322 test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES)
325 # General rule for creating PO files.
328 @lang=`echo $@ | sed -e 's/\.po-create$$//'`; \
329 echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \
332 # General rule for updating PO files.
335 @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \
338 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
339 echo "$${cdcmd}$(MSGMERGE) $(MSGMERGE_OPTIONS) --lang=$$lang $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \
341 if { case `$(MSGMERGE) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \
342 '' | 0.[0-9] | 0.[0-9].* | 0.1[0-7] | 0.1[0-7].*) \
343 $(MSGMERGE) $(MSGMERGE_OPTIONS) -o $$tmpdir/$$lang.new.po $$lang.po $(DOMAIN).pot;; \
345 $(MSGMERGE) $(MSGMERGE_OPTIONS) --lang=$$lang -o $$tmpdir/$$lang.new.po $$lang.po $(DOMAIN).pot;; \
348 if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
349 rm -f $$tmpdir/$$lang.new.po; \
351 if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
354 echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
359 echo "msgmerge for $$lang.po failed!" 1>&2; \
360 rm -f $$tmpdir/$$lang.new.po; \
365 update-gmo: Makefile $(GMOFILES)