3 # Common rules for Native Language Support (NLS)
5 # If some subdirectory of the source tree wants to provide NLS, it
6 # needs to contain a file 'nls.mk' with the following make variable
9 # CATALOG_NAME -- name of the message catalog (xxx.po); probably
11 # GETTEXT_FILES -- list of source files that contain message strings
12 # GETTEXT_TRIGGERS -- (optional) list of functions that contain
13 # translatable strings
14 # GETTEXT_FLAGS -- (optional) list of gettext --flag arguments to mark
15 # function arguments that contain C format strings
16 # (functions must be listed in TRIGGERS and FLAGS)
18 # Also, provide a text file 'po/LINGUAS' with a space-separated list
19 # of languages that are provided/supported.
21 # That's all, the rest is done here, if --enable-nls was specified.
23 # The only user-visible targets here are 'init-po', to make an initial
24 # "blank" catalog from program sources, and 'update-po', which is to
25 # be called if the messages in the program source have changed, in
26 # order to merge the changes into the existing .po files.
29 # existence checked by Makefile.global; otherwise we won't get here
30 include $(srcdir)/nls.mk
32 AVAIL_LANGUAGES
:= $(shell cat
$(srcdir)/po
/LINGUAS
)
34 # If user specified the languages he wants in --enable-nls=LANGUAGES,
35 # filter out the rest. Else use all available ones.
36 ifdef WANTED_LANGUAGES
37 LANGUAGES
= $(filter $(WANTED_LANGUAGES
), $(AVAIL_LANGUAGES
))
39 LANGUAGES
= $(AVAIL_LANGUAGES
)
42 PO_FILES
= $(addprefix po
/, $(addsuffix .po
, $(LANGUAGES
)))
43 ALL_PO_FILES
= $(addprefix po
/, $(addsuffix .po
, $(AVAIL_LANGUAGES
)))
44 MO_FILES
= $(addprefix po
/, $(addsuffix .mo
, $(LANGUAGES
)))
47 XGETTEXT
+= -ctranslator
--copyright-holder
='PostgreSQL Global Development Group' --msgid-bugs-address
=pgsql-bugs@lists.postgresql.org
--no-wrap
--sort-by-file
--package-name
='$(CATALOG_NAME) (PostgreSQL)' --package-version
='$(MAJORVERSION)'
51 MSGMERGE
+= --no-wrap
--previous
--sort-by-file
54 # _ is defined in c.h, so it's global
56 GETTEXT_FLAGS
+= _
:1:pass-c-format
59 # common settings that apply to backend and all backend modules
60 BACKEND_COMMON_GETTEXT_TRIGGERS
= \
61 $(FRONTEND_COMMON_GETTEXT_TRIGGERS
) \
62 errmsg errmsg_plural
:1,2 \
63 errdetail errdetail_log errdetail_plural
:1,2 \
64 errhint errhint_plural
:1,2 \
68 ConditionalMultiXactIdWait
:6
69 BACKEND_COMMON_GETTEXT_FLAGS
= \
70 $(FRONTEND_COMMON_GETTEXT_FLAGS
) \
71 errmsg
:1:c-format errmsg_plural
:1:c-format errmsg_plural
:2:c-format \
72 errdetail
:1:c-format errdetail_log
:1:c-format errdetail_plural
:1:c-format errdetail_plural
:2:c-format \
73 errhint
:1:c-format errhint_plural
:1:c-format errhint_plural
:2:c-format \
76 FRONTEND_COMMON_GETTEXT_FILES
= $(top_srcdir
)/src
/common
/logging.c
78 FRONTEND_COMMON_GETTEXT_TRIGGERS
= \
79 pg_log_error pg_log_error_detail pg_log_error_hint \
80 pg_log_warning pg_log_warning_detail pg_log_warning_hint \
81 pg_log_info pg_log_info_detail pg_log_info_hint \
82 pg_fatal pg_log_generic
:3 pg_log_generic_v
:3
84 FRONTEND_COMMON_GETTEXT_FLAGS
= \
85 pg_log_error
:1:c-format pg_log_error_detail
:1:c-format pg_log_error_hint
:1:c-format \
86 pg_log_warning
:1:c-format pg_log_warning_detail
:1:c-format pg_log_warning_hint
:1:c-format \
87 pg_log_info
:1:c-format pg_log_info_detail
:1:c-format pg_log_info_hint
:1:c-format \
88 pg_fatal
:1:c-format pg_log_generic
:3:c-format pg_log_generic_v
:3:c-format
94 $(MSGFMT
) $(MSGFMT_FLAGS
) -o
$@
$<
96 ifeq ($(word 1,$(GETTEXT_FILES
)),+)
97 po
/$(CATALOG_NAME
).pot
: $(word 2, $(GETTEXT_FILES
)) $(MAKEFILE_LIST
)
99 $(XGETTEXT
) -D
$(srcdir) -D .
-n
$(addprefix -k
, $(GETTEXT_TRIGGERS
)) $(addprefix --flag
=, $(GETTEXT_FLAGS
)) -f
$<
101 @echo
"You don't have 'xgettext'."; exit
1
104 po
/$(CATALOG_NAME
).pot
: $(GETTEXT_FILES
) $(MAKEFILE_LIST
)
105 # Change to srcdir explicitly, don't rely on $^. That way we get
106 # consistent #: file references in the po files.
108 $(XGETTEXT
) -D
$(srcdir) -D .
-n
$(addprefix -k
, $(GETTEXT_TRIGGERS
)) $(addprefix --flag
=, $(GETTEXT_FLAGS
)) $(GETTEXT_FILES
)
110 @echo
"You don't have 'xgettext'."; exit
1
112 endif # GETTEXT_FILES
113 @
$(MKDIR_P
) $(dir $@
)
114 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
>$@
118 # catalog name extensions must match behavior of PG_TEXTDOMAIN() in c.h
119 install-po
: all-po installdirs-po
120 ifneq (,$(LANGUAGES
))
121 for lang in
$(LANGUAGES
); do \
122 $(INSTALL_DATA
) po
/$$lang.mo
'$(DESTDIR)$(localedir)'/$$lang/LC_MESSAGES
/$(CATALOG_NAME
)$(SO_MAJOR_VERSION
)-$(MAJORVERSION
).mo || exit
1; \
127 $(if
$(LANGUAGES
),$(MKDIR_P
) $(foreach lang
, $(LANGUAGES
), '$(DESTDIR)$(localedir)'/$(lang
)/LC_MESSAGES
),:)
130 $(if
$(LANGUAGES
),rm -f
$(foreach lang
, $(LANGUAGES
), '$(DESTDIR)$(localedir)'/$(lang
)/LC_MESSAGES
/$(CATALOG_NAME
)$(SO_MAJOR_VERSION
)-$(MAJORVERSION
).mo
),:)
134 $(if
$(MO_FILES
),rm -f
$(MO_FILES
))
135 @
$(if
$(wildcard po
/*.po.new
),rm -f po
/*.po.new
)
136 rm -f po
/$(CATALOG_NAME
).pot
139 init-po
: po
/$(CATALOG_NAME
).pot
142 # For performance reasons, only calculate these when the user actually
143 # requested update-po or a specific file.
144 ifneq (,$(filter update-po
%.po.new
,$(MAKECMDGOALS
)))
145 ALL_LANGUAGES
:= $(shell find
$(top_srcdir
) -name
'*.po' -print | sed
's,^.*/\([^/]*\).po$$,\1,' | LC_ALL
=C
sort -u
)
146 all_compendia
:= $(shell find
$(top_srcdir
) -name
'*.po' -print | LC_ALL
=C
sort)
148 ALL_LANGUAGES
= $(AVAIL_LANGUAGES
)
149 all_compendia
= FORCE
153 ifdef WANTED_LANGUAGES
154 ALL_LANGUAGES
:= $(filter $(WANTED_LANGUAGES
), $(ALL_LANGUAGES
))
157 update-po
: $(ALL_LANGUAGES
:%=po
/%.po.new
)
159 $(AVAIL_LANGUAGES
:%=po
/%.po.new
): po
/%.po.new
: po
/%.po po
/$(CATALOG_NAME
).pot
$(all_compendia
)
160 $(MSGMERGE
) --lang
=$* $(word 1, $^
) $(word 2,$^
) -o
$@
$(addprefix --compendium
=,$(filter %/$*.po
,$(wordlist
3,$(words $^
),$^
)))
162 # For languages not yet available, merge against oneself, to pick
163 # up translations from the compendia. (Merging against /dev/null
164 # doesn't work so well; it inserts the headers from the first-named
166 po
/%.po.new
: po
/$(CATALOG_NAME
).pot
$(all_compendia
)
167 $(MSGMERGE
) --lang
=$* $(word 1,$^
) $(word 1,$^
) -o
$@
$(addprefix --compendium
=,$(filter %/$*.po
,$(wordlist
2,$(words $^
),$^
)))
172 installdirs: installdirs-po
173 uninstall: uninstall-po
174 clean distclean: clean-po
176 .PHONY
: all-po install-po installdirs-po uninstall-po clean-po \