Commit e5420364 authored by Peter Eisentraut's avatar Peter Eisentraut

Native Language Support (NLS)

Use --enable-nls to turn it on; see installation instructions for details.
See developer's guide how to make use of it in programs and how to add
translations.

psql sources have been almost fully prepared and an incomplete German
translation has been provided.  In the backend, only elog() calls are
currently translatable, and the provided German translation file is more
of a placeholder.
parent 58193c5f
# $Header: /cvsroot/pgsql/config/programs.m4,v 1.4 2001/02/10 22:31:42 petere Exp $
# $Header: /cvsroot/pgsql/config/programs.m4,v 1.5 2001/06/02 18:25:16 petere Exp $
# PGAC_PATH_FLEX
......@@ -99,3 +99,34 @@ if test "$pgac_cv_check_readline" != no ; then
else
AC_MSG_RESULT(no)
fi])# PGAC_CHECK_READLINE
# PGAC_CHECK_GETTEXT
# ------------------
AC_DEFUN([PGAC_CHECK_GETTEXT],
[
AC_SEARCH_LIBS(gettext, intl, [],
[AC_MSG_ERROR([a gettext implementation is required for NLS])])
AC_CHECK_HEADER([libintl.h], [],
[AC_MSG_ERROR([header file <libintl.h> is required for NLS])])
AC_CHECK_PROGS(MSGFMT, msgfmt)
if test -z "$MSGFMT"; then
AC_MSG_ERROR([msgfmt is required for NLS])
fi
AC_CHECK_PROGS(MSGMERGE, msgmerge)
dnl FIXME: We should probably check for version >=0.10.36.
AC_CHECK_PROGS(XGETTEXT, xgettext)
# Note: share/locale is always the default, independent of $datadir
if test x"$prefix" = x"NONE"; then
localedir="$ac_default_prefix/share/locale"
else
localedir="$prefix/share/locale"
fi
AC_SUBST(localedir)
AC_DEFINE_UNQUOTED(LOCALEDIR, ["$localedir"],
[location of locale files])
])# PGAC_CHECK_GETTEXT
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -212,6 +212,19 @@ AC_DEFINE([UNICODE_CONVERSION], 1,
[Set to 1 if you want Unicode conversion support (--enable-unicode-conversion)])])
AC_MSG_RESULT([$enable_unicode_conversion])
#
# NLS
#
AC_MSG_CHECKING([whether NLS is wanted])
PGAC_ARG_OPTARG(enable, nls,
[ --enable-nls[=LANGUAGES] enable Native Language Support],
[],
[WANTED_LANGUAGES=$enableval],
[AC_DEFINE(ENABLE_NLS)])
AC_MSG_RESULT([$enable_nls])
AC_SUBST(enable_nls)
AC_SUBST(WANTED_LANGUAGES)
#
# Default port number (--with-pgport), default 5432
#
......@@ -720,6 +733,10 @@ if test "$with_openssl" = yes ; then
AC_CHECK_LIB(ssl, [SSL_library_init], [], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])])
fi
if test "$enable_nls" = yes ; then
PGAC_CHECK_GETTEXT
fi
##
## Header files
......
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/Attic/developer.sgml,v 1.4 2001/02/03 19:03:26 petere Exp $ -->
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/Attic/developer.sgml,v 1.5 2001/06/02 18:25:16 petere Exp $ -->
<!-- PostgreSQL Developer's Guide -->
<book id="developer">
......@@ -24,6 +24,7 @@
&bki;
&page;
&geqo;
&nls;
<![%single-book;[
&biblio;
]]>
......
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/filelist.sgml,v 1.12 2001/05/12 22:51:34 petere Exp $ -->
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/filelist.sgml,v 1.13 2001/06/02 18:25:16 petere Exp $ -->
<!entity history SYSTEM "history.sgml">
<!entity info SYSTEM "info.sgml">
......@@ -96,6 +96,7 @@
<!entity page SYSTEM "page.sgml">
<!entity protocol SYSTEM "protocol.sgml">
<!entity sources SYSTEM "sources.sgml">
<!entity nls SYSTEM "nls.sgml">
<!-- see standalone-install.sgml about these -->
<!entity % flattext-install-ignore "INCLUDE">
......
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/installation.sgml,v 1.49 2001/05/14 16:16:52 momjian Exp $ -->
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/installation.sgml,v 1.50 2001/06/02 18:25:16 petere Exp $ -->
<chapter id="installation">
<title><![%flattext-install-include[<productname>PostgreSQL</>]]>
......@@ -536,6 +536,44 @@ su - postgres
</listitem>
</varlistentry>
<varlistentry>
<term>--enable-nls<optional>=<replaceable>LANGUAGES</replaceable></optional></term>
<listitem>
<para>
Enables Native Language Support (NLS), that is, the ability
to display a program's message in a language other than
English. <replaceable>LANGUAGES</replaceable> is a space
separated list of codes of the languages that you want
supported. (The intersection between your list and the set
of actually provided translations will be computed
automatically.) If you do not specify it, then all available
translations are installed.
</para>
<comment>
The list of provided translations should be shown somewhere.
</comment>
<para>
To use this option, you will need an implementation of the
gettext API. Some operating systems have this built-in
(e.g., Linux, NetBSD, Solaris), for other systems you can download
an add-on package from here: <ulink
url="http://www.postgresql.org/~petere/gettext.html"
>http://www.postgresql.org/~petere/gettext.html</ulink>. If
you are using the gettext implementation in the GNU C library
then you will additionally need the GNU gettext package for
some utility programs. For any of the other implementations
you will not need it.
</para>
<comment>
The download location should be moved.
</comment>
</listitem>
</varlistentry>
<varlistentry>
<term>--with-pgport=<replaceable>NUMBER</></term>
<listitem>
......
This diff is collapsed.
# -*-makefile-*-
# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.128 2001/05/25 14:28:58 momjian Exp $
# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.129 2001/06/02 18:25:16 petere Exp $
#------------------------------------------------------------------------------
# All PostgreSQL makefiles include this file and use the variables it sets,
......@@ -18,7 +18,7 @@
#
# Meta configuration
.PHONY: all install installdirs uninstall clean distclean maintainer-clean distprep check installcheck
.PHONY: all install installdirs uninstall clean distclean maintainer-clean distprep check installcheck maintainer-check
.SILENT: installdirs
# make `all' the default target
......@@ -100,6 +100,7 @@ endif
odbcinst_ini_dir = @odbcinst_ini_dir@
javadir := $(DESTDIR)$(datadir)/java
localedir := @localedir@
##########################################################################
......@@ -119,6 +120,7 @@ enable_odbc = @enable_odbc@
MULTIBYTE = @MULTIBYTE@
enable_shared = @enable_shared@
enable_rpath = @enable_rpath@
enable_nls = @enable_nls@
python_version = @python_version@
python_includedir = @python_includedir@
......@@ -186,10 +188,13 @@ X = @EXEEXT@
ANT = @ANT@
AWK = @AWK@
LN_S = @LN_S@
MSGFMT = @MSGFMT@
MSGMERGE = @MSGMERGE@
PERL = @PERL@
PYTHON = @PYTHON@
TAR = @TAR@
WISH = @WISH@
XGETTEXT = @XGETTEXT@
# Installation.
......@@ -214,6 +219,7 @@ SGMLSPL = @SGMLSPL@
# Feature settings
DEF_PGPORT = @default_port@
WANTED_LANGUAGES = @WANTED_LANGUAGES@
##########################################################################
......@@ -411,3 +417,16 @@ clean-deps:
@rm -rf $(DEPDIR) *.d
endif # autodepend
##########################################################################
#
# Native language support
ifeq ($(enable_nls), yes)
ifneq (,$(wildcard $(srcdir)/nls.mk))
include $(top_srcdir)/src/nls-global.mk
endif # nls.mk
endif # enable_nls
......@@ -4,7 +4,7 @@
#
# Copyright (c) 1994, Regents of the University of California
#
# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.72 2001/05/24 15:53:32 momjian Exp $
# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.73 2001/06/02 18:25:17 petere Exp $
#
#-------------------------------------------------------------------------
......@@ -34,6 +34,9 @@ endif
##########################################################################
all: postgres $(POSTGRES_IMP)
ifeq ($(enable_nls), yes)
$(MAKE) -C po all
endif
ifneq ($(PORTNAME), win)
......@@ -113,7 +116,9 @@ distprep:
$(MAKE) -C parser gram.c parse.h scan.c
$(MAKE) -C bootstrap bootparse.c bootstrap_tokens.h bootscanner.c
$(MAKE) -C utils/misc guc-file.c
ifeq ($(enable_nls), yes)
$(MAKE) -C po $@
endif
##########################################################################
......@@ -127,9 +132,15 @@ endif
$(INSTALL_DATA) $(srcdir)/libpq/pg_hba.conf.sample $(DESTDIR)$(datadir)/pg_hba.conf.sample
$(INSTALL_DATA) $(srcdir)/libpq/pg_ident.conf.sample $(DESTDIR)$(datadir)/pg_ident.conf.sample
$(INSTALL_DATA) $(srcdir)/utils/misc/postgresql.conf.sample $(DESTDIR)$(datadir)/postgresql.conf.sample
ifeq ($(enable_nls), yes)
$(MAKE) -C po $@
endif
installdirs:
$(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(libdir) $(DESTDIR)$(datadir)
ifeq ($(enable_nls), yes)
$(MAKE) -C po $@
endif
install-bin: postgres $(POSTGRES_IMP) installdirs
$(INSTALL_PROGRAM) postgres$(X) $(DESTDIR)$(bindir)/postgres$(X)
......@@ -157,6 +168,9 @@ endif
rm -f $(DESTDIR)$(datadir)/pg_hba.conf.sample \
$(DESTDIR)$(datadir)/pg_ident.conf.sample \
$(DESTDIR)$(datadir)/postgresql.conf.sample
ifeq ($(enable_nls), yes)
$(MAKE) -C po $@
endif
##########################################################################
......@@ -171,6 +185,9 @@ ifeq ($(MAKE_DLL), true)
endif
endif
for i in $(DIRS); do $(MAKE) -C $$i clean || exit; done
ifeq ($(enable_nls), yes)
$(MAKE) -C po $@
endif
distclean: clean
rm -f port/Makefile port/tas.s port/dynloader.c
......@@ -183,6 +200,7 @@ maintainer-clean: distclean
$(srcdir)/parser/scan.c \
$(srcdir)/parser/parse.h \
$(srcdir)/utils/misc/guc-file.c
$(MAKE) -C po maintainer-clean
##########################################################################
......
......@@ -13,7 +13,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.43 2001/04/21 18:29:29 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.44 2001/06/02 18:25:17 petere Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -21,7 +21,7 @@
#include <pwd.h>
#include <unistd.h>
#ifdef USE_LOCALE
#if defined(USE_LOCALE) || defined(ENABLE_NLS)
#include <locale.h>
#endif
......@@ -97,6 +97,14 @@ main(int argc, char *argv[])
beos_startup(argc, argv);
#endif
#ifdef ENABLE_NLS
#ifdef LC_MESSAGES
setlocale(LC_MESSAGES, "");
#endif
bindtextdomain("postgres", LOCALEDIR);
textdomain("postgres");
#endif
/*
* Not-quite-so-platform-specific startup environment checks. Still
* best to minimize these.
......
# $Header: /cvsroot/pgsql/src/backend/po/Attic/Makefile,v 1.1 2001/06/02 18:25:17 petere Exp $
subdir = src/backend/po
top_builddir = ../../..
include $(top_builddir)/src/Makefile.global
gettext-files:
find $(srcdir)/.. -name '*.c' >$@
maintainer-clean:
rm -f gettext-files
This diff is collapsed.
CATALOG_NAME := postgres
AVAIL_LANGUAGES := de
GETTEXT_FILES := + gettext-files
GETTEXT_TRIGGERS:= elog:2
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.84 2001/05/30 14:15:26 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.85 2001/06/02 18:25:17 petere Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -207,6 +207,7 @@ elog(int lev, const char *fmt,...)
if (Log_pid)
timestamp_size += PID_SIZE;
fmt = gettext(fmt);
/*
* Set up the expanded format, consisting of the prefix string plus
* input format, with any %m replaced by strerror() string (since
......
......@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.54 2001/05/12 19:44:46 petere Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.55 2001/06/02 18:25:17 petere Exp $
*/
#include "postgres_fe.h"
#include "command.h"
......@@ -156,7 +156,7 @@ HandleSlashCmds(const char *line,
if (status == CMD_UNKNOWN)
{
if (pset.cur_cmd_interactive)
fprintf(stderr, "Invalid command \\%s. Try \\? for help.\n", my_line);
fprintf(stderr, gettext("Invalid command \\%s. Try \\? for help.\n"), my_line);
else
psql_error("invalid command \\%s\n", my_line);
status = CMD_ERROR;
......@@ -582,7 +582,7 @@ exec_command(const char *cmd,
if (query_buf && query_buf->len > 0)
puts(query_buf->data);
else if (!quiet)
puts("Query buffer is empty.");
puts(gettext("Query buffer is empty."));
fflush(stdout);
}
......@@ -613,7 +613,7 @@ exec_command(const char *cmd,
{
resetPQExpBuffer(query_buf);
if (!quiet)
puts("Query buffer reset (cleared).");
puts(gettext("Query buffer reset (cleared)."));
}
/* \s save history in a file or show it on the screen */
......@@ -624,7 +624,7 @@ exec_command(const char *cmd,
success = saveHistory(fname ? fname : "/dev/tty");
if (success && !quiet && fname)
printf("Wrote history to %s.\n", fname);
printf(gettext("Wrote history to %s.\n"), fname);
free(fname);
}
......@@ -1314,7 +1314,7 @@ do_connect(const char *new_dbname, const char *new_user)
PQfinish(pset.db);
if (oldconn)
{
fputs("Previous connection kept\n", stderr);
fputs(gettext("Previous connection kept\n"), stderr);
pset.db = oldconn;
}
else
......@@ -1339,12 +1339,12 @@ do_connect(const char *new_dbname, const char *new_user)
if (!QUIET())
{
if (userparam != new_user) /* no new user */
printf("You are now connected to database %s.\n", dbparam);
printf(gettext("You are now connected to database %s.\n"), dbparam);
else if (dbparam != new_dbname) /* no new db */
printf("You are now connected as new user %s.\n", new_user);
printf(gettext("You are now connected as new user %s.\n"), new_user);
else
/* both new */
printf("You are now connected to database %s as user %s.\n",
printf(gettext("You are now connected to database %s as user %s.\n"),
PQdb(pset.db), PQuser(pset.db));
}
......@@ -1672,7 +1672,7 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
}
if (!quiet)
printf("Output format is %s.\n", _align2string(popt->topt.format));
printf(gettext("Output format is %s.\n"), _align2string(popt->topt.format));
}
/* set border style/width */
......@@ -1682,7 +1682,7 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
popt->topt.border = atoi(value);
if (!quiet)
printf("Border style is %d.\n", popt->topt.border);
printf(gettext("Border style is %d.\n"), popt->topt.border);
}
/* set expanded/vertical mode */
......@@ -1690,7 +1690,9 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
{
popt->topt.expanded = !popt->topt.expanded;
if (!quiet)
printf("Expanded display is %s.\n", popt->topt.expanded ? "on" : "off");
printf(popt->topt.expanded
? gettext("Expanded display is on.\n")
: gettext("Expanded display is off.\n"));
}
/* null display */
......@@ -1702,7 +1704,7 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
popt->nullPrint = xstrdup(value);
}
if (!quiet)
printf("Null display is '%s'.\n", popt->nullPrint ? popt->nullPrint : "");
printf(gettext("Null display is '%s'.\n"), popt->nullPrint ? popt->nullPrint : "");
}
/* field separator for unaligned text */
......@@ -1714,7 +1716,7 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
popt->topt.fieldSep = xstrdup(value);
}
if (!quiet)
printf("Field separator is '%s'.\n", popt->topt.fieldSep);
printf(gettext("Field separator is '%s'.\n"), popt->topt.fieldSep);
}
/* record separator for unaligned text */
......@@ -1728,9 +1730,9 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
if (!quiet)
{
if (strcmp(popt->topt.recordSep, "\n") == 0)
printf("Record separator is <newline>.");
printf(gettext("Record separator is <newline>."));
else
printf("Record separator is '%s'.\n", popt->topt.recordSep);
printf(gettext("Record separator is '%s'.\n"), popt->topt.recordSep);
}
}
......@@ -1741,9 +1743,9 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
if (!quiet)
{
if (popt->topt.tuples_only)
puts("Showing only tuples.");
puts(gettext("Showing only tuples."));
else
puts("Tuples only is off.");
puts(gettext("Tuples only is off."));
}
}
......@@ -1759,9 +1761,9 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
if (!quiet)
{
if (popt->title)
printf("Title is \"%s\".\n", popt->title);
printf(gettext("Title is \"%s\".\n"), popt->title);
else
printf("Title is unset.\n");
printf(gettext("Title is unset.\n"));
}
}
......@@ -1777,9 +1779,9 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
if (!quiet)
{
if (popt->topt.tableAttr)
printf("Table attribute is \"%s\".\n", popt->topt.tableAttr);
printf(gettext("Table attribute is \"%s\".\n"), popt->topt.tableAttr);
else
printf("Table attributes unset.\n");
printf(gettext("Table attributes unset.\n"));
}
}
......@@ -1790,9 +1792,9 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
if (!quiet)
{
if (popt->topt.pager)
puts("Using pager is on.");
puts(gettext("Using pager is on."));
else
puts("Using pager is off.");
puts(gettext("Using pager is off."));
}
}
......@@ -1803,9 +1805,9 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
if (!quiet)
{
if (popt->default_footer)
puts("Default footer is on.");
puts(gettext("Default footer is on."));
else
puts("Default footer is off.");
puts(gettext("Default footer is off."));
}
}
......
......@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
* $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.32 2001/04/15 00:43:37 petere Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.33 2001/06/02 18:25:18 petere Exp $
*/
#include "postgres_fe.h"
......@@ -47,7 +47,7 @@ xstrdup(const char *string)
if (!string)
{
fprintf(stderr, "%s: xstrdup: cannot duplicate null pointer (internal error)\n",
fprintf(stderr, gettext("%s: xstrdup: cannot duplicate null pointer (internal error)\n"),
pset.progname);
exit(EXIT_FAILURE);
}
......@@ -139,7 +139,7 @@ psql_error(const char *fmt,...)
if (pset.inputfile)
fprintf(stderr, "%s:%s:%u: ", pset.progname, pset.inputfile, pset.lineno);
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
vfprintf(stderr, gettext(fmt), ap);
va_end(ap);
}
......@@ -187,7 +187,7 @@ simple_prompt(const char *prompt, int maxlen, bool echo)
if (!destination)
return NULL;
if (prompt)
fputs(prompt, stderr);
fputs(gettext(prompt), stderr);
prompt_state = true;
......@@ -303,7 +303,9 @@ PSQLexec(const char *query)
var = GetVariable(pset.vars, "ECHO_HIDDEN");
if (var)
{
printf("********* QUERY *********\n%s\n*************************\n\n", query);
printf("********* QUERY **********\n"
"%s\n"
"**************************\n\n", query);
fflush(stdout);
}
......@@ -336,11 +338,11 @@ PSQLexec(const char *query)
psql_error("connection to server was lost\n");
exit(EXIT_BADCONN);
}
fputs("The connection to the server was lost. Attempting reset: ", stderr);
fputs(gettext("The connection to the server was lost. Attempting reset: "), stderr);
PQreset(pset.db);
if (PQstatus(pset.db) == CONNECTION_BAD)
{
fputs("Failed.\n", stderr);
fputs(gettext("Failed.\n"), stderr);
PQfinish(pset.db);
pset.db = NULL;
SetVariable(pset.vars, "DBNAME", NULL);
......@@ -350,7 +352,7 @@ PSQLexec(const char *query)
SetVariable(pset.vars, "ENCODING", NULL);
}
else
fputs("Succeeded.\n", stderr);
fputs(gettext("Succeeded.\n"), stderr);
}
return NULL;
......@@ -388,9 +390,9 @@ SendQuery(const char *query)
{
char buf[3];
printf("***(Single step mode: Verify query)*********************************************\n"
"%s\n"
"***(press return to proceed or enter x and return to cancel)********************\n",
printf(gettext("***(Single step mode: Verify query)*********************************************\n"
"%s\n"
"***(press return to proceed or enter x and return to cancel)********************\n"),
query);
fflush(stdout);
if (fgets(buf, sizeof(buf), stdin) != NULL)
......@@ -480,8 +482,8 @@ SendQuery(const char *query)
case PGRES_COPY_IN:
if (pset.cur_cmd_interactive && !QUIET())
puts("Enter data to be copied followed by a newline.\n"
"End with a backslash and a period on a line by itself.");
puts(gettext("Enter data to be copied followed by a newline.\n"
"End with a backslash and a period on a line by itself."));
success = handleCopyIn(pset.db, pset.cur_cmd_source,
pset.cur_cmd_interactive ? get_prompt(PROMPT_COPY) : NULL);
......@@ -504,11 +506,11 @@ SendQuery(const char *query)
psql_error("connection to server was lost\n");
exit(EXIT_BADCONN);
}
fputs("The connection to the server was lost. Attempting reset: ", stderr);
fputs(gettext("The connection to the server was lost. Attempting reset: "), stderr);
PQreset(pset.db);
if (PQstatus(pset.db) == CONNECTION_BAD)
{
fputs("Failed.\n", stderr);
fputs(gettext("Failed.\n"), stderr);
PQfinish(pset.db);
PQclear(results);
pset.db = NULL;
......@@ -520,13 +522,13 @@ SendQuery(const char *query)
return false;
}
else
fputs("Succeeded.\n", stderr);
fputs(gettext("Succeeded.\n"), stderr);
}
/* check for asynchronous notification returns */
while ((notify = PQnotifies(pset.db)) != NULL)
{
fprintf(pset.queryFout, "Asynchronous NOTIFY '%s' from backend with pid '%d' received.\n",
fprintf(pset.queryFout, gettext("Asynchronous NOTIFY '%s' from backend with pid '%d' received.\n"),
notify->relname, notify->be_pid);
free(notify);
fflush(pset.queryFout);
......
......@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
* $Header: /cvsroot/pgsql/src/bin/psql/copy.c,v 1.18 2001/03/22 04:00:19 momjian Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/copy.c,v 1.19 2001/06/02 18:25:18 petere Exp $
*/
#include "postgres_fe.h"
#include "copy.h"
......@@ -207,10 +207,10 @@ parse_slash_copy(const char *args)
if (error)
{
psql_error("\\copy: parse error at %s%s%s\n",
token ? "'" : "",
token ? token : "end of line",
token ? "'" : "");
if (token)
psql_error("\\copy: parse error at '%s'\n", token);
else
psql_error("\\copy: parse error at end of line\n");
free_copy_options(result);
return NULL;
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
* $Header: /cvsroot/pgsql/src/bin/psql/large_obj.c,v 1.14 2001/03/22 04:00:20 momjian Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/large_obj.c,v 1.15 2001/06/02 18:25:18 petere Exp $
*/
#include "postgres_fe.h"
#include "large_obj.h"
......@@ -63,9 +63,9 @@ handle_transaction(void)
else if (!QUIET())
{
if (commit)
puts("Warning: Your transaction in progress has been committed.");
puts(gettext("Warning: Your transaction in progress has been committed."));
else
puts("Warning: Your transaction in progress has been rolled back.");
puts(gettext("Warning: Your transaction in progress has been rolled back."));
}
PQsetNoticeProcessor(pset.db, old_notice_hook, NULL);
......@@ -92,9 +92,7 @@ do_lo_export(const char *loid_arg, const char *filename_arg)
if (!pset.db)
{
if (!pset.cur_cmd_interactive)
fprintf(stderr, "%s: ", pset.progname);
fputs("\\lo_export: not connected to a database\n", stderr);
psql_error("\\lo_export: not connected to a database\n");
return false;
}
......@@ -161,9 +159,7 @@ do_lo_import(const char *filename_arg, const char *comment_arg)
if (!pset.db)
{
if (!pset.cur_cmd_interactive)
fprintf(stderr, "%s: ", pset.progname);
fputs("\\lo_import: not connected to a database\n", stderr);
psql_error("\\lo_import: not connected to a database\n");
return false;
}
......@@ -254,9 +250,7 @@ do_lo_unlink(const char *loid_arg)
if (!pset.db)
{
if (!pset.cur_cmd_interactive)
fprintf(stderr, "%s: ", pset.progname);
fputs("\\lo_unlink: not connected to a database\n", stderr);
psql_error("\\lo_unlink: not connected to a database\n");
return false;
}
......@@ -327,10 +321,11 @@ do_lo_list(void)
char buf[1024];
printQueryOpt myopt = pset.popt;
strcpy(buf,
"SELECT loid as \"ID\", obj_description(loid) as \"Description\"\n"
"FROM (SELECT DISTINCT loid FROM pg_largeobject) x\n"
"ORDER BY \"ID\"");
snprintf(buf, sizeof(buf),
"SELECT loid as \"ID\", obj_description(loid) as \"%s\"\n"
"FROM (SELECT DISTINCT loid FROM pg_largeobject) x\n"
"ORDER BY \"ID\"",
gettext("Description"));
res = PSQLexec(buf);
if (!res)
......@@ -338,7 +333,7 @@ do_lo_list(void)
myopt.topt.tuples_only = false;
myopt.nullPrint = NULL;
myopt.title = "Large objects";
myopt.title = gettext("Large objects");
printQuery(res, &myopt, pset.queryFout);
......
......@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
* $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.39 2001/03/26 15:18:51 tgl Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.40 2001/06/02 18:25:18 petere Exp $
*/
#include "postgres_fe.h"
#include "mainloop.h"
......@@ -19,7 +19,6 @@
#ifndef WIN32
#include <setjmp.h>
sigjmp_buf main_loop_jmp;
#endif
......@@ -240,7 +239,7 @@ MainLoop(FILE *source)
else
{
if (!QUIET())
printf("Use \"\\q\" to leave %s.\n", pset.progname);
printf(gettext("Use \"\\q\" to leave %s.\n"), pset.progname);
continue;
}
}
......
# $Header: /cvsroot/pgsql/src/bin/psql/nls.mk,v 1.1 2001/06/02 18:25:18 petere Exp $
CATALOG_NAME := psql
AVAIL_LANGUAGES := de
GETTEXT_FILES := command.c common.c copy.c help.c input.c large_obj.c \
mainloop.c print.c startup.c
# describe.c needs work
GETTEXT_TRIGGERS:= _ psql_error simple_prompt
......@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
* $Header: /cvsroot/pgsql/src/bin/psql/print.c,v 1.19 2001/05/12 19:44:46 petere Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/print.c,v 1.20 2001/06/02 18:25:18 petere Exp $
*/
#include "postgres_fe.h"
#include "print.h"
......@@ -364,7 +364,7 @@ print_aligned_vertical(const char *title, const char *const * headers,
if (cells[0] == NULL)
{
puts("(No rows)\n");
puts(gettext("(No rows)\n"));
return;
}
......@@ -1069,9 +1069,9 @@ printQuery(const PGresult *result, const printQueryOpt *opt, FILE *fout)
footers[0] = malloc(100);
if (PQntuples(result) == 1)
strcpy(footers[0], "(1 row)");
snprintf(footers[0], 100, gettext("(1 row)"));
else
sprintf(footers[0], "(%d rows)", PQntuples(result));
snprintf(footers[0], 100, gettext("(%d rows)"), PQntuples(result));
}
else
footers = NULL;
......
......@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
* $Header: /cvsroot/pgsql/src/bin/psql/startup.c,v 1.49 2001/05/30 14:15:27 momjian Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/startup.c,v 1.50 2001/06/02 18:25:18 petere Exp $
*/
#include "postgres_fe.h"
......@@ -21,6 +21,10 @@
#include <getopt.h>
#endif
#ifdef ENABLE_NLS
#include <locale.h>
#endif
#include "libpq-fe.h"
#include "command.h"
......@@ -102,6 +106,12 @@ main(int argc, char *argv[])
char *password = NULL;
bool need_pass;
#ifdef ENABLE_NLS
setlocale(LC_ALL, "");
bindtextdomain("psql", LOCALEDIR);
textdomain("psql");
#endif
if (!strrchr(argv[0], '/'))
pset.progname = argv[0];
else
......@@ -128,7 +138,7 @@ main(int argc, char *argv[])
pset.vars = CreateVariableSpace();
if (!pset.vars)
{
fprintf(stderr, "%s: out of memory\n", pset.progname);
fprintf(stderr, gettext("%s: out of memory\n"), pset.progname);
exit(EXIT_FAILURE);
}
pset.popt.topt.format = PRINT_ALIGNED;
......@@ -273,12 +283,13 @@ main(int argc, char *argv[])
pset.issuper = test_superuser(PQuser(pset.db));
if (!QUIET() && !pset.notty)
{
printf("Welcome to %s, the PostgreSQL interactive terminal.\n\n"
"Type: \\copyright for distribution terms\n"
" \\h for help with SQL commands\n"
" \\? for help on internal slash commands\n"
" \\g or terminate with semicolon to execute query\n"
" \\q to quit\n\n", pset.progname);
printf(gettext("Welcome to %s, the PostgreSQL interactive terminal.\n\n"
"Type: \\copyright for distribution terms\n"
" \\h for help with SQL commands\n"
" \\? for help on internal slash commands\n"
" \\g or terminate with semicolon to execute query\n"
" \\q to quit\n\n"),
pset.progname);
#ifdef USE_SSL
printSSLInfo();
#endif
......@@ -447,7 +458,7 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
if (!result)
{
fprintf(stderr, "%s: couldn't set printing parameter %s\n", pset.progname, value);
fprintf(stderr, gettext("%s: couldn't set printing parameter %s\n"), pset.progname, value);
exit(EXIT_FAILURE);
}
......@@ -493,7 +504,7 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
{
if (!DeleteVariable(pset.vars, value))
{
fprintf(stderr, "%s: could not delete variable %s\n",
fprintf(stderr, gettext("%s: could not delete variable %s\n"),
pset.progname, value);
exit(EXIT_FAILURE);
}
......@@ -503,7 +514,7 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
*equal_loc = '\0';
if (!SetVariable(pset.vars, value, equal_loc + 1))
{
fprintf(stderr, "%s: could not set variable %s\n",
fprintf(stderr, gettext("%s: could not set variable %s\n"),
pset.progname, value);
exit(EXIT_FAILURE);
}
......@@ -534,20 +545,22 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
/* unknown option reported by getopt */
else
{
fprintf(stderr, "Try '%s --help' for more information.\n",
fprintf(stderr, gettext("Try '%s --help' for more information.\n"),
pset.progname);
exit(EXIT_FAILURE);
}
break;
#ifndef HAVE_GETOPT_LONG
case '-':
fprintf(stderr, "%s was compiled without support for long options.\n"
"Use --help for help on invocation options.\n", pset.progname);
fprintf(stderr,
gettext("%s was compiled without support for long options.\n"
"Use --help for help on invocation options.\n"),
pset.progname);
exit(EXIT_FAILURE);
break;
#endif
default:
fprintf(stderr, "Try '%s --help' for more information.\n",
fprintf(stderr, gettext("Try '%s --help' for more information.\n"),
pset.progname);
exit(EXIT_FAILURE);
break;
......@@ -565,14 +578,14 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
else if (!options->username)
options->username = argv[optind];
else if (!QUIET())
fprintf(stderr, "%s: warning: extra option %s ignored\n",
fprintf(stderr, gettext("%s: warning: extra option %s ignored\n"),
pset.progname, argv[optind]);
optind++;
}
if (used_old_u_option && !QUIET())
fprintf(stderr, "%s: Warning: The -u option is deprecated. Use -U.\n", pset.progname);
fprintf(stderr, gettext("%s: Warning: The -u option is deprecated. Use -U.\n"), pset.progname);
}
......@@ -599,7 +612,7 @@ process_psqlrc(void)
psqlrc = malloc(strlen(home) + 20);
if (!psqlrc)
{
fprintf(stderr, "%s: out of memory\n", pset.progname);
fprintf(stderr, gettext("%s: out of memory\n"), pset.progname);
exit(EXIT_FAILURE);
}
......@@ -628,10 +641,10 @@ showVersion(void)
puts("psql (PostgreSQL) " PG_VERSION);
#if defined(USE_READLINE) || defined (USE_HISTORY) || defined(MULTIBYTE)
fputs("contains ", stdout);
fputs(gettext("contains support for: "), stdout);
#ifdef USE_READLINE
fputs("readline", stdout);
fputs(gettext("readline"), stdout);
#define _Feature
#endif
......@@ -641,7 +654,7 @@ showVersion(void)
#else
#define _Feature
#endif
fputs("history", stdout);
fputs(gettext("history"), stdout);
#endif
#ifdef MULTIBYTE
......@@ -650,18 +663,18 @@ showVersion(void)
#else
#define _Feature
#endif
fputs("multibyte", stdout);
fputs(gettext("multibyte"), stdout);
#endif
#undef _Feature
puts(" support");
puts("");
#endif
puts("Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group");
puts("Portions Copyright (c) 1996 Regents of the University of California");
puts("Read the file COPYRIGHT or use the command \\copyright to see the");
puts("usage and distribution terms.");
puts(gettext("Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group\n"
"Portions Copyright (c) 1996, Regents of the University of California\n"
"Read the file COPYRIGHT or use the command \\copyright to see the\n"
"usage and distribution terms."));
}
......@@ -683,7 +696,7 @@ printSSLInfo(void)
return; /* no SSL */
SSL_get_cipher_bits(ssl, &sslbits);
printf("SSL enabled connection. Chiper: %s, bits: %i\n\n",
printf(gettext("SSL connection (cipher: %s, bits: %i)\n\n"),
SSL_get_cipher(ssl), sslbits);
}
......
......@@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: c.h,v 1.93 2001/05/30 14:15:27 momjian Exp $
* $Id: c.h,v 1.94 2001/06/02 18:25:18 petere Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -68,6 +68,11 @@
#include <SupportDefs.h>
#endif
#ifdef ENABLE_NLS
#include <libintl.h>
#else
#define gettext(x) (x)
#endif
/* ----------------------------------------------------------------
* Section 1: hacks to cope with non-ANSI C compilers
......
......@@ -8,7 +8,7 @@
* or in config.h afterwards. Of course, if you edit config.h, then your
* changes will be overwritten the next time you run configure.
*
* $Id: config.h.in,v 1.164 2001/05/11 23:38:06 petere Exp $
* $Id: config.h.in,v 1.165 2001/06/02 18:25:18 petere Exp $
*/
#ifndef CONFIG_H
......@@ -84,6 +84,11 @@
/* --enable-pltcl-unknown */
#undef ENABLE_PLTCL_UNKNOWN
/* --enable-nls */
#undef ENABLE_NLS
/* location of locale files */
#undef LOCALEDIR
/*
*------------------------------------------------------------------------
......
# $Header: /cvsroot/pgsql/src/nls-global.mk,v 1.1 2001/06/02 18:25:17 petere Exp $
# 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:
#
# 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
# translatable strings
#
# 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
include $(srcdir)/nls.mk
# If user specified the languages he wants in --enable-nls=LANGUAGES,
# filter out the rest. Else use all available ones.
ifdef WANTED_LANGUAGES
LANGUAGES = $(filter $(WANTED_LANGUAGES), $(AVAIL_LANGUAGES))
else
LANGUAGES = $(AVAIL_LANGUAGES)
endif
PO_FILES = $(addsuffix .po, $(LANGUAGES))
MO_FILES = $(addsuffix .mo, $(LANGUAGES))
XGETTEXT += --foreign-user
all-po: $(MO_FILES)
distprep: $(srcdir)/$(CATALOG_NAME).pot
%.mo: %.po
$(MSGFMT) -o $@ $<
ifdef XGETTEXT
ifeq ($(word 1,$(GETTEXT_FILES)),+)
$(srcdir)/$(CATALOG_NAME).pot: $(word 2, $(GETTEXT_FILES))
$(XGETTEXT) -D $(srcdir) -ctranslator -n $(addprefix -k, $(GETTEXT_TRIGGERS)) -f $<
else
$(srcdir)/$(CATALOG_NAME).pot: $(GETTEXT_FILES)
$(XGETTEXT) -ctranslator -n $(addprefix -k, $(GETTEXT_TRIGGERS)) $^
endif
mv messages.po $@
else # not XGETTEXT
@echo "You don't have 'xgettext'."; exit 1
endif # not XGETTEXT
install-po: all-po installdirs-po
for lang in $(LANGUAGES); do \
$(INSTALL_DATA) $$lang.mo $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(CATALOG_NAME).mo || exit 1; \
done
installdirs-po:
$(mkinstalldirs) $(foreach lang, $(LANGUAGES), $(DESTDIR)$(localedir)/$(lang)/LC_MESSAGES)
uninstall-po:
rm -f $(foreach lang, $(LANGUAGES), $(DESTDIR)$(localedir)/$(lang)/LC_MESSAGES/$(CATALOG_NAME).mo)
clean-po:
rm -f $(MO_FILES)
@rm -f $(addsuffix .po.old, $(AVAIL_LANGUAGES))
maintainer-clean-po:
rm -f $(srcdir)/$(CATALOG_NAME).pot
maintainer-check-po: $(PO_FILES)
for file in $^; do \
$(MSGFMT) -v -o /dev/null $$file || exit 1; \
done
init-po: $(srcdir)/$(CATALOG_NAME).pot
update-po: $(srcdir)/$(CATALOG_NAME).pot
ifdef MSGMERGE
# XXX should be $(LANGUAGES)?
@for lang in $(AVAIL_LANGUAGES); do \
echo "merging $$lang:"; \
if $(MSGMERGE) $(srcdir)/$$lang.po $< -o $$lang.po.new; \
then \
mv $(srcdir)/$$lang.po $$lang.po.old; \
mv $$lang.po.new $(srcdir)/$$lang.po; \
else \
echo "msgmerge for $$lang failed"; \
rm -f $$lang.po.new; \
fi; \
done
else
@echo "You don't have 'msgmerge'." ; exit 1
endif
all: all-po
install: install-po
installdirs: installdirs-po
uninstall: uninstall-po
clean distclean: clean-po
maintainer-clean: maintainer-clean-po
maintainer-check: maintainer-check-po
.PHONY: all-po install-po installdirs-po uninstall-po clean-po \
maintainer-clean-po maintainer-check-po init-po update-po
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment