OSDN Git Service

Refactor common gettext triggers
[pg-rex/syncrep.git] / src / nls-global.mk
index e7e375f..dda3e29 100644 (file)
@@ -1,4 +1,4 @@
-# $PostgreSQL: pgsql/src/nls-global.mk,v 1.22 2010/05/13 14:35:28 petere Exp $
+# src/nls-global.mk
 
 # Common rules for Native Language Support (NLS)
 #
@@ -6,11 +6,11 @@
 # 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.
@@ -39,28 +39,43 @@ ifdef XGETTEXT
 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)) $(MAKEFILE_LIST)
+ifdef XGETTEXT
        $(XGETTEXT) -D $(srcdir) -n $(addprefix -k, $(GETTEXT_TRIGGERS)) -f $<
 else
+       @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
+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