]> granicus.if.org Git - postgresql/blobdiff - src/nls-global.mk
COPY: use pg_plan_query() instead of planner()
[postgresql] / src / nls-global.mk
index 72b774cb67278885838efe3ccb2227fc281764dd..b90a3f3889a9ceb2015b8c8da2fa8e742fdcd8d0 100644 (file)
@@ -1,4 +1,4 @@
-# $Header: /cvsroot/pgsql/src/nls-global.mk,v 1.6 2002/08/29 22:13:01 petere Exp $
+# src/nls-global.mk
 
 # Common rules for Native Language Support (NLS)
 #
@@ -6,12 +6,15 @@
 # needs to contain a file 'nls.mk' with the following make variable
 # assignments:
 #
-# CATALOG_NAME         -- name of the message catalog (xxx.po); probably
+# CATALOG_NAME          -- name of the message catalog (xxx.po); probably
 #                          name of the program
-# AVAIL_LANGUAGES      -- list of languages that are provided/supported
+# 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
+# GETTEXT_FLAGS         -- (optional) list of gettext --flag arguments to mark
+#                          function arguments that contain C format strings
+#                          (functions must be listed in TRIGGERS and FLAGS)
 #
 # That's all, the rest is done here, if --enable-nls was specified.
 #
@@ -33,92 +36,122 @@ LANGUAGES = $(AVAIL_LANGUAGES)
 endif
 
 PO_FILES = $(addprefix po/, $(addsuffix .po, $(LANGUAGES)))
+ALL_PO_FILES = $(addprefix po/, $(addsuffix .po, $(AVAIL_LANGUAGES)))
 MO_FILES = $(addprefix po/, $(addsuffix .mo, $(LANGUAGES)))
 
 ifdef XGETTEXT
-XGETTEXT += --foreign-user -ctranslator
+XGETTEXT += -ctranslator --copyright-holder='PostgreSQL Global Development Group' --msgid-bugs-address=pgsql-bugs@postgresql.org --no-wrap --sort-by-file --package-name='$(CATALOG_NAME) (PostgreSQL)' --package-version='$(MAJORVERSION)'
 endif
 
+ifdef MSGMERGE
+MSGMERGE += --no-wrap --previous --sort-by-file
+endif
+
+# _ is defined in c.h, so it's global
+GETTEXT_TRIGGERS += _
+GETTEXT_FLAGS    += _:1:pass-c-format
 
-all-po: $(MO_FILES)
 
-distprep: $(srcdir)/po/$(CATALOG_NAME).pot
+# 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 \
+    XactLockTableWait:4 \
+    MultiXactIdWait:6 \
+    ConditionalMultiXactIdWait:6
+BACKEND_COMMON_GETTEXT_FLAGS = \
+    errmsg:1:c-format errmsg_plural:1:c-format errmsg_plural:2:c-format \
+    errdetail:1:c-format errdetail_log:1:c-format errdetail_plural:1:c-format errdetail_plural:2:c-format \
+    errhint:1:c-format \
+    errcontext:1:c-format
+
+
+all-po: $(MO_FILES)
 
 %.mo: %.po
-       $(MSGFMT) -o $@ $<
+       $(MSGFMT) $(MSGFMT_FLAGS) -o $@ $<
 
-ifdef XGETTEXT
 ifeq ($(word 1,$(GETTEXT_FILES)),+)
-$(srcdir)/po/$(CATALOG_NAME).pot: $(word 2, $(GETTEXT_FILES))
-       $(XGETTEXT) -D $(srcdir) -n $(addprefix -k, $(GETTEXT_TRIGGERS)) -f $<
+po/$(CATALOG_NAME).pot: $(word 2, $(GETTEXT_FILES)) $(MAKEFILE_LIST)
+ifdef XGETTEXT
+       $(XGETTEXT) -D $(srcdir) -n $(addprefix -k, $(GETTEXT_TRIGGERS)) $(addprefix --flag=, $(GETTEXT_FLAGS)) -f $<
 else
-$(srcdir)/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.
-       $(XGETTEXT) -D $(srcdir) -n $(addprefix -k, $(GETTEXT_TRIGGERS)) $(GETTEXT_FILES)
-endif
-       @$(mkinstalldirs) $(dir $@)
-       mv messages.po $@
-else # not XGETTEXT
+ifdef XGETTEXT
+       $(XGETTEXT) -D $(srcdir) -n $(addprefix -k, $(GETTEXT_TRIGGERS)) $(addprefix --flag=, $(GETTEXT_FLAGS)) $(GETTEXT_FILES)
+else
        @echo "You don't have 'xgettext'."; exit 1
-endif # not XGETTEXT
+endif
+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
 
 
+# catalog name extensions must match behavior of PG_TEXTDOMAIN() in c.h
 install-po: all-po installdirs-po
+ifneq (,$(LANGUAGES))
        for lang in $(LANGUAGES); do \
-         $(INSTALL_DATA) po/$$lang.mo $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(CATALOG_NAME).mo || exit 1; \
+         $(INSTALL_DATA) po/$$lang.mo '$(DESTDIR)$(localedir)'/$$lang/LC_MESSAGES/$(CATALOG_NAME)$(SO_MAJOR_VERSION)-$(MAJORVERSION).mo || exit 1; \
        done
+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).mo)
+       $(if $(LANGUAGES),rm -f $(foreach lang, $(LANGUAGES), '$(DESTDIR)$(localedir)'/$(lang)/LC_MESSAGES/$(CATALOG_NAME)$(SO_MAJOR_VERSION)-$(MAJORVERSION).mo),:)
 
 
 clean-po:
-       rm -f $(MO_FILES)
-       @rm -f $(addsuffix .old, $(PO_FILES))
+       $(if $(MO_FILES),rm -f $(MO_FILES))
+       @$(if $(wildcard po/*.po.new),rm -f po/*.po.new)
+       rm -f po/$(CATALOG_NAME).pot
 
-maintainer-clean-po: clean-po
-       rm -f $(srcdir)/po/$(CATALOG_NAME).pot
 
+init-po: po/$(CATALOG_NAME).pot
 
-maintainer-check-po: $(PO_FILES)
-       for file in $^; do \
-         $(MSGFMT) -c -v -o /dev/null $$file || exit 1; \
-       done
 
+# 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' -print | sed 's,^.*/\([^/]*\).po$$,\1,' | LC_ALL=C sort -u)
+all_compendia := $(shell find $(top_srcdir) -name '*.po' -print | LC_ALL=C sort)
+else
+ALL_LANGUAGES = $(AVAIL_LANGUAGES)
+all_compendia = FORCE
+FORCE:
+endif
 
-init-po: $(srcdir)/po/$(CATALOG_NAME).pot
+ifdef WANTED_LANGUAGES
+ALL_LANGUAGES := $(filter $(WANTED_LANGUAGES), $(ALL_LANGUAGES))
+endif
 
+update-po: $(ALL_LANGUAGES:%=po/%.po.new)
 
-update-po: $(srcdir)/po/$(CATALOG_NAME).pot
-ifdef MSGMERGE
-       @for lang in $(LANGUAGES); do \
-         echo "merging $$lang:"; \
-         if $(MSGMERGE) $(srcdir)/po/$$lang.po $< -o po/$$lang.po.new; \
-         then \
-           mv $(srcdir)/po/$$lang.po po/$$lang.po.old; \
-           mv po/$$lang.po.new $(srcdir)/po/$$lang.po; \
-         else \
-           echo "msgmerge for $$lang failed"; \
-           rm -f po/$$lang.po.new; \
-         fi; \
-       done
-else
-       @echo "You don't have 'msgmerge'." ; exit 1
-endif
+$(AVAIL_LANGUAGES:%=po/%.po.new): po/%.po.new: po/%.po po/$(CATALOG_NAME).pot $(all_compendia)
+       $(MSGMERGE) --lang=$* $(word 1, $^) $(word 2,$^) -o $@ $(addprefix --compendium=,$(filter %/$*.po,$(wordlist 3,$(words $^),$^)))
+
+# 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) --lang=$* $(word 1,$^) $(word 1,$^) -o $@ $(addprefix --compendium=,$(filter %/$*.po,$(wordlist 2,$(words $^),$^)))
 
 
 all: all-po
 install: install-po
 installdirs: installdirs-po
 uninstall: uninstall-po
-clean distclean: clean-po
-maintainer-clean: maintainer-clean-po
-maintainer-check: maintainer-check-po
+clean distclean maintainer-clean: clean-po
 
 .PHONY: all-po install-po installdirs-po uninstall-po clean-po \
-        maintainer-clean-po maintainer-check-po init-po update-po
-.SILENT: installdirs-po
+        init-po update-po