2010-09-20 22:08:53 +02:00
# src/nls-global.mk
2001-06-02 20:25:18 +02:00
# Common rules for Native Language Support (NLS)
#
# If some subdirectory of the source tree wants to provide NLS, it
# needs to contain a file 'nls.mk' with the following make variable
# assignments:
#
2011-06-26 22:38:29 +02:00
# CATALOG_NAME -- name of the message catalog (xxx.po); probably
# name of the program
# AVAIL_LANGUAGES -- list of languages that are provided/supported
# GETTEXT_FILES -- list of source files that contain message strings
# GETTEXT_TRIGGERS -- (optional) list of functions that contain
2001-06-02 20:25:18 +02:00
# translatable strings
2011-06-26 23:13:10 +02:00
# 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)
2001-06-02 20:25:18 +02:00
#
# That's all, the rest is done here, if --enable-nls was specified.
#
# The only user-visible targets here are 'init-po', to make an initial
# "blank" catalog from program sources, and 'update-po', which is to
# be called if the messages in the program source have changed, in
# order to merge the changes into the existing .po files.
# existence checked by Makefile.global; otherwise we won't get here
i n c l u d e $( srcdir ) / n l s . m k
# If user specified the languages he wants in --enable-nls=LANGUAGES,
# filter out the rest. Else use all available ones.
i f d e f W A N T E D _ L A N G U A G E S
LANGUAGES = $( filter $( WANTED_LANGUAGES) , $( AVAIL_LANGUAGES) )
e l s e
LANGUAGES = $( AVAIL_LANGUAGES)
e n d i f
2002-08-21 22:42:27 +02:00
PO_FILES = $( addprefix po/, $( addsuffix .po, $( LANGUAGES) ) )
2012-03-28 20:06:45 +02:00
ALL_PO_FILES = $( addprefix po/, $( addsuffix .po, $( AVAIL_LANGUAGES) ) )
2002-08-21 22:42:27 +02:00
MO_FILES = $( addprefix po/, $( addsuffix .mo, $( LANGUAGES) ) )
2001-06-02 20:25:18 +02:00
2001-06-30 23:58:06 +02:00
i f d e f X G E T T E X T
2012-04-05 20:22:15 +02:00
XGETTEXT += -ctranslator --copyright-holder= 'PostgreSQL Global Development Group' --msgid-bugs-address= pgsql-bugs@postgresql.org --no-wrap --sort-by-file
e n d i f
i f d e f M S G M E R G E
MSGMERGE += --no-wrap --sort-by-file
2001-06-30 23:58:06 +02:00
e n d i f
2001-06-02 20:25:18 +02:00
2011-06-26 22:05:30 +02:00
# _ is defined in c.h, so it's global
GETTEXT_TRIGGERS += _
2011-06-26 23:13:10 +02:00
GETTEXT_FLAGS += _:1:pass-c-format
2011-06-26 22:05:30 +02:00
2001-06-02 20:25:18 +02:00
2011-06-26 22:50:21 +02:00
# common settings that apply to backend and all backend modules
BACKEND_COMMON_GETTEXT_TRIGGERS = \
errmsg errmsg_plural:1,2 \
errdetail errdetail_log errdetail_plural:1,2 \
errhint \
errcontext
2011-06-26 23:13:10 +02:00
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
2011-06-26 22:50:21 +02:00
2001-06-02 20:25:18 +02:00
all-po : $( MO_FILES )
%.mo : %.po
$( MSGFMT) -o $@ $<
i f e q ( $( word 1,$ ( GETTEXT_FILES ) ) , + )
2009-01-15 10:01:24 +01:00
po/$(CATALOG_NAME).pot : $( word 2, $ ( GETTEXT_FILES ) ) $( MAKEFILE_LIST )
2010-10-14 21:15:46 +02:00
i f d e f X G E T T E X T
2011-06-26 23:13:10 +02:00
$( XGETTEXT) -D $( srcdir) -n $( addprefix -k, $( GETTEXT_TRIGGERS) ) $( addprefix --flag= , $( GETTEXT_FLAGS) ) -f $<
2001-06-02 20:25:18 +02:00
e l s e
2010-10-14 21:15:46 +02:00
@echo "You don't have 'xgettext'." ; exit 1
e n d i f
e l s e # GETTEXT_FILES
2009-01-15 10:01:24 +01:00
po/$(CATALOG_NAME).pot : $( GETTEXT_FILES ) $( MAKEFILE_LIST )
2001-07-15 13:43:55 +02:00
# Change to srcdir explicitly, don't rely on $^. That way we get
# consistent #: file references in the po files.
2010-10-14 21:15:46 +02:00
i f d e f X G E T T E X T
2011-06-26 23:13:10 +02:00
$( XGETTEXT) -D $( srcdir) -n $( addprefix -k, $( GETTEXT_TRIGGERS) ) $( addprefix --flag= , $( GETTEXT_FLAGS) ) $( GETTEXT_FILES)
2010-10-14 21:15:46 +02:00
e l s e
@echo "You don't have 'xgettext'." ; exit 1
2001-06-02 20:25:18 +02:00
e n d i f
2010-10-14 21:15:46 +02:00
e n d i f # GETTEXT_FILES
2009-08-27 00:24:44 +02:00
@$( MKDIR_P) $( dir $@ )
2009-01-02 16:15:42 +01:00
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 >$@
rm messages.po
2001-06-02 20:25:18 +02:00
2008-12-11 08:34:09 +01:00
# catalog name extentions must match behavior of PG_TEXTDOMAIN() in c.h
2001-06-02 20:25:18 +02:00
install-po : all -po installdirs -po
2002-09-03 00:19:42 +02:00
i f n e q ( , $( LANGUAGES ) )
2001-06-02 20:25:18 +02:00
for lang in $( LANGUAGES) ; do \
2008-12-11 08:34:09 +01:00
$( INSTALL_DATA) po/$$ lang.mo '$(DESTDIR)$(localedir)' /$$ lang/LC_MESSAGES/$( CATALOG_NAME) $( SO_MAJOR_VERSION) -$( MAJORVERSION) .mo || exit 1; \
2001-06-02 20:25:18 +02:00
done
2002-09-03 00:19:42 +02:00
e n d i f
2001-06-02 20:25:18 +02:00
installdirs-po :
2010-05-13 16:35:28 +02:00
$( if $( LANGUAGES) ,$( MKDIR_P) $( foreach lang, $( LANGUAGES) , '$(DESTDIR)$(localedir)' /$( lang) /LC_MESSAGES) ,:)
2001-06-02 20:25:18 +02:00
uninstall-po :
2010-05-13 16:35:28 +02:00
$( if $( LANGUAGES) ,rm -f $( foreach lang, $( LANGUAGES) , '$(DESTDIR)$(localedir)' /$( lang) /LC_MESSAGES/$( CATALOG_NAME) $( SO_MAJOR_VERSION) -$( MAJORVERSION) .mo) ,:)
2001-06-02 20:25:18 +02:00
clean-po :
2008-05-17 22:24:05 +02:00
$( if $( MO_FILES) ,rm -f $( MO_FILES) )
2009-01-09 11:54:08 +01:00
@$( if $( wildcard po/*.po.new) ,rm -f po/*.po.new)
2003-09-15 00:40:38 +02:00
rm -f po/$( CATALOG_NAME) .pot
2001-06-02 20:25:18 +02:00
2012-03-28 20:06:45 +02:00
maintainer-check-po : $( ALL_PO_FILES )
2001-06-02 20:25:18 +02:00
for file in $^; do \
2001-07-15 13:43:55 +02:00
$( MSGFMT) -c -v -o /dev/null $$ file || exit 1; \
2001-06-02 20:25:18 +02:00
done
2003-09-15 00:40:38 +02:00
init-po : po /$( CATALOG_NAME ) .pot
2001-06-02 20:25:18 +02:00
2009-01-09 11:54:08 +01:00
# For performance reasons, only calculate these when the user actually
# requested update-po or a specific file.
i f n e q ( , $( filter update -po %.po .new ,$ ( MAKECMDGOALS ) ) )
2011-12-27 19:22:51 +01:00
ALL_LANGUAGES := $( shell find $( top_srcdir) -name '*.po' -print | sed 's,^.*/\([^/]*\).po$$,\1,' | LC_ALL = C sort -u)
all_compendia := $( shell find $( top_srcdir) -name '*.po' -print | LC_ALL = C sort)
2001-06-02 20:25:18 +02:00
e l s e
2009-01-09 11:54:08 +01:00
ALL_LANGUAGES = $( AVAIL_LANGUAGES)
all_compendia = FORCE
FORCE :
e n d i f
i f d e f W A N T E D _ L A N G U A G E S
ALL_LANGUAGES := $( filter $( WANTED_LANGUAGES) , $( ALL_LANGUAGES) )
2001-06-02 20:25:18 +02:00
e n d i f
2009-01-09 11:54:08 +01:00
update-po : $( ALL_LANGUAGES :%=po /%.po .new )
$(AVAIL_LANGUAGES : %=po /%.po .new ): po /%.po .new : po /%.po po /$( CATALOG_NAME ) .pot $( all_compendia )
2012-04-02 01:58:37 +02:00
$( MSGMERGE) --lang= $* $( word 1, $^) $( word 2,$^) -o $@ $( addprefix --compendium= ,$( filter %/$* .po,$( wordlist 3,$( words $^) ,$^) ) )
2009-01-09 11:54:08 +01:00
2009-01-20 10:58:50 +01:00
# For languages not yet available, merge against oneself, to pick
# up translations from the compendia. (Merging against /dev/null
# doesn't work so well; it inserts the headers from the first-named
# compendium.)
2009-01-09 11:54:08 +01:00
po/%.po.new : po /$( CATALOG_NAME ) .pot $( all_compendia )
2012-04-02 01:58:37 +02:00
$( MSGMERGE) --lang= $* $( word 1,$^) $( word 1,$^) -o $@ $( addprefix --compendium= ,$( filter %/$* .po,$( wordlist 2,$( words $^) ,$^) ) )
2009-01-09 11:54:08 +01:00
2001-06-02 20:25:18 +02:00
all : all -po
install : install -po
installdirs : installdirs -po
uninstall : uninstall -po
2003-09-15 00:40:38 +02:00
clean distclean maintainer-clean : clean -po
2001-06-02 20:25:18 +02:00
maintainer-check : maintainer -check -po
.PHONY : all -po install -po installdirs -po uninstall -po clean -po \
2003-09-15 00:40:38 +02:00
maintainer-check-po init-po update-po