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.
11 # Usually the message domain is the same as the package name.
14 # These options get passed to xgettext.
17 # This is the copyright holder that gets inserted into the header of the
18 # $(DOMAIN).pot file. Set this to the copyright holder of the surrounding
19 # package. (Note that the msgstr strings, extracted from the package's
20 # sources, belong to the copyright holder of the package.) Translators are
21 # expected to transfer the copyright for their translations to this person
22 # or entity, or to disclaim their copyright. The empty string stands for
23 # the public domain; in this case the translators are expected to disclaim
25 COPYRIGHT_HOLDER = Yoyodyne, Inc.
27 # This is the email address or URL to which the translators shall report
28 # bugs in the untranslated strings:
29 # - Strings which are not entire sentences, see the maintainer guidelines
30 # in the GNU gettext documentation, section 'Preparing Strings'.
31 # - Strings which use unclear terms or require additional context to be
33 # - Strings which make invalid assumptions about notation of date, time or
35 # - Pluralisation problems.
36 # - Incorrect English spelling.
37 # - Incorrect formatting.
38 # It can be your email address, or a mailing list address where translators
39 # can write to without being subscribed, or the URL of a web page through
40 # which the translators can contact you.
41 MSGID_BUGS_ADDRESS = bug-gnu-gettext@gnu.org
43 # This is the list of locale categories, beyond LC_MESSAGES, for which the
44 # message catalogs shall be used. It is usually empty.
45 EXTRA_LOCALE_CATEGORIES =
47 localedir = $(datadir)/locale
50 MSGMERGE_UPDATE = @MSGMERGE@ --update
55 # This is computed as $(foreach file, $(POTFILES), $(top_srcdir)/$(file))
56 POTFILES_DEPS = @POTFILES_DEPS@
58 # This is computed as $(foreach lang, $(LINGUAS), $(srcdir)/$(lang).po)
60 # This is computed as $(foreach lang, $(LINGUAS), $(srcdir)/$(lang).gmo)
62 # This is computed as $(foreach lang, $(LINGUAS), $(lang).po-update)
63 UPDATEPOFILES = @UPDATEPOFILES@
64 # This is computed as $(foreach lang, $(LINGUAS), $(lang).nop)
65 DUMMYPOFILES = @DUMMYPOFILES@
68 # $(foreach lang, user-specified subset of $(LINGUAS), $(lang).gmo)
71 SUFFIXES = .po .gmo .mo .sed .sin .nop .po-create .po-update
74 @echo "$(MSGFMT) -c -o $@ $<"; \
75 $(MSGFMT) -c -o t-$@ $< && mv t-$@ $@
78 @lang=`echo $* | sed -e 's,.*/,,'`; \
79 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
80 echo "$${cdcmd}rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o $${lang}.gmo $${lang}.po"; \
81 cd $(srcdir) && rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o t-$${lang}.gmo $${lang}.po && mv t-$${lang}.gmo $${lang}.gmo
84 sed -e '/^#/d' $< > t-$@
88 all-local: all-local-@USE_NLS@
90 all-local-yes: stamp-po
93 # $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no
94 # internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because
95 # we don't want to bother translators with empty POT files). We assume that
96 # LINGUAS is empty in this case, i.e. $(POFILES) and $(GMOFILES) are empty.
97 # In this case, stamp-po is a nop (i.e. a phony target).
99 # stamp-po is a timestamp denoting the last time at which the CATALOGS have
100 # been loosely updated. Its purpose is that when a developer or translator
101 # checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS,
102 # "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent
103 # invocations of "make" will do nothing. This timestamp would not be necessary
104 # if updating the $(CATALOGS) would always touch them; however, the rule for
105 # $(POFILES) has been designed to not touch files that don't need to be
107 stamp-po: $(srcdir)/$(DOMAIN).pot
108 test ! -f $(srcdir)/$(DOMAIN).pot || \
109 test -z "$(GMOFILES)" || $(MAKE) $(GMOFILES)
110 @test ! -f $(srcdir)/$(DOMAIN).pot || { \
111 echo "touch stamp-po" && \
112 echo timestamp > stamp-poT && \
113 mv stamp-poT stamp-po; \
116 # Note: Target 'all' must not depend on target '$(DOMAIN).pot-update',
117 # otherwise packages like GCC can not be built if only parts of the source
118 # have been downloaded.
120 # This target rebuilds $(DOMAIN).pot; it is an expensive operation.
121 # Note that $(DOMAIN).pot is not touched if it doesn't need to be changed.
122 $(DOMAIN).pot-update: $(POTFILES_DEPS) remove-potcdate.sed
123 if test -n '$(MSGID_BUGS_ADDRESS)'; then \
124 msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \
126 msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \
128 $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
129 --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \
130 --copyright-holder='$(COPYRIGHT_HOLDER)' \
131 --msgid-bugs-address="$$msgid_bugs_address" \
133 test ! -f $(DOMAIN).po || { \
134 if test -f $(srcdir)/$(DOMAIN).pot; then \
135 sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \
136 sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \
137 if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \
138 rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \
140 rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \
141 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
144 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
148 # This rule has no dependencies: we don't need to update $(DOMAIN).pot at
149 # every "make" invocation, only create it when it is missing.
150 # Only "make $(DOMAIN).pot-update" or "make dist" will force an update.
151 $(srcdir)/$(DOMAIN).pot:
152 $(MAKE) $(DOMAIN).pot-update
154 # This target rebuilds a PO file if $(DOMAIN).pot has changed.
155 # Note that a PO file is not touched if it doesn't need to be changed.
156 $(POFILES): $(srcdir)/$(DOMAIN).pot
157 @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
158 if test -f "$(srcdir)/$${lang}.po"; then \
159 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
160 echo "$${cdcmd}$(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot"; \
161 cd $(srcdir) && $(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot; \
163 $(MAKE) $${lang}.po-create; \
167 install-data-local: install-data-local-@USE_NLS@
168 install-data-local-no: all-local
169 install-data-local-yes: all-local
170 $(mkinstalldirs) $(DESTDIR)$(datadir)
171 @catalogs='$(CATALOGS)'; \
172 for cat in $$catalogs; do \
173 cat=`basename $$cat`; \
174 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
175 dir=$(localedir)/$$lang/LC_MESSAGES; \
176 $(mkinstalldirs) $(DESTDIR)$$dir; \
177 if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \
178 $(INSTALL_DATA) $$realcat $(DESTDIR)$$dir/$(DOMAIN).mo; \
179 echo "installing $$realcat as $(DESTDIR)$$dir/$(DOMAIN).mo"; \
180 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
181 if test -n "$$lc"; then \
182 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
183 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
184 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
185 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
186 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
188 if test -f $$file; then \
189 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
192 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
194 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
197 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
198 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
201 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
202 ln -s ../LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
203 ln $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
204 cp -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
205 echo "installing $$realcat link as $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo"; \
210 installdirs-local: installdirs-local-@USE_NLS@
211 installdirs-local-no:
212 installdirs-local-yes:
213 $(mkinstalldirs) $(DESTDIR)$(datadir)
214 @catalogs='$(CATALOGS)'; \
215 for cat in $$catalogs; do \
216 cat=`basename $$cat`; \
217 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
218 dir=$(localedir)/$$lang/LC_MESSAGES; \
219 $(mkinstalldirs) $(DESTDIR)$$dir; \
220 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
221 if test -n "$$lc"; then \
222 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
223 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
224 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
225 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
226 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
228 if test -f $$file; then \
229 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
232 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
234 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
237 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
238 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
245 uninstall-local: uninstall-local-@USE_NLS@
248 catalogs='$(CATALOGS)'; \
249 for cat in $$catalogs; do \
250 cat=`basename $$cat`; \
251 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
252 for lc in LC_MESSAGES $(EXTRA_LOCALE_CATEGORIES); do \
253 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
260 MOSTLYCLEANFILES += remove-potcdate.sed
261 MOSTLYCLEANFILES += stamp-poT
262 MOSTLYCLEANFILES += core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po
263 MOSTLYCLEANFILES += *.o
265 DISTCLEANFILES = *.mo
267 MAINTAINERCLEANFILES = stamp-po $(GMOFILES)
269 EXTRA_DIST = remove-potcdate.sin LINGUAS $(POFILES) $(GMOFILES)
271 # Hidden from automake, but really activated. Works around an automake-1.5 bug.
275 if test -f $(srcdir)/$(DOMAIN).pot; then \
276 for file in $(DOMAIN).pot stamp-po; do \
277 if test -f $$file; then d=.; else d=$(srcdir); fi; \
278 cp -p $$d/$$file $(distdir)/$$file || exit 1; \
283 $(MAKE) $(DOMAIN).pot-update
284 test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES)
287 # General rule for creating PO files.
290 @lang=`echo $@ | sed -e 's/\.po-create$$//'`; \
291 echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \
294 # General rule for updating PO files.
297 @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \
300 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
301 echo "$${cdcmd}$(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \
303 if $(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$tmpdir/$$lang.new.po; then \
304 if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
305 rm -f $$tmpdir/$$lang.new.po; \
307 if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
310 echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
315 echo "msgmerge for $$lang.po failed!" 1>&2; \
316 rm -f $$tmpdir/$$lang.new.po; \
321 update-gmo: Makefile $(GMOFILES)