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