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 --keyword=tr --flag=tr:1:pass-c-format --flag=tr:1:pass-qt-format \
18 --keyword=translate:2 --flag=translate:2:pass-c-format --flag=translate:2:pass-qt-format \
19 --keyword=QT_TR_NOOP --flag=QT_TR_NOOP:1:pass-c-format --flag=QT_TR_NOOP:1:pass-qt-format \
20 --keyword=QT_TRANSLATE_NOOP:2 --flag=QT_TRANSLATE_NOOP:2:pass-c-format --flag=QT_TRANSLATE_NOOP:2:pass-qt-format \
21 --keyword=_ --flag=_:1:pass-c-format --flag=_:1:pass-qt-format \
22 --keyword=N_ --flag=N_:1:pass-c-format --flag=N_:1:pass-qt-format
24 # This is the copyright holder that gets inserted into the header of the
25 # $(DOMAIN).pot file. Set this to the copyright holder of the surrounding
26 # package. (Note that the msgstr strings, extracted from the package's
27 # sources, belong to the copyright holder of the package.) Translators are
28 # expected to transfer the copyright for their translations to this person
29 # or entity, or to disclaim their copyright. The empty string stands for
30 # the public domain; in this case the translators are expected to disclaim
32 COPYRIGHT_HOLDER = Yoyodyne, Inc.
34 # This is the email address or URL to which the translators shall report
35 # bugs in the untranslated strings:
36 # - Strings which are not entire sentences, see the maintainer guidelines
37 # in the GNU gettext documentation, section 'Preparing Strings'.
38 # - Strings which use unclear terms or require additional context to be
40 # - Strings which make invalid assumptions about notation of date, time or
42 # - Pluralisation problems.
43 # - Incorrect English spelling.
44 # - Incorrect formatting.
45 # It can be your email address, or a mailing list address where translators
46 # can write to without being subscribed, or the URL of a web page through
47 # which the translators can contact you.
48 MSGID_BUGS_ADDRESS = bug-gnu-gettext@gnu.org
50 localedir = $(datadir)/locale
53 MSGMERGE_UPDATE = @MSGMERGE@ --update
58 # This is computed as $(foreach file, $(POTFILES), $(top_srcdir)/$(file))
59 POTFILES_DEPS = @POTFILES_DEPS@
61 # This is computed as $(foreach lang, $(LINGUAS), $(srcdir)/$(lang).po)
63 # This is computed as $(foreach lang, $(LINGUAS), $(lang).po-update)
64 UPDATEPOFILES = @UPDATEPOFILES@
65 # This is computed as $(foreach lang, $(LINGUAS), $(lang).nop)
66 DUMMYPOFILES = @DUMMYPOFILES@
67 # This is computed as $(foreach lang, $(LINGUAS), $(srcdir)/$(lang).qm)
71 # $(foreach lang, user-specified subset of $(LINGUAS), $(lang).qm)
72 CATALOGS = @QTCATALOGS@
74 SUFFIXES = .po .qm .sed .sin .nop .po-create .po-update
77 @lang=`echo $* | sed -e 's,.*/,,'`; \
78 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
79 echo "$${cdcmd}rm -f $${lang}.qm && $(GMSGFMT) -c --qt --statistics -o $${lang}.qm $${lang}.po"; \
80 cd $(srcdir) && rm -f $${lang}.qm && $(GMSGFMT) -c --qt --statistics -o t-$${lang}.qm $${lang}.po && mv t-$${lang}.qm $${lang}.qm
83 sed -e '/^#/d' $< > t-$@
87 all-local: all-local-@USE_NLS@
89 all-local-yes: stamp-po
92 # $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no
93 # internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because
94 # we don't want to bother translators with empty POT files). We assume that
95 # LINGUAS is empty in this case, i.e. $(POFILES) and $(QMFILES) are empty.
96 # In this case, stamp-po is a nop (i.e. a phony target).
98 # stamp-po is a timestamp denoting the last time at which the CATALOGS have
99 # been loosely updated. Its purpose is that when a developer or translator
100 # checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS,
101 # "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent
102 # invocations of "make" will do nothing. This timestamp would not be necessary
103 # if updating the $(CATALOGS) would always touch them; however, the rule for
104 # $(POFILES) has been designed to not touch files that don't need to be
106 stamp-po: $(srcdir)/$(DOMAIN).pot
107 test ! -f $(srcdir)/$(DOMAIN).pot || \
108 test -z "$(QMFILES)" || $(MAKE) $(QMFILES)
109 @test ! -f $(srcdir)/$(DOMAIN).pot || { \
110 echo "touch stamp-po" && \
111 echo timestamp > stamp-poT && \
112 mv stamp-poT stamp-po; \
115 # Note: Target 'all' must not depend on target '$(DOMAIN).pot-update',
116 # otherwise packages like GCC can not be built if only parts of the source
117 # have been downloaded.
119 # This target rebuilds $(DOMAIN).pot; it is an expensive operation.
120 # Note that $(DOMAIN).pot is not touched if it doesn't need to be changed.
121 $(DOMAIN).pot-update: $(POTFILES_DEPS) remove-potcdate.sed
122 if test -n '$(MSGID_BUGS_ADDRESS)'; then \
123 msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \
125 msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \
127 $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
128 --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \
129 --copyright-holder='$(COPYRIGHT_HOLDER)' \
130 --msgid-bugs-address="$$msgid_bugs_address" \
132 test ! -f $(DOMAIN).po || { \
133 if test -f $(srcdir)/$(DOMAIN).pot; then \
134 sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \
135 sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \
136 if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \
137 rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \
139 rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \
140 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
143 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
147 # This rule has no dependencies: we don't need to update $(DOMAIN).pot at
148 # every "make" invocation, only create it when it is missing.
149 # Only "make $(DOMAIN).pot-update" or "make dist" will force an update.
150 $(srcdir)/$(DOMAIN).pot:
151 $(MAKE) $(DOMAIN).pot-update
153 # This target rebuilds a PO file if $(DOMAIN).pot has changed.
154 # Note that a PO file is not touched if it doesn't need to be changed.
155 $(POFILES): $(srcdir)/$(DOMAIN).pot
156 @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
157 if test -f "$(srcdir)/$${lang}.po"; then \
158 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
159 echo "$${cdcmd}$(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot"; \
160 cd $(srcdir) && $(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot; \
162 $(MAKE) $${lang}.po-create; \
166 install-data-local: install-data-local-@USE_NLS@
167 install-data-local-no: all-local
168 install-data-local-yes: all-local
169 $(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/locale
170 @catalogs='$(CATALOGS)'; \
171 for cat in $$catalogs; do \
172 cat=`basename $$cat`; \
173 if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \
174 $(INSTALL_DATA) $$realcat $(DESTDIR)$(pkgdatadir)/locale/$(DOMAIN)_$$cat; \
175 echo "installing $$realcat as $(DESTDIR)$(pkgdatadir)/locale/$(DOMAIN)_$$cat"; \
178 installdirs-local: installdirs-local-@USE_NLS@
179 installdirs-local-no:
180 installdirs-local-yes:
181 $(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/locale
183 uninstall-local: uninstall-local-@USE_NLS@
186 catalogs='$(CATALOGS)'; \
187 for cat in $$catalogs; do \
188 cat=`basename $$cat`; \
189 rm -f $(DESTDIR)$(pkgdatadir)/locale/$(DOMAIN)_$$cat; \
195 MOSTLYCLEANFILES += remove-potcdate.sed
196 MOSTLYCLEANFILES += stamp-poT
197 MOSTLYCLEANFILES += core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po
198 MOSTLYCLEANFILES += *.o
200 MAINTAINERCLEANFILES = stamp-po $(QMFILES)
202 EXTRA_DIST = remove-potcdate.sin LINGUAS $(POFILES) $(QMFILES)
204 # Hidden from automake, but really activated. Works around an automake-1.5 bug.
208 if test -f $(srcdir)/$(DOMAIN).pot; then \
209 for file in $(DOMAIN).pot stamp-po; do \
210 if test -f $$file; then d=.; else d=$(srcdir); fi; \
211 cp -p $$d/$$file $(distdir)/$$file || exit 1; \
216 $(MAKE) $(DOMAIN).pot-update
217 test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES)
220 # General rule for creating PO files.
223 @lang=`echo $@ | sed -e 's/\.po-create$$//'`; \
224 echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \
227 # General rule for updating PO files.
230 @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \
233 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
234 echo "$${cdcmd}$(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \
236 if $(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$tmpdir/$$lang.new.po; then \
237 if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
238 rm -f $$tmpdir/$$lang.new.po; \
240 if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
243 echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
248 echo "msgmerge for $$lang.po failed!" 1>&2; \
249 rm -f $$tmpdir/$$lang.new.po; \
254 update-gmo: Makefile $(QMFILES)