1 # Example for use of GNU gettext.
2 # Copyright (C) 2003-2005 Free Software Foundation, Inc.
3 # This file is in the public domain.
5 # Makefile configuration - processed by automake.
7 # List of files which contain translatable strings.
9 hello-1.pl.in hello-2.pl.in
11 # Usually the message domain is the same as the package name.
14 # These options get passed to xgettext.
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'%__' --flag=%__:1:pass-perl-format --flag=%__:1:pass-perl-brace-format \
20 -k__x --flag=__x:1:perl-brace-format \
21 -k__n:1,2 --flag=__n:1:pass-perl-format --flag=__n:1:pass-perl-brace-format \
22 --flag=__n:2:pass-perl-format --flag=__n:2:pass-perl-brace-format \
23 -k__nx:1,2 --flag=__nx:1:perl-brace-format --flag=__nx:2:perl-brace-format \
24 -k__xn:1,2 --flag=__xn:1:perl-brace-format --flag=__xn:2:perl-brace-format \
25 -kN__ --flag=N__:1:pass-perl-format --flag=N__:1:pass-perl-brace-format
27 # This is the copyright holder that gets inserted into the header of the
28 # $(DOMAIN).pot file. Set this to the copyright holder of the surrounding
29 # package. (Note that the msgstr strings, extracted from the package's
30 # sources, belong to the copyright holder of the package.) Translators are
31 # expected to transfer the copyright for their translations to this person
32 # or entity, or to disclaim their copyright. The empty string stands for
33 # the public domain; in this case the translators are expected to disclaim
35 COPYRIGHT_HOLDER = Yoyodyne, Inc.
37 # This is the email address or URL to which the translators shall report
38 # bugs in the untranslated strings:
39 # - Strings which are not entire sentences, see the maintainer guidelines
40 # in the GNU gettext documentation, section 'Preparing Strings'.
41 # - Strings which use unclear terms or require additional context to be
43 # - Strings which make invalid assumptions about notation of date, time or
45 # - Pluralisation problems.
46 # - Incorrect English spelling.
47 # - Incorrect formatting.
48 # It can be your email address, or a mailing list address where translators
49 # can write to without being subscribed, or the URL of a web page through
50 # which the translators can contact you.
51 MSGID_BUGS_ADDRESS = bug-gnu-gettext@gnu.org
53 # This is the list of locale categories, beyond LC_MESSAGES, for which the
54 # message catalogs shall be used. It is usually empty.
55 EXTRA_LOCALE_CATEGORIES =
57 localedir = $(datadir)/locale
60 MSGMERGE_UPDATE = @MSGMERGE@ --update
65 # This is computed as $(foreach file, $(POTFILES), $(top_srcdir)/$(file))
66 POTFILES_DEPS = @POTFILES_DEPS@
68 # This is computed as $(foreach lang, $(LINGUAS), $(srcdir)/$(lang).po)
70 # This is computed as $(foreach lang, $(LINGUAS), $(srcdir)/$(lang).gmo)
72 # This is computed as $(foreach lang, $(LINGUAS), $(lang).po-update)
73 UPDATEPOFILES = @UPDATEPOFILES@
74 # This is computed as $(foreach lang, $(LINGUAS), $(lang).nop)
75 DUMMYPOFILES = @DUMMYPOFILES@
78 # $(foreach lang, user-specified subset of $(LINGUAS), $(lang).gmo)
81 SUFFIXES = .po .gmo .mo .sed .sin .nop .po-create .po-update
84 @echo "$(MSGFMT) -c -o $@ $<"; \
85 $(MSGFMT) -c -o t-$@ $< && mv t-$@ $@
88 @lang=`echo $* | sed -e 's,.*/,,'`; \
89 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
90 echo "$${cdcmd}rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o $${lang}.gmo $${lang}.po"; \
91 cd $(srcdir) && rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o t-$${lang}.gmo $${lang}.po && mv t-$${lang}.gmo $${lang}.gmo
94 sed -e '/^#/d' $< > t-$@
98 all-local: all-local-@USE_NLS@
100 all-local-yes: stamp-po
103 # $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no
104 # internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because
105 # we don't want to bother translators with empty POT files). We assume that
106 # LINGUAS is empty in this case, i.e. $(POFILES) and $(GMOFILES) are empty.
107 # In this case, stamp-po is a nop (i.e. a phony target).
109 # stamp-po is a timestamp denoting the last time at which the CATALOGS have
110 # been loosely updated. Its purpose is that when a developer or translator
111 # checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS,
112 # "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent
113 # invocations of "make" will do nothing. This timestamp would not be necessary
114 # if updating the $(CATALOGS) would always touch them; however, the rule for
115 # $(POFILES) has been designed to not touch files that don't need to be
117 stamp-po: $(srcdir)/$(DOMAIN).pot
118 test ! -f $(srcdir)/$(DOMAIN).pot || \
119 test -z "$(GMOFILES)" || $(MAKE) $(GMOFILES)
120 @test ! -f $(srcdir)/$(DOMAIN).pot || { \
121 echo "touch stamp-po" && \
122 echo timestamp > stamp-poT && \
123 mv stamp-poT stamp-po; \
126 # Note: Target 'all' must not depend on target '$(DOMAIN).pot-update',
127 # otherwise packages like GCC can not be built if only parts of the source
128 # have been downloaded.
130 # This target rebuilds $(DOMAIN).pot; it is an expensive operation.
131 # Note that $(DOMAIN).pot is not touched if it doesn't need to be changed.
132 $(DOMAIN).pot-update: $(POTFILES_DEPS) remove-potcdate.sed
133 if test -n '$(MSGID_BUGS_ADDRESS)'; then \
134 msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \
136 msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \
138 $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
139 --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \
140 --copyright-holder='$(COPYRIGHT_HOLDER)' \
141 --msgid-bugs-address="$$msgid_bugs_address" \
143 test ! -f $(DOMAIN).po || { \
144 if test -f $(srcdir)/$(DOMAIN).pot; then \
145 sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \
146 sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \
147 if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \
148 rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \
150 rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \
151 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
154 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
158 # This rule has no dependencies: we don't need to update $(DOMAIN).pot at
159 # every "make" invocation, only create it when it is missing.
160 # Only "make $(DOMAIN).pot-update" or "make dist" will force an update.
161 $(srcdir)/$(DOMAIN).pot:
162 $(MAKE) $(DOMAIN).pot-update
164 # This target rebuilds a PO file if $(DOMAIN).pot has changed.
165 # Note that a PO file is not touched if it doesn't need to be changed.
166 $(POFILES): $(srcdir)/$(DOMAIN).pot
167 @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
168 if test -f "$(srcdir)/$${lang}.po"; then \
169 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
170 echo "$${cdcmd}$(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot"; \
171 cd $(srcdir) && $(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot; \
173 $(MAKE) $${lang}.po-create; \
177 install-data-local: install-data-local-@USE_NLS@
178 install-data-local-no: all-local
179 install-data-local-yes: all-local
180 $(mkinstalldirs) $(DESTDIR)$(datadir)
181 @catalogs='$(CATALOGS)'; \
182 for cat in $$catalogs; do \
183 cat=`basename $$cat`; \
184 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
185 dir=$(localedir)/$$lang/LC_MESSAGES; \
186 $(mkinstalldirs) $(DESTDIR)$$dir; \
187 if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \
188 $(INSTALL_DATA) $$realcat $(DESTDIR)$$dir/$(DOMAIN).mo; \
189 echo "installing $$realcat as $(DESTDIR)$$dir/$(DOMAIN).mo"; \
190 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
191 if test -n "$$lc"; then \
192 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
193 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
194 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
195 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
196 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
198 if test -f $$file; then \
199 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
202 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
204 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
207 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
208 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
211 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
212 ln -s ../LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
213 ln $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
214 cp -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
215 echo "installing $$realcat link as $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo"; \
220 installdirs-local: installdirs-local-@USE_NLS@
221 installdirs-local-no:
222 installdirs-local-yes:
223 $(mkinstalldirs) $(DESTDIR)$(datadir)
224 @catalogs='$(CATALOGS)'; \
225 for cat in $$catalogs; do \
226 cat=`basename $$cat`; \
227 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
228 dir=$(localedir)/$$lang/LC_MESSAGES; \
229 $(mkinstalldirs) $(DESTDIR)$$dir; \
230 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
231 if test -n "$$lc"; then \
232 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
233 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
234 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
235 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
236 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
238 if test -f $$file; then \
239 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
242 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
244 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
247 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
248 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
255 uninstall-local: uninstall-local-@USE_NLS@
258 catalogs='$(CATALOGS)'; \
259 for cat in $$catalogs; do \
260 cat=`basename $$cat`; \
261 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
262 for lc in LC_MESSAGES $(EXTRA_LOCALE_CATEGORIES); do \
263 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
270 MOSTLYCLEANFILES += remove-potcdate.sed
271 MOSTLYCLEANFILES += stamp-poT
272 MOSTLYCLEANFILES += core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po
273 MOSTLYCLEANFILES += *.o
275 DISTCLEANFILES = *.mo
277 MAINTAINERCLEANFILES = stamp-po $(GMOFILES)
279 EXTRA_DIST = remove-potcdate.sin LINGUAS $(POFILES) $(GMOFILES)
281 # Hidden from automake, but really activated. Works around an automake-1.5 bug.
285 if test -f $(srcdir)/$(DOMAIN).pot; then \
286 for file in $(DOMAIN).pot stamp-po; do \
287 if test -f $$file; then d=.; else d=$(srcdir); fi; \
288 cp -p $$d/$$file $(distdir)/$$file || exit 1; \
293 $(MAKE) $(DOMAIN).pot-update
294 test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES)
297 # General rule for creating PO files.
300 @lang=`echo $@ | sed -e 's/\.po-create$$//'`; \
301 echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \
304 # General rule for updating PO files.
307 @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \
310 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
311 echo "$${cdcmd}$(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \
313 if $(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$tmpdir/$$lang.new.po; then \
314 if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
315 rm -f $$tmpdir/$$lang.new.po; \
317 if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
320 echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
325 echo "msgmerge for $$lang.po failed!" 1>&2; \
326 rm -f $$tmpdir/$$lang.new.po; \
331 update-gmo: Makefile $(GMOFILES)