1# Example for use of GNU gettext.
2# Copyright (C) 2003-2005 Free Software Foundation, Inc.
3# This file is in the public domain.
4#
5# Makefile configuration - processed by automake.
6
7# List of files which contain translatable strings.
8POTFILES = \
9  Hello.java
10
11# Usually the message domain is the same as the package name.
12DOMAIN = $(PACKAGE)
13
14# These options get passed to xgettext.
15XGETTEXT_OPTIONS =
16
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
24# their copyright.
25COPYRIGHT_HOLDER = Yoyodyne, Inc.
26
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
32#   understood.
33# - Strings which make invalid assumptions about notation of date, time or
34#   money.
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.
41MSGID_BUGS_ADDRESS = bug-gnu-gettext@gnu.org
42
43MSGMERGE = msgmerge
44MSGMERGE_UPDATE = @MSGMERGE@ --update
45MSGCAT = msgcat
46MSGINIT = msginit
47MSGCONV = msgconv
48MSGFILTER = msgfilter
49
50# This is computed as $(foreach file, $(POTFILES), $(top_srcdir)/$(file))
51POTFILES_DEPS = @POTFILES_DEPS@
52
53# This is computed as $(foreach lang, $(LINGUAS), $(srcdir)/$(lang).po)
54POFILES = @POFILES@
55# This is computed as $(foreach lang, $(LINGUAS), $(lang).po-update)
56UPDATEPOFILES = @UPDATEPOFILES@
57# This is computed as $(foreach lang, $(LINGUAS), $(lang).nop)
58DUMMYPOFILES = @DUMMYPOFILES@
59# This is computed as $(foreach lang, $(LINGUAS), $(top_srcdir)/$(DOMAIN)_$(lang).properties)
60PROPERTIESFILES = @PROPERTIESFILES@
61# This is computed as $(foreach lang, $(LINGUAS), $(top_srcdir)/$(DOMAIN)_$(lang).class)
62CLASSFILES = @CLASSFILES@
63
64# This is computed as
65# $(foreach lang, user-specified subset of $(LINGUAS), $(DOMAIN)_$(lang).properties)
66CATALOGS = @JAVACATALOGS@
67
68SUFFIXES = .po .sed .sin .nop .po-create .po-update
69
70.sin.sed:
71	sed -e '/^#/d' $< > t-$@
72	mv t-$@ $@
73
74
75all-local: stamp-po
76
77# $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no
78# internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because
79# we don't want to bother translators with empty POT files). We assume that
80# LINGUAS is empty in this case, i.e. $(POFILES) and $(PROPERTIESFILES) are
81# empty. In this case, stamp-po is a nop (i.e. a phony target).
82
83# stamp-po is a timestamp denoting the last time at which the CATALOGS have
84# been loosely updated. Its purpose is that when a developer or translator
85# checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS,
86# "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent
87# invocations of "make" will do nothing. This timestamp would not be necessary
88# if updating the $(CATALOGS) would always touch them; however, the rule for
89# $(POFILES) has been designed to not touch files that don't need to be
90# changed.
91stamp-po: $(srcdir)/$(DOMAIN).pot
92	test ! -f $(srcdir)/$(DOMAIN).pot || \
93	  $(MAKE) update-properties
94	@test ! -f $(srcdir)/$(DOMAIN).pot || { \
95	  echo "touch stamp-po" && \
96	  echo timestamp > stamp-poT && \
97	  mv stamp-poT stamp-po; \
98	}
99
100# Note: Target 'all' must not depend on target '$(DOMAIN).pot-update',
101# otherwise packages like GCC can not be built if only parts of the source
102# have been downloaded.
103
104# This target rebuilds $(DOMAIN).pot; it is an expensive operation.
105# Note that $(DOMAIN).pot is not touched if it doesn't need to be changed.
106$(DOMAIN).pot-update: $(POTFILES_DEPS) remove-potcdate.sed
107	if test -n '$(MSGID_BUGS_ADDRESS)'; then \
108	  msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \
109	else \
110	  msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \
111	fi; \
112	$(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
113	  --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \
114	  --copyright-holder='$(COPYRIGHT_HOLDER)' \
115	  --msgid-bugs-address="$$msgid_bugs_address" \
116	  $(POTFILES)
117	test ! -f $(DOMAIN).po || { \
118	  if test -f $(srcdir)/$(DOMAIN).pot; then \
119	    sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \
120	    sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \
121	    if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \
122	      rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \
123	    else \
124	      rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \
125	      mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
126	    fi; \
127	  else \
128	    mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
129	  fi; \
130	}
131
132# This rule has no dependencies: we don't need to update $(DOMAIN).pot at
133# every "make" invocation, only create it when it is missing.
134# Only "make $(DOMAIN).pot-update" or "make dist" will force an update.
135$(srcdir)/$(DOMAIN).pot:
136	$(MAKE) $(DOMAIN).pot-update
137
138# This target rebuilds a PO file if $(DOMAIN).pot has changed.
139# Note that a PO file is not touched if it doesn't need to be changed.
140$(POFILES): $(srcdir)/$(DOMAIN).pot
141	@lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
142	if test -f "$(srcdir)/$${lang}.po"; then \
143	  test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
144	  echo "$${cdcmd}$(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot"; \
145	  cd $(srcdir) && $(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot; \
146	else \
147	  $(MAKE) $${lang}.po-create; \
148	fi
149
150
151html ID:
152
153MOSTLYCLEANFILES =
154MOSTLYCLEANFILES += remove-potcdate.sed
155MOSTLYCLEANFILES += stamp-poT
156MOSTLYCLEANFILES += core core.* *.stackdump $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po
157
158MAINTAINERCLEANFILES = stamp-po
159
160EXTRA_DIST = remove-potcdate.sin LINGUAS $(POFILES)
161
162# Hidden from automake, but really activated. Works around an automake-1.5 bug.
163#distdir: distdir1
164distdir1:
165	$(MAKE) update-po
166	if test -f $(srcdir)/$(DOMAIN).pot; then \
167	  for file in $(DOMAIN).pot stamp-po; do \
168	    if test -f $$file; then d=.; else d=$(srcdir); fi; \
169	    cp -p $$d/$$file $(distdir)/$$file || exit 1; \
170	  done; \
171	fi
172
173update-po: Makefile
174	$(MAKE) $(DOMAIN).pot-update
175	test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES)
176	$(MAKE) update-properties
177
178# General rule for creating PO files.
179
180.nop.po-create:
181	@lang=`echo $@ | sed -e 's/\.po-create$$//'`; \
182	echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \
183	exit 1
184
185# General rule for updating PO files.
186
187.nop.po-update:
188	@lang=`echo $@ | sed -e 's/\.po-update$$//'`; \
189	tmpdir=`pwd`; \
190	echo "$$lang:"; \
191	test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
192	echo "$${cdcmd}$(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \
193	cd $(srcdir); \
194	if $(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$tmpdir/$$lang.new.po; then \
195	  if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
196	    rm -f $$tmpdir/$$lang.new.po; \
197	  else \
198	    if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
199	      :; \
200	    else \
201	      echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
202	      exit 1; \
203	    fi; \
204	  fi; \
205	else \
206	  echo "msgmerge for $$lang.po failed!" 1>&2; \
207	  rm -f $$tmpdir/$$lang.new.po; \
208	fi
209
210$(DUMMYPOFILES):
211
212update-properties: Makefile $(DOMAIN).pot $(POFILES)
213	@echo "$(MSGINIT) -i $(DOMAIN).pot --no-translator -l en --properties-output -o $(top_srcdir)/$(DOMAIN).properties"; \
214	$(MSGINIT) -i $(DOMAIN).pot --no-translator -l en --properties-output -o $(top_srcdir)/$(DOMAIN).properties || { rm -f $(top_srcdir)/$(DOMAIN).properties; exit 1; }
215	@for f in $(POFILES); do \
216	  lang=`echo $$f | sed -e 's,.*/,,' -e 's,\.po$$,,'`; \
217	  echo "$(GMSGFMT) -c --statistics -o /dev/null $(srcdir)/$${lang}.po"; \
218	  $(GMSGFMT) -c --statistics -o /dev/null $(srcdir)/$${lang}.po || exit 1; \
219	  echo "$(MSGCAT) --properties-output -o $(top_srcdir)/$(DOMAIN)_$$lang.properties $(srcdir)/$${lang}.po"; \
220	  $(MSGCAT) --properties-output -o $(top_srcdir)/$(DOMAIN)_$$lang.properties.tmp $(srcdir)/$${lang}.po || exit 1; \
221	  mv $(top_srcdir)/$(DOMAIN)_$$lang.properties.tmp $(top_srcdir)/$(DOMAIN)_$$lang.properties || exit 1; \
222	done
223
224# Alternatively, we could create classes instead of properties files.
225update-classes: Makefile $(DOMAIN).pot $(POFILES)
226	@echo "$(MSGINIT) -i $(DOMAIN).pot --no-translator -l en --properties-output -o $(top_srcdir)/$(DOMAIN).properties"; \
227	$(MSGINIT) -i $(DOMAIN).pot --no-translator -l en --properties-output -o $(top_srcdir)/$(DOMAIN).properties || { rm -f $(top_srcdir)/$(DOMAIN).properties; exit 1; }
228	@for f in $(POFILES); do \
229	  lang=`echo $$f | sed -e 's,.*/,,' -e 's,\.po$$,,'`; \
230	  echo "$(GMSGFMT) -c --statistics -j -d $(top_srcdir) -r $(DOMAIN) -l $${lang} $(srcdir)/$${lang}.po"; \
231	  $(GMSGFMT) -c --statistics -j -d $(top_srcdir) -r $(DOMAIN) -l $${lang} $(srcdir)/$${lang}.po || exit 1; \
232	done
233
234echo-catalogs:
235	@echo $(CATALOGS)
236