-# $PostgreSQL: pgsql/src/nls-global.mk,v 1.17 2009/01/09 10:54:08 petere Exp $
+# src/nls-global.mk
# Common rules for Native Language Support (NLS)
#
# needs to contain a file 'nls.mk' with the following make variable
# assignments:
#
-# CATALOG_NAME -- name of the message catalog (xxx.po); probably
-# name of the program
-# AVAIL_LANGUAGES -- list of languages that are provided/supported
-# GETTEXT_FILES -- list of source files that contain message strings
-# GETTEXT_TRIGGERS -- (optional) list of functions that contain
+# CATALOG_NAME -- name of the message catalog (xxx.po); probably
+# name of the program
+# AVAIL_LANGUAGES -- list of languages that are provided/supported
+# GETTEXT_FILES -- list of source files that contain message strings
+# GETTEXT_TRIGGERS -- (optional) list of functions that contain
# translatable strings
#
# That's all, the rest is done here, if --enable-nls was specified.
XGETTEXT += -ctranslator --copyright-holder='PostgreSQL Global Development Group' --msgid-bugs-address=pgsql-bugs@postgresql.org
endif
+# _ is defined in c.h, so it's global
+GETTEXT_TRIGGERS += _
+
+
+# common settings that apply to backend and all backend modules
+BACKEND_COMMON_GETTEXT_TRIGGERS = \
+ errmsg errmsg_plural:1,2 \
+ errdetail errdetail_log errdetail_plural:1,2 \
+ errhint \
+ errcontext
+
all-po: $(MO_FILES)
%.mo: %.po
$(MSGFMT) -o $@ $<
-ifdef XGETTEXT
ifeq ($(word 1,$(GETTEXT_FILES)),+)
-po/$(CATALOG_NAME).pot: $(word 2, $(GETTEXT_FILES))
+po/$(CATALOG_NAME).pot: $(word 2, $(GETTEXT_FILES)) $(MAKEFILE_LIST)
+ifdef XGETTEXT
$(XGETTEXT) -D $(srcdir) -n $(addprefix -k, $(GETTEXT_TRIGGERS)) -f $<
else
-po/$(CATALOG_NAME).pot: $(GETTEXT_FILES)
+ @echo "You don't have 'xgettext'."; exit 1
+endif
+else # GETTEXT_FILES
+po/$(CATALOG_NAME).pot: $(GETTEXT_FILES) $(MAKEFILE_LIST)
# Change to srcdir explicitly, don't rely on $^. That way we get
# consistent #: file references in the po files.
+ifdef XGETTEXT
$(XGETTEXT) -D $(srcdir) -n $(addprefix -k, $(GETTEXT_TRIGGERS)) $(GETTEXT_FILES)
+else
+ @echo "You don't have 'xgettext'."; exit 1
endif
- @$(mkinstalldirs) $(dir $@)
+endif # GETTEXT_FILES
+ @$(MKDIR_P) $(dir $@)
sed -e '1,18 { s/SOME DESCRIPTIVE TITLE./LANGUAGE message translation file for $(CATALOG_NAME)/;s/PACKAGE/PostgreSQL/g;s/VERSION/$(MAJORVERSION)/g;s/YEAR/'`date +%Y`'/g; }' messages.po >$@
rm messages.po
-else # not XGETTEXT
- @echo "You don't have 'xgettext'."; exit 1
-endif # not XGETTEXT
# catalog name extentions must match behavior of PG_TEXTDOMAIN() in c.h
endif
installdirs-po:
- $(mkinstalldirs) $(foreach lang, $(LANGUAGES), '$(DESTDIR)$(localedir)'/$(lang)/LC_MESSAGES)
+ $(if $(LANGUAGES),$(MKDIR_P) $(foreach lang, $(LANGUAGES), '$(DESTDIR)$(localedir)'/$(lang)/LC_MESSAGES),:)
uninstall-po:
- rm -f $(foreach lang, $(LANGUAGES), '$(DESTDIR)$(localedir)'/$(lang)/LC_MESSAGES/$(CATALOG_NAME)$(SO_MAJOR_VERSION)-$(MAJORVERSION).mo)
+ $(if $(LANGUAGES),rm -f $(foreach lang, $(LANGUAGES), '$(DESTDIR)$(localedir)'/$(lang)/LC_MESSAGES/$(CATALOG_NAME)$(SO_MAJOR_VERSION)-$(MAJORVERSION).mo),:)
clean-po:
# For performance reasons, only calculate these when the user actually
# requested update-po or a specific file.
ifneq (,$(filter update-po %.po.new,$(MAKECMDGOALS)))
-ALL_LANGUAGES := $(shell find $(top_srcdir) -name '*.po' -printf '%f\n' | sort -u | sed 's/\.po$$//')
-all_compendia := $(shell find $(top_srcdir) -name '*.po' -printf '%p ')
+ALL_LANGUAGES := $(shell find $(top_srcdir) -name '*.po' -print | sed 's,^.*/\([^/]*\).po$$,\1,' | sort -u)
+all_compendia := $(shell find $(top_srcdir) -name '*.po' -print)
else
ALL_LANGUAGES = $(AVAIL_LANGUAGES)
all_compendia = FORCE
$(AVAIL_LANGUAGES:%=po/%.po.new): po/%.po.new: po/%.po po/$(CATALOG_NAME).pot $(all_compendia)
$(MSGMERGE) $(word 1, $^) $(word 2,$^) -o $@ $(addprefix --compendium=,$(filter %/$*.po,$(wordlist 3,$(words $^),$^)))
-# For languages not yet available, merge against empty file, to pick
-# up translations from the compendia.
+# For languages not yet available, merge against oneself, to pick
+# up translations from the compendia. (Merging against /dev/null
+# doesn't work so well; it inserts the headers from the first-named
+# compendium.)
po/%.po.new: po/$(CATALOG_NAME).pot $(all_compendia)
- $(MSGMERGE) /dev/null $(word 1,$^) -o $@ $(addprefix --compendium=,$(filter %/$*.po,$(wordlist 2,$(words $^),$^)))
+ $(MSGMERGE) $(word 1,$^) $(word 1,$^) -o $@ $(addprefix --compendium=,$(filter %/$*.po,$(wordlist 2,$(words $^),$^)))
all: all-po
.PHONY: all-po install-po installdirs-po uninstall-po clean-po \
maintainer-check-po init-po update-po
-.SILENT: installdirs-po