Add the possibility to pass --flag arguments to xgettext calls
authorPeter Eisentraut <[email protected]>
Sun, 26 Jun 2011 21:13:10 +0000 (00:13 +0300)
committerPeter Eisentraut <[email protected]>
Sun, 26 Jun 2011 21:37:21 +0000 (00:37 +0300)
The --flag argument can be used to tell xgettext the arguments of
which functions should be flagged with c-format in the PO files,
instead of guessing based on the presence of format specifiers, which
fails if no format specifiers are present but the translation
accidentally introduces one.

Appropriate flag settings have been added for each message catalog.

based on a patch by Christoph Berg for bug #6066

src/backend/nls.mk
src/bin/pg_dump/nls.mk
src/bin/psql/nls.mk
src/interfaces/ecpg/ecpglib/nls.mk
src/interfaces/ecpg/preproc/nls.mk
src/interfaces/libpq/nls.mk
src/nls-global.mk
src/pl/plperl/nls.mk
src/pl/plpgsql/src/nls.mk
src/pl/plpython/nls.mk
src/pl/tcl/nls.mk

index 7672d67090e144a5b5fac495ee568d660a0fc63b..297d1cb1902a3af5ba417d11105b975e92e3204a 100644 (file)
@@ -5,6 +5,11 @@ GETTEXT_FILES    = + gettext-files
 GETTEXT_TRIGGERS = $(BACKEND_COMMON_GETTEXT_TRIGGERS) \
     GUC_check_errmsg GUC_check_errdetail GUC_check_errhint \
     write_stderr yyerror parser_yyerror
+GETTEXT_FLAGS    = $(BACKEND_COMMON_GETTEXT_FLAGS) \
+    GUC_check_errmsg:1:c-format \
+    GUC_check_errdetail:1:c-format \
+    GUC_check_errhint:1:c-format \
+    write_stderr:1:c-format
 
 gettext-files: distprep
    find $(srcdir)/ $(srcdir)/../port/ -name '*.c' -print >$@
index 48a4990163b5b8f0a391e4c8fabfecd2476ef7c1..a4824af1b8caeca95337f6c7b43de3fea655ac66 100644 (file)
@@ -7,3 +7,8 @@ GETTEXT_FILES    = pg_dump.c common.c pg_backup_archiver.c pg_backup_custom.c \
                    ../../port/exec.c
 GETTEXT_TRIGGERS = write_msg:2 die_horribly:3 exit_horribly:3 simple_prompt \
                    ExecuteSqlCommand:3 ahlog:3
+GETTEXT_FLAGS  = \
+    write_msg:2:c-format \
+    die_horribly:3:c-format \
+    exit_horribly:3:c-format \
+    ahlog:3:c-format
index 38d9b157f2c6f7e98ea37905cca6fc1ae4b3eb2f..8d744348f0b7278c595a937331c95370fb6f7b96 100644 (file)
@@ -5,3 +5,4 @@ GETTEXT_FILES    = command.c common.c copy.c help.c input.c large_obj.c \
                    mainloop.c print.c startup.c describe.c sql_help.h sql_help.c \
                    ../../port/exec.c
 GETTEXT_TRIGGERS = N_ psql_error simple_prompt
+GETTEXT_FLAGS    = psql_error:1:c-format
index 2c92237bd7f05de420567b47fe5438b2f760cb18..a127e636516347e2e2c94b5b5cef139616a85355 100644 (file)
@@ -3,3 +3,4 @@ CATALOG_NAME     = ecpglib
 AVAIL_LANGUAGES  = de es fr it ja pt_BR tr zh_CN
 GETTEXT_FILES    = connect.c error.c execute.c misc.c
 GETTEXT_TRIGGERS = ecpg_gettext
+GETTEXT_FLAGS    = ecpg_gettext:1:pass-c-format
index 2c66d7833afc1872f4c7b23682841163b0dee265..2a10b7668d79e5a7885fe5f5a8ba643bb09ed3c3 100644 (file)
@@ -3,3 +3,4 @@ CATALOG_NAME     = ecpg
 AVAIL_LANGUAGES  = de es fr it ja ko pt_BR tr zh_CN zh_TW
 GETTEXT_FILES    = descriptor.c ecpg.c pgc.c preproc.c type.c variable.c
 GETTEXT_TRIGGERS = mmerror:3
+GETTEXT_FLAGS    = mmerror:3:c-format
index ae0911e850d6854d633db51f9be25d64ad98a0c6..2cd1efa9b03139c13b594e79d59e270aba45d13b 100644 (file)
@@ -3,3 +3,4 @@ CATALOG_NAME     = libpq
 AVAIL_LANGUAGES  = cs de es fr it ja ko pt_BR ru sv ta tr zh_CN zh_TW
 GETTEXT_FILES    = fe-auth.c fe-connect.c fe-exec.c fe-lobj.c fe-misc.c fe-protocol2.c fe-protocol3.c fe-secure.c
 GETTEXT_TRIGGERS = libpq_gettext pqInternalNotice:2
+GETTEXT_FLAGS    = libpq_gettext:1:pass-c-format pqInternalNotice:2:c-format
index dda3e29a7a328d55029ff07947d7de912c9f4d12..c95c3a496fa19d56f5fb7b8e4a58679a1486c76c 100644 (file)
@@ -12,6 +12,9 @@
 # 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.
 #
@@ -41,6 +44,7 @@ endif
 
 # _ is defined in c.h, so it's global
 GETTEXT_TRIGGERS += _
+GETTEXT_FLAGS    += _:1:pass-c-format
 
 
 # common settings that apply to backend and all backend modules
@@ -49,6 +53,11 @@ BACKEND_COMMON_GETTEXT_TRIGGERS = \
     errdetail errdetail_log errdetail_plural:1,2 \
     errhint \
     errcontext
+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)
@@ -59,7 +68,7 @@ all-po: $(MO_FILES)
 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 $<
+   $(XGETTEXT) -D $(srcdir) -n $(addprefix -k, $(GETTEXT_TRIGGERS)) $(addprefix --flag=, $(GETTEXT_FLAGS)) -f $<
 else
    @echo "You don't have 'xgettext'."; exit 1
 endif
@@ -68,7 +77,7 @@ 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)
+   $(XGETTEXT) -D $(srcdir) -n $(addprefix -k, $(GETTEXT_TRIGGERS)) $(addprefix --flag=, $(GETTEXT_FLAGS)) $(GETTEXT_FILES)
 else
    @echo "You don't have 'xgettext'."; exit 1
 endif
index 57846d159fbf09557277a3fdefe12c9795a167ca..26041e53f7d5441f0bb7217f75b67ed50e3b2637 100644 (file)
@@ -3,3 +3,4 @@ CATALOG_NAME     = plperl
 AVAIL_LANGUAGES  = de es fr it ja pt_BR ro tr zh_CN zh_TW
 GETTEXT_FILES    = plperl.c SPI.c
 GETTEXT_TRIGGERS = $(BACKEND_COMMON_GETTEXT_TRIGGERS)
+GETTEXT_FLAGS    = $(BACKEND_COMMON_GETTEXT_FLAGS)
index 98f25ea7e54ed7250a406752e2a528cc4a49ac9f..5be1859a90302c3a52790ad11a1345b4b46c6a74 100644 (file)
@@ -3,3 +3,4 @@ CATALOG_NAME     = plpgsql
 AVAIL_LANGUAGES  = de es fr it ja ko pt_BR ro zh_CN zh_TW
 GETTEXT_FILES    = pl_comp.c pl_exec.c pl_gram.c pl_funcs.c pl_handler.c pl_scanner.c
 GETTEXT_TRIGGERS = $(BACKEND_COMMON_GETTEXT_TRIGGERS) yyerror plpgsql_yyerror
+GETTEXT_FLAGS    = $(BACKEND_COMMON_GETTEXT_FLAGS)
index 0fdd234ad237f6f7010f9fb9e8ed0dffb9c0fe05..27d5e7cea8f8cdbbcad340eaeabf89d3165ed602 100644 (file)
@@ -3,3 +3,8 @@ CATALOG_NAME     = plpython
 AVAIL_LANGUAGES  = de es fr it ja pt_BR ro tr zh_CN zh_TW
 GETTEXT_FILES    = plpython.c
 GETTEXT_TRIGGERS = $(BACKEND_COMMON_GETTEXT_TRIGGERS) PLy_elog:2 PLy_exception_set:2 PLy_exception_set_plural:2,3
+GETTEXT_FLAGS    = $(BACKEND_COMMON_GETTEXT_FLAGS) \
+    PLy_elog:2:c-format \
+    PLy_exception_set:2:c-format \
+    PLy_exception_set_plural:2:c-format \
+    PLy_exception_set_plural:3:c-format
index be95c15a04c682c373e05dd49428ac8ceb693d60..bb63f28b8c0d2544af79c7648bf2cc13fd4dd489 100644 (file)
@@ -3,3 +3,4 @@ CATALOG_NAME     = pltcl
 AVAIL_LANGUAGES  = de es fr it ja pt_BR ro tr zh_CN zh_TW
 GETTEXT_FILES    = pltcl.c
 GETTEXT_TRIGGERS = $(BACKEND_COMMON_GETTEXT_TRIGGERS)
+GETTEXT_FLAGS    = $(BACKEND_COMMON_GETTEXT_FLAGS)