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 # AVAIL_LANGUAGES -- list of languages that are provided/supported
12 # GETTEXT_FILES -- list of source files that contain message strings
13 # GETTEXT_TRIGGERS -- (optional) list of functions that contain
14 # translatable strings
16 # That's all, the rest is done here, if --enable-nls was specified.
18 # The only user-visible targets here are 'init-po', to make an initial
19 # "blank" catalog from program sources, and 'update-po', which is to
20 # be called if the messages in the program source have changed, in
21 # order to merge the changes into the existing .po files.
24 # existence checked by Makefile.global; otherwise we won't get here
25 include $(srcdir)/nls.mk
27 # If user specified the languages he wants in --enable-nls=LANGUAGES,
28 # filter out the rest. Else use all available ones.
29 ifdef WANTED_LANGUAGES
30 LANGUAGES
= $(filter $(WANTED_LANGUAGES
), $(AVAIL_LANGUAGES
))
32 LANGUAGES
= $(AVAIL_LANGUAGES
)
35 PO_FILES
= $(addprefix po
/, $(addsuffix .po
, $(LANGUAGES
)))
36 MO_FILES
= $(addprefix po
/, $(addsuffix .mo
, $(LANGUAGES
)))
39 XGETTEXT
+= -ctranslator
--copyright-holder
='PostgreSQL Global Development Group' --msgid-bugs-address
=pgsql-bugs@postgresql.org
49 ifeq ($(word 1,$(GETTEXT_FILES
)),+)
50 po
/$(CATALOG_NAME
).pot
: $(word 2, $(GETTEXT_FILES
)) $(MAKEFILE_LIST
)
51 $(XGETTEXT
) -D
$(srcdir) -n
$(addprefix -k
, $(GETTEXT_TRIGGERS
)) -f
$<
53 po
/$(CATALOG_NAME
).pot
: $(GETTEXT_FILES
) $(MAKEFILE_LIST
)
54 # Change to srcdir explicitly, don't rely on $^. That way we get
55 # consistent #: file references in the po files.
56 $(XGETTEXT
) -D
$(srcdir) -n
$(addprefix -k
, $(GETTEXT_TRIGGERS
)) $(GETTEXT_FILES
)
58 @
$(mkinstalldirs
) $(dir $@
)
59 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
>$@
62 @echo
"You don't have 'xgettext'."; exit
1
66 # catalog name extentions must match behavior of PG_TEXTDOMAIN() in c.h
67 install-po
: all-po installdirs-po
69 for lang in
$(LANGUAGES
); do \
70 $(INSTALL_DATA
) po
/$$lang.mo
'$(DESTDIR)$(localedir)'/$$lang/LC_MESSAGES
/$(CATALOG_NAME
)$(SO_MAJOR_VERSION
)-$(MAJORVERSION
).mo || exit
1; \
75 $(mkinstalldirs
) $(foreach lang
, $(LANGUAGES
), '$(DESTDIR)$(localedir)'/$(lang
)/LC_MESSAGES
)
78 rm -f
$(foreach lang
, $(LANGUAGES
), '$(DESTDIR)$(localedir)'/$(lang
)/LC_MESSAGES
/$(CATALOG_NAME
)$(SO_MAJOR_VERSION
)-$(MAJORVERSION
).mo
)
82 $(if
$(MO_FILES
),rm -f
$(MO_FILES
))
83 @
$(if
$(wildcard po
/*.po.new
),rm -f po
/*.po.new
)
84 rm -f po
/$(CATALOG_NAME
).pot
87 maintainer-check-po
: $(PO_FILES
)
89 $(MSGFMT
) -c
-v
-o
/dev
/null
$$file || exit
1; \
93 init-po
: po
/$(CATALOG_NAME
).pot
96 # For performance reasons, only calculate these when the user actually
97 # requested update-po or a specific file.
98 ifneq (,$(filter update-po
%.po.new
,$(MAKECMDGOALS
)))
99 ALL_LANGUAGES
:= $(shell find
$(top_srcdir
) -name
'*.po' -print | sed
's,^.*/\([^/]*\).po$$,\1,' |
sort -u
)
100 all_compendia
:= $(shell find
$(top_srcdir
) -name
'*.po' -print)
102 ALL_LANGUAGES
= $(AVAIL_LANGUAGES
)
103 all_compendia
= FORCE
107 ifdef WANTED_LANGUAGES
108 ALL_LANGUAGES
:= $(filter $(WANTED_LANGUAGES
), $(ALL_LANGUAGES
))
111 update-po
: $(ALL_LANGUAGES
:%=po
/%.po.new
)
113 $(AVAIL_LANGUAGES
:%=po
/%.po.new
): po
/%.po.new
: po
/%.po po
/$(CATALOG_NAME
).pot
$(all_compendia
)
114 $(MSGMERGE
) $(word 1, $^
) $(word 2,$^
) -o
$@
$(addprefix --compendium
=,$(filter %/$*.po
,$(wordlist
3,$(words $^
),$^
)))
116 # For languages not yet available, merge against oneself, to pick
117 # up translations from the compendia. (Merging against /dev/null
118 # doesn't work so well; it inserts the headers from the first-named
120 po
/%.po.new
: po
/$(CATALOG_NAME
).pot
$(all_compendia
)
121 $(MSGMERGE
) $(word 1,$^
) $(word 1,$^
) -o
$@
$(addprefix --compendium
=,$(filter %/$*.po
,$(wordlist
2,$(words $^
),$^
)))
126 installdirs: installdirs-po
127 uninstall: uninstall-po
128 clean distclean maintainer-clean
: clean-po
129 maintainer-check
: maintainer-check-po
131 .PHONY
: all-po install-po installdirs-po uninstall-po clean-po \
132 maintainer-check-po init-po update-po
133 .SILENT
: installdirs-po