Fix ancient bug in handling of to_char modifier 'TH', when used with HH.
[PostgreSQL.git] / src / nls-global.mk
blob46f469858710d73de8ad53bbc3712ecd473819da
1 # $PostgreSQL$
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
7 # assignments:
9 # CATALOG_NAME -- name of the message catalog (xxx.po); probably
10 # name of the program
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))
31 else
32 LANGUAGES = $(AVAIL_LANGUAGES)
33 endif
35 PO_FILES = $(addprefix po/, $(addsuffix .po, $(LANGUAGES)))
36 MO_FILES = $(addprefix po/, $(addsuffix .mo, $(LANGUAGES)))
38 ifdef XGETTEXT
39 XGETTEXT += -ctranslator --copyright-holder='PostgreSQL Global Development Group' --msgid-bugs-address=pgsql-bugs@postgresql.org
40 endif
43 all-po: $(MO_FILES)
45 %.mo: %.po
46 $(MSGFMT) -o $@ $<
48 ifdef XGETTEXT
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 $<
52 else
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)
57 endif
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 >$@
60 rm messages.po
61 else # not XGETTEXT
62 @echo "You don't have 'xgettext'."; exit 1
63 endif # not XGETTEXT
66 # catalog name extentions must match behavior of PG_TEXTDOMAIN() in c.h
67 install-po: all-po installdirs-po
68 ifneq (,$(LANGUAGES))
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; \
71 done
72 endif
74 installdirs-po:
75 $(mkinstalldirs) $(foreach lang, $(LANGUAGES), '$(DESTDIR)$(localedir)'/$(lang)/LC_MESSAGES)
77 uninstall-po:
78 rm -f $(foreach lang, $(LANGUAGES), '$(DESTDIR)$(localedir)'/$(lang)/LC_MESSAGES/$(CATALOG_NAME)$(SO_MAJOR_VERSION)-$(MAJORVERSION).mo)
81 clean-po:
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)
88 for file in $^; do \
89 $(MSGFMT) -c -v -o /dev/null $$file || exit 1; \
90 done
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)
101 else
102 ALL_LANGUAGES = $(AVAIL_LANGUAGES)
103 all_compendia = FORCE
104 FORCE:
105 endif
107 ifdef WANTED_LANGUAGES
108 ALL_LANGUAGES := $(filter $(WANTED_LANGUAGES), $(ALL_LANGUAGES))
109 endif
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
119 # compendium.)
120 po/%.po.new: po/$(CATALOG_NAME).pot $(all_compendia)
121 $(MSGMERGE) $(word 1,$^) $(word 1,$^) -o $@ $(addprefix --compendium=,$(filter %/$*.po,$(wordlist 2,$(words $^),$^)))
124 all: all-po
125 install: install-po
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