1# Example for use of GNU gettext.
2# Copyright (C) 2003 Free Software Foundation, Inc.
3# This file is in the public domain.
4#
5# Makefile - processed by GNU make.
6
7# NLS is enabled by default.
8USE_NLS = yes
9
10# List of files which contain translatable strings.
11POTFILES = \
12  Hello.m
13
14# Usually the message domain is the same as the package name in lower case.
15DOMAIN = hello-objc-gnustep
16
17# These options get passed to xgettext.
18XGETTEXT_OPTIONS =
19
20# This is the copyright holder that gets inserted into the header of the
21# $(DOMAIN).pot file.  Set this to the copyright holder of the surrounding
22# package.  (Note that the msgstr strings, extracted from the package's
23# sources, belong to the copyright holder of the package.)  Translators are
24# expected to transfer the copyright for their translations to this person
25# or entity, or to disclaim their copyright.  The empty string stands for
26# the public domain; in this case the translators are expected to disclaim
27# their copyright.
28COPYRIGHT_HOLDER = Yoyodyne, Inc.
29
30# This is the email address or URL to which the translators shall report
31# bugs in the untranslated strings:
32# - Strings which are not entire sentences, see the maintainer guidelines
33#   in the GNU gettext documentation, section 'Preparing Strings'.
34# - Strings which use unclear terms or require additional context to be
35#   understood.
36# - Strings which make invalid assumptions about notation of date, time or
37#   money.
38# - Pluralisation problems.
39# - Incorrect English spelling.
40# - Incorrect formatting.
41# It can be your email address, or a mailing list address where translators
42# can write to without being subscribed, or the URL of a web page through
43# which the translators can contact you.
44MSGID_BUGS_ADDRESS = bug-gnu-gettext@gnu.org
45
46-include $(GNUSTEP_MAKEFILES)/rules.make
47
48XGETTEXT = xgettext
49MSGMERGE = msgmerge
50MSGMERGE_UPDATE = msgmerge --update
51MSGINIT = msginit
52MSGCONV = msgconv
53MSGFILTER = msgfilter
54
55# Set of available languages.
56LINGUAS := $(shell sed -e "/^\#/d" LINGUAS)
57# Set of languages which use msgen.
58ENLINGUAS := $(filter-out $(LINGUAS), en)
59
60top_srcdir = ..
61
62include LocaleAliases
63
64POTFILES_DEPS = $(foreach file, $(POTFILES), $(top_srcdir)/$(file))
65POFILES = $(foreach lang, $(LINGUAS), $(lang).po)
66UPDATEPOFILES = $(foreach lang, $(LINGUAS), $(lang).po-update)
67DUMMYPOFILES = $(foreach lang, $(LINGUAS), $(lang).nop)
68STRINGSFILES = $(foreach lang, $(LINGUAS), $(top_srcdir)/$(NSLOCALE_$(lang)).lproj/Localizable.strings)
69ENSTRINGSFILES = $(foreach lang, $(ENLINGUAS), $(top_srcdir)/$(NSLOCALE_$(lang)).lproj/Localizable.strings)
70CATALOGS = $(STRINGSFILES) $(ENSTRINGSFILES)
71
72.SUFFIXES: .po .mo .sed .sin .nop .po-update
73
74.sin.sed:
75	sed -e '/^#/d' $< > t-$@
76	mv t-$@ $@
77
78
79internal-all:: all-local-$(USE_NLS)
80
81all-local-yes: $(CATALOGS)
82all-local-no:
83
84# Note: Target 'all' must not depend on target '$(DOMAIN).pot-update',
85# otherwise packages like GCC can not be built if only parts of the source
86# have been downloaded.
87
88# This target rebuilds $(DOMAIN).pot; it is an expensive operation.
89# Note that $(DOMAIN).pot is not touched if it doesn't need to be changed.
90$(DOMAIN).pot-update: $(POTFILES_DEPS) remove-potcdate.sed
91	$(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
92	  --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \
93	  --copyright-holder='$(COPYRIGHT_HOLDER)' \
94	  --msgid-bugs-address='$(MSGID_BUGS_ADDRESS)' \
95	  $(POTFILES)
96	test ! -f $(DOMAIN).po || { \
97	  if test -f $(DOMAIN).pot; then \
98	    sed -f remove-potcdate.sed < $(DOMAIN).pot > $(DOMAIN).1po && \
99	    sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \
100	    if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \
101	      rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \
102	    else \
103	      rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).pot && \
104	      mv $(DOMAIN).po $(DOMAIN).pot; \
105	    fi; \
106	  else \
107	    mv $(DOMAIN).po $(DOMAIN).pot; \
108	  fi; \
109	}
110
111# This rule has no dependencies: we don't need to update $(DOMAIN).pot at
112# every "make" invocation, only create it when it is missing.
113# Only "make $(DOMAIN).pot-update" or "make dist" will force an update.
114$(DOMAIN).pot:
115	$(MAKE) $(DOMAIN).pot-update
116
117# This target rebuilds a PO file if $(DOMAIN).pot has changed.
118# Note that a PO file is not touched if it doesn't need to be changed.
119$(POFILES): $(DOMAIN).pot
120	@lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
121	echo "$(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot"; \
122	$(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot
123
124update-po:
125	$(MAKE) $(DOMAIN).pot-update
126	test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES)
127	$(MAKE) update-strings
128
129# General rule for updating PO files.
130
131.nop.po-update:
132	@lang=`echo $@ | sed -e 's/\.po-update$$//'`; \
133	tmpdir=`pwd`; \
134	echo "$$lang:"; \
135	echo "$(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \
136	if $(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$tmpdir/$$lang.new.po; then \
137	  if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
138	    rm -f $$tmpdir/$$lang.new.po; \
139	  else \
140	    if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
141	      :; \
142	    else \
143	      echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
144	      exit 1; \
145	    fi; \
146	  fi; \
147	else \
148	  echo "msgmerge for $$lang.po failed!" 1>&2; \
149	  rm -f $$tmpdir/$$lang.new.po; \
150	fi
151
152$(DUMMYPOFILES):
153
154
155update-strings: $(CATALOGS)
156	@:
157
158# I don't know how to make a dependency from a particular .strings file to its
159# corresponding .po file; therefore I put here a dependency towards all .po
160# files. It's safer than no dependency at all.
161$(STRINGSFILES): $(POFILES)
162	$(MAKE) $(UNIXLOCALE_$(patsubst %.lproj,%, $(notdir $(patsubst %/,%, $(dir $@))))).po
163	mkdir -p $(patsubst %/,%, $(dir $@))
164	msgcat --stringtable-output -o $@.tmp $(UNIXLOCALE_$(patsubst %.lproj,%, $(notdir $(patsubst %/,%, $(dir $@))))).po
165	mv $@.tmp $@
166
167$(ENSTRINGSFILES): $(DOMAIN).pot
168	mkdir -p $(patsubst %/,%, $(dir $@))
169	$(MSGINIT) -i $(DOMAIN).pot --no-translator -l $(UNIXLOCALE_$(patsubst %.lproj,%, $(notdir $(patsubst %/,%, $(dir $@))))) --stringtable-output -o $@.tmp
170	mv $@.tmp $@
171
172echo-languages:
173	@echo $(foreach lang, $(LINGUAS), $(NSLOCALE_$(lang)))
174
175