Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit cb5a7bc

Browse files
committed
Add the possibility to pass --flag arguments to xgettext calls
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
1 parent 7a5a843 commit cb5a7bc

File tree

11 files changed

+33
-2
lines changed

11 files changed

+33
-2
lines changed

src/backend/nls.mk

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ GETTEXT_FILES = + gettext-files
55
GETTEXT_TRIGGERS = $(BACKEND_COMMON_GETTEXT_TRIGGERS) \
66
GUC_check_errmsg GUC_check_errdetail GUC_check_errhint \
77
write_stderr yyerror parser_yyerror
8+
GETTEXT_FLAGS = $(BACKEND_COMMON_GETTEXT_FLAGS) \
9+
GUC_check_errmsg:1:c-format \
10+
GUC_check_errdetail:1:c-format \
11+
GUC_check_errhint:1:c-format \
12+
write_stderr:1:c-format
813

914
gettext-files: distprep
1015
find $(srcdir)/ $(srcdir)/../port/ -name '*.c' -print >$@

src/bin/pg_dump/nls.mk

+5
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@ GETTEXT_FILES = pg_dump.c common.c pg_backup_archiver.c pg_backup_custom.c \
77
../../port/exec.c
88
GETTEXT_TRIGGERS = write_msg:2 die_horribly:3 exit_horribly:3 simple_prompt \
99
ExecuteSqlCommand:3 ahlog:3
10+
GETTEXT_FLAGS = \
11+
write_msg:2:c-format \
12+
die_horribly:3:c-format \
13+
exit_horribly:3:c-format \
14+
ahlog:3:c-format

src/bin/psql/nls.mk

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ GETTEXT_FILES = command.c common.c copy.c help.c input.c large_obj.c \
55
mainloop.c print.c startup.c describe.c sql_help.h sql_help.c \
66
../../port/exec.c
77
GETTEXT_TRIGGERS = N_ psql_error simple_prompt
8+
GETTEXT_FLAGS = psql_error:1:c-format

src/interfaces/ecpg/ecpglib/nls.mk

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ CATALOG_NAME = ecpglib
33
AVAIL_LANGUAGES = de es fr it ja pt_BR tr zh_CN
44
GETTEXT_FILES = connect.c error.c execute.c misc.c
55
GETTEXT_TRIGGERS = ecpg_gettext
6+
GETTEXT_FLAGS = ecpg_gettext:1:pass-c-format

src/interfaces/ecpg/preproc/nls.mk

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ CATALOG_NAME = ecpg
33
AVAIL_LANGUAGES = de es fr it ja ko pt_BR tr zh_CN zh_TW
44
GETTEXT_FILES = descriptor.c ecpg.c pgc.c preproc.c type.c variable.c
55
GETTEXT_TRIGGERS = mmerror:3
6+
GETTEXT_FLAGS = mmerror:3:c-format

src/interfaces/libpq/nls.mk

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ CATALOG_NAME = libpq
33
AVAIL_LANGUAGES = cs de es fr it ja ko pt_BR ru sv ta tr zh_CN zh_TW
44
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
55
GETTEXT_TRIGGERS = libpq_gettext pqInternalNotice:2
6+
GETTEXT_FLAGS = libpq_gettext:1:pass-c-format pqInternalNotice:2:c-format

src/nls-global.mk

+11-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
# GETTEXT_FILES -- list of source files that contain message strings
1313
# GETTEXT_TRIGGERS -- (optional) list of functions that contain
1414
# translatable strings
15+
# GETTEXT_FLAGS -- (optional) list of gettext --flag arguments to mark
16+
# function arguments that contain C format strings
17+
# (functions must be listed in TRIGGERS and FLAGS)
1518
#
1619
# That's all, the rest is done here, if --enable-nls was specified.
1720
#
@@ -41,6 +44,7 @@ endif
4144

4245
# _ is defined in c.h, so it's global
4346
GETTEXT_TRIGGERS += _
47+
GETTEXT_FLAGS += _:1:pass-c-format
4448

4549

4650
# common settings that apply to backend and all backend modules
@@ -49,6 +53,11 @@ BACKEND_COMMON_GETTEXT_TRIGGERS = \
4953
errdetail errdetail_log errdetail_plural:1,2 \
5054
errhint \
5155
errcontext
56+
BACKEND_COMMON_GETTEXT_FLAGS = \
57+
errmsg:1:c-format errmsg_plural:1:c-format errmsg_plural:2:c-format \
58+
errdetail:1:c-format errdetail_log:1:c-format errdetail_plural:1:c-format errdetail_plural:2:c-format \
59+
errhint:1:c-format \
60+
errcontext:1:c-format
5261

5362

5463
all-po: $(MO_FILES)
@@ -59,7 +68,7 @@ all-po: $(MO_FILES)
5968
ifeq ($(word 1,$(GETTEXT_FILES)),+)
6069
po/$(CATALOG_NAME).pot: $(word 2, $(GETTEXT_FILES)) $(MAKEFILE_LIST)
6170
ifdef XGETTEXT
62-
$(XGETTEXT) -D $(srcdir) -n $(addprefix -k, $(GETTEXT_TRIGGERS)) -f $<
71+
$(XGETTEXT) -D $(srcdir) -n $(addprefix -k, $(GETTEXT_TRIGGERS)) $(addprefix --flag=, $(GETTEXT_FLAGS)) -f $<
6372
else
6473
@echo "You don't have 'xgettext'."; exit 1
6574
endif
@@ -68,7 +77,7 @@ po/$(CATALOG_NAME).pot: $(GETTEXT_FILES) $(MAKEFILE_LIST)
6877
# Change to srcdir explicitly, don't rely on $^. That way we get
6978
# consistent #: file references in the po files.
7079
ifdef XGETTEXT
71-
$(XGETTEXT) -D $(srcdir) -n $(addprefix -k, $(GETTEXT_TRIGGERS)) $(GETTEXT_FILES)
80+
$(XGETTEXT) -D $(srcdir) -n $(addprefix -k, $(GETTEXT_TRIGGERS)) $(addprefix --flag=, $(GETTEXT_FLAGS)) $(GETTEXT_FILES)
7281
else
7382
@echo "You don't have 'xgettext'."; exit 1
7483
endif

src/pl/plperl/nls.mk

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ CATALOG_NAME = plperl
33
AVAIL_LANGUAGES = de es fr it ja pt_BR ro tr zh_CN zh_TW
44
GETTEXT_FILES = plperl.c SPI.c
55
GETTEXT_TRIGGERS = $(BACKEND_COMMON_GETTEXT_TRIGGERS)
6+
GETTEXT_FLAGS = $(BACKEND_COMMON_GETTEXT_FLAGS)

src/pl/plpgsql/src/nls.mk

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ CATALOG_NAME = plpgsql
33
AVAIL_LANGUAGES = de es fr it ja ko pt_BR ro zh_CN zh_TW
44
GETTEXT_FILES = pl_comp.c pl_exec.c pl_gram.c pl_funcs.c pl_handler.c pl_scanner.c
55
GETTEXT_TRIGGERS = $(BACKEND_COMMON_GETTEXT_TRIGGERS) yyerror plpgsql_yyerror
6+
GETTEXT_FLAGS = $(BACKEND_COMMON_GETTEXT_FLAGS)

src/pl/plpython/nls.mk

+5
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,8 @@ CATALOG_NAME = plpython
33
AVAIL_LANGUAGES = de es fr it ja pt_BR ro tr zh_CN zh_TW
44
GETTEXT_FILES = plpython.c
55
GETTEXT_TRIGGERS = $(BACKEND_COMMON_GETTEXT_TRIGGERS) PLy_elog:2 PLy_exception_set:2 PLy_exception_set_plural:2,3
6+
GETTEXT_FLAGS = $(BACKEND_COMMON_GETTEXT_FLAGS) \
7+
PLy_elog:2:c-format \
8+
PLy_exception_set:2:c-format \
9+
PLy_exception_set_plural:2:c-format \
10+
PLy_exception_set_plural:3:c-format

src/pl/tcl/nls.mk

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ CATALOG_NAME = pltcl
33
AVAIL_LANGUAGES = de es fr it ja pt_BR ro tr zh_CN zh_TW
44
GETTEXT_FILES = pltcl.c
55
GETTEXT_TRIGGERS = $(BACKEND_COMMON_GETTEXT_TRIGGERS)
6+
GETTEXT_FLAGS = $(BACKEND_COMMON_GETTEXT_FLAGS)

0 commit comments

Comments
 (0)