Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c2ohN-0005qp-Gd for pgsql-hackers@arkaria.postgresql.org; Sat, 05 Nov 2016 00:19:05 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1c2ohM-0005kM-Un for pgsql-hackers@arkaria.postgresql.org; Sat, 05 Nov 2016 00:19:04 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1c2ofy-0004DS-Tp for pgsql-hackers@postgresql.org; Sat, 05 Nov 2016 00:17:39 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1c2ofu-00080J-FR for pgsql-hackers@postgresql.org; Sat, 05 Nov 2016 00:17:38 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 5627620707; Fri, 4 Nov 2016 20:17:32 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute2.internal (MEProxy); Fri, 04 Nov 2016 20:17:32 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=smtpout; bh=j93VlGsw+lpGkz zxel1TucKDd1s=; b=NPULtBJH+psr3Id3Ote2S+nUtl5Otn76ANjl+ptiGGLVOu o/jUYnSFl+Nrk5t/53x9qTtTZhMX3tAU1X8v3hMHXeua/q2Ct/+QeRWaVH4l8IvS +EgTkNNc0pYMrY5z4KbTuMG8W0s/NMZHOgaBccthOc4WntmPgHBO/ZTbn6Pmw= X-ME-Sender: X-Sasl-enc: nkt7QS4Sst2eSBnw7h5+KIgGpXFg9Ovvxuc1zeLJ7Sa9 1478305050 Received: from april.local (c-73-13-66-39.hsd1.pa.comcast.net [73.13.66.39]) by mail.messagingengine.com (Postfix) with ESMTPA id 8749ACC07B; Fri, 4 Nov 2016 20:17:30 -0400 (EDT) Subject: Re: add more NLS to bin To: Michael Paquier References: Cc: pgsql-hackers From: Peter Eisentraut Organization: 2ndQuadrant Message-ID: Date: Fri, 4 Nov 2016 20:17:29 -0400 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------1508852046E9E01350EAA448" X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org This is a multi-part message in MIME format. --------------1508852046E9E01350EAA448 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 11/3/16 7:17 PM, Michael Paquier wrote: > This patch not being complicated, so I would vote for those being > addressed now so as they are not forgotten even if there is a FIXME > flag added. Perhaps you don't think so, and as that's a minor issue > I'll be fine with your judgement as well. OK, I just wrapped it in translation markers as is, which should work well enough. >>> In util.c, doesn't pg_log_v() need to handle strings used in fprintf? >> >> Which specific lines do you have in mind? > > The verbose logs at the top. In pg_rewind for example those logs are > getting translated via the pg_log() calls used with PG_DEBUG. Yeah that was wrong anyway. The previously existing translation markers were wrong. We want to translate the fmt, not the formatted message. New patch attached. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services --------------1508852046E9E01350EAA448 Content-Type: text/x-patch; name="v2-0001-pg_upgrade-Add-NLS.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="v2-0001-pg_upgrade-Add-NLS.patch" From 91a5d23f1d8a188d11de2f2dfc6d455ebf04cfc5 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Fri, 14 Oct 2016 12:00:00 -0400 Subject: [PATCH v2 1/3] pg_upgrade: Add NLS --- src/bin/pg_upgrade/function.c | 2 +- src/bin/pg_upgrade/info.c | 8 ++-- src/bin/pg_upgrade/nls.mk | 12 +++++ src/bin/pg_upgrade/option.c | 101 +++++++++++++++++++-------------------- src/bin/pg_upgrade/pg_upgrade.c | 1 + src/bin/pg_upgrade/relfilenode.c | 6 ++- src/bin/pg_upgrade/server.c | 4 +- src/bin/pg_upgrade/util.c | 14 +++--- 8 files changed, 80 insertions(+), 68 deletions(-) create mode 100644 src/bin/pg_upgrade/nls.mk diff --git a/src/bin/pg_upgrade/function.c b/src/bin/pg_upgrade/function.c index 3009340..5b60f9f 100644 --- a/src/bin/pg_upgrade/function.c +++ b/src/bin/pg_upgrade/function.c @@ -252,7 +252,7 @@ check_loadable_libraries(void) if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL) pg_fatal("could not open file \"%s\": %s\n", output_path, strerror(errno)); - fprintf(script, "could not load library \"%s\":\n%s\n", + fprintf(script, _("could not load library \"%s\":\n%s\n"), lib, PQerrorMessage(conn)); } diff --git a/src/bin/pg_upgrade/info.c b/src/bin/pg_upgrade/info.c index 1200c7f..8af9eac 100644 --- a/src/bin/pg_upgrade/info.c +++ b/src/bin/pg_upgrade/info.c @@ -238,7 +238,7 @@ report_unmatched_relation(const RelInfo *rel, const DbInfo *db, bool is_new_db) { snprintf(reldesc + strlen(reldesc), sizeof(reldesc) - strlen(reldesc), - " which is an index on \"%s.%s\"", + _(" which is an index on \"%s.%s\""), hrel->nspname, hrel->relname); /* Shift attention to index's table for toast check */ rel = hrel; @@ -248,7 +248,7 @@ report_unmatched_relation(const RelInfo *rel, const DbInfo *db, bool is_new_db) if (i >= db->rel_arr.nrels) snprintf(reldesc + strlen(reldesc), sizeof(reldesc) - strlen(reldesc), - " which is an index on OID %u", rel->indtable); + _(" which is an index on OID %u"), rel->indtable); } if (rel->toastheap) { @@ -260,7 +260,7 @@ report_unmatched_relation(const RelInfo *rel, const DbInfo *db, bool is_new_db) { snprintf(reldesc + strlen(reldesc), sizeof(reldesc) - strlen(reldesc), - " which is the TOAST table for \"%s.%s\"", + _(" which is the TOAST table for \"%s.%s\""), brel->nspname, brel->relname); break; } @@ -268,7 +268,7 @@ report_unmatched_relation(const RelInfo *rel, const DbInfo *db, bool is_new_db) if (i >= db->rel_arr.nrels) snprintf(reldesc + strlen(reldesc), sizeof(reldesc) - strlen(reldesc), - " which is the TOAST table for OID %u", rel->toastheap); + _(" which is the TOAST table for OID %u"), rel->toastheap); } if (is_new_db) diff --git a/src/bin/pg_upgrade/nls.mk b/src/bin/pg_upgrade/nls.mk new file mode 100644 index 0000000..a0c846d --- /dev/null +++ b/src/bin/pg_upgrade/nls.mk @@ -0,0 +1,12 @@ +# src/bin/pg_upgrade/nls.mk +CATALOG_NAME = pg_upgrade +AVAIL_LANGUAGES = +GETTEXT_FILES = check.c controldata.c dump.c exec.c file.c function.c \ + info.c option.c parallel.c pg_upgrade.c relfilenode.c \ + server.c tablespace.c util.c version.c +GETTEXT_TRIGGERS = pg_fatal pg_log:2 prep_status report_status:2 +GETTEXT_FLAGS = \ + pg_fatal:1:c-format \ + pg_log:2:c-format \ + prep_status:1:c-format \ + report_status:2:c-format diff --git a/src/bin/pg_upgrade/option.c b/src/bin/pg_upgrade/option.c index 2e9a40c..12a49ff 100644 --- a/src/bin/pg_upgrade/option.c +++ b/src/bin/pg_upgrade/option.c @@ -240,13 +240,13 @@ parseCommandLine(int argc, char *argv[]) /* Get values from env if not already set */ check_required_directory(&old_cluster.bindir, NULL, "PGBINOLD", "-b", - "old cluster binaries reside"); + _("old cluster binaries reside")); check_required_directory(&new_cluster.bindir, NULL, "PGBINNEW", "-B", - "new cluster binaries reside"); + _("new cluster binaries reside")); check_required_directory(&old_cluster.pgdata, &old_cluster.pgconfig, - "PGDATAOLD", "-d", "old cluster data resides"); + "PGDATAOLD", "-d", _("old cluster data resides")); check_required_directory(&new_cluster.pgdata, &new_cluster.pgconfig, - "PGDATANEW", "-D", "new cluster data resides"); + "PGDATANEW", "-D", _("new cluster data resides")); #ifdef WIN32 @@ -275,56 +275,53 @@ parseCommandLine(int argc, char *argv[]) static void usage(void) { - printf(_("pg_upgrade upgrades a PostgreSQL cluster to a different major version.\n\ -\nUsage:\n\ - pg_upgrade [OPTION]...\n\ -\n\ -Options:\n\ - -b, --old-bindir=BINDIR old cluster executable directory\n\ - -B, --new-bindir=BINDIR new cluster executable directory\n\ - -c, --check check clusters only, don't change any data\n\ - -d, --old-datadir=DATADIR old cluster data directory\n\ - -D, --new-datadir=DATADIR new cluster data directory\n\ - -j, --jobs number of simultaneous processes or threads to use\n\ - -k, --link link instead of copying files to new cluster\n\ - -o, --old-options=OPTIONS old cluster options to pass to the server\n\ - -O, --new-options=OPTIONS new cluster options to pass to the server\n\ - -p, --old-port=PORT old cluster port number (default %d)\n\ - -P, --new-port=PORT new cluster port number (default %d)\n\ - -r, --retain retain SQL and log files after success\n\ - -U, --username=NAME cluster superuser (default \"%s\")\n\ - -v, --verbose enable verbose internal logging\n\ - -V, --version display version information, then exit\n\ - -?, --help show this help, then exit\n\ -\n\ -Before running pg_upgrade you must:\n\ - create a new database cluster (using the new version of initdb)\n\ - shutdown the postmaster servicing the old cluster\n\ - shutdown the postmaster servicing the new cluster\n\ -\n\ -When you run pg_upgrade, you must provide the following information:\n\ - the data directory for the old cluster (-d DATADIR)\n\ - the data directory for the new cluster (-D DATADIR)\n\ - the \"bin\" directory for the old version (-b BINDIR)\n\ - the \"bin\" directory for the new version (-B BINDIR)\n\ -\n\ -For example:\n\ - pg_upgrade -d oldCluster/data -D newCluster/data -b oldCluster/bin -B newCluster/bin\n\ -or\n"), old_cluster.port, new_cluster.port, os_info.user); + printf(_("pg_upgrade upgrades a PostgreSQL cluster to a different major version.\n\n")); + printf(_("Usage:\n")); + printf(_(" pg_upgrade [OPTION]...\n\n")); + printf(_("Options:\n")); + printf(_(" -b, --old-bindir=BINDIR old cluster executable directory\n")); + printf(_(" -B, --new-bindir=BINDIR new cluster executable directory\n")); + printf(_(" -c, --check check clusters only, don't change any data\n")); + printf(_(" -d, --old-datadir=DATADIR old cluster data directory\n")); + printf(_(" -D, --new-datadir=DATADIR new cluster data directory\n")); + printf(_(" -j, --jobs number of simultaneous processes or threads to use\n")); + printf(_(" -k, --link link instead of copying files to new cluster\n")); + printf(_(" -o, --old-options=OPTIONS old cluster options to pass to the server\n")); + printf(_(" -O, --new-options=OPTIONS new cluster options to pass to the server\n")); + printf(_(" -p, --old-port=PORT old cluster port number (default %d)\n"), old_cluster.port); + printf(_(" -P, --new-port=PORT new cluster port number (default %d)\n"), new_cluster.port); + printf(_(" -r, --retain retain SQL and log files after success\n")); + printf(_(" -U, --username=NAME cluster superuser (default \"%s\")\n"), os_info.user); + printf(_(" -v, --verbose enable verbose internal logging\n")); + printf(_(" -V, --version display version information, then exit\n")); + printf(_(" -?, --help show this help, then exit\n")); + printf(_("\n" + "Before running pg_upgrade you must:\n" + " create a new database cluster (using the new version of initdb)\n" + " shutdown the postmaster servicing the old cluster\n" + " shutdown the postmaster servicing the new cluster\n")); + printf(_("\n" + "When you run pg_upgrade, you must provide the following information:\n" + " the data directory for the old cluster (-d DATADIR)\n" + " the data directory for the new cluster (-D DATADIR)\n" + " the \"bin\" directory for the old version (-b BINDIR)\n" + " the \"bin\" directory for the new version (-B BINDIR)\n")); + printf(_("\n" + "For example:\n" + " pg_upgrade -d oldCluster/data -D newCluster/data -b oldCluster/bin -B newCluster/bin\n" + "or\n")); #ifndef WIN32 - printf(_("\ - $ export PGDATAOLD=oldCluster/data\n\ - $ export PGDATANEW=newCluster/data\n\ - $ export PGBINOLD=oldCluster/bin\n\ - $ export PGBINNEW=newCluster/bin\n\ - $ pg_upgrade\n")); + printf(_(" $ export PGDATAOLD=oldCluster/data\n" + " $ export PGDATANEW=newCluster/data\n" + " $ export PGBINOLD=oldCluster/bin\n" + " $ export PGBINNEW=newCluster/bin\n" + " $ pg_upgrade\n")); #else - printf(_("\ - C:\\> set PGDATAOLD=oldCluster/data\n\ - C:\\> set PGDATANEW=newCluster/data\n\ - C:\\> set PGBINOLD=oldCluster/bin\n\ - C:\\> set PGBINNEW=newCluster/bin\n\ - C:\\> pg_upgrade\n")); + printf(_(" C:\\> set PGDATAOLD=oldCluster/data\n" + " C:\\> set PGDATANEW=newCluster/data\n" + " C:\\> set PGBINOLD=oldCluster/bin\n" + " C:\\> set PGBINNEW=newCluster/bin\n" + " C:\\> pg_upgrade\n")); #endif printf(_("\nReport bugs to .\n")); } diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c index 90c0720..0207d85 100644 --- a/src/bin/pg_upgrade/pg_upgrade.c +++ b/src/bin/pg_upgrade/pg_upgrade.c @@ -75,6 +75,7 @@ main(int argc, char **argv) char *deletion_script_file_name = NULL; bool live_check = false; + set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_upgrade")); parseCommandLine(argc, argv); get_restricted_token(os_info.progname); diff --git a/src/bin/pg_upgrade/relfilenode.c b/src/bin/pg_upgrade/relfilenode.c index c8c2a28..79e41d1 100644 --- a/src/bin/pg_upgrade/relfilenode.c +++ b/src/bin/pg_upgrade/relfilenode.c @@ -30,8 +30,10 @@ void transfer_all_new_tablespaces(DbInfoArr *old_db_arr, DbInfoArr *new_db_arr, char *old_pgdata, char *new_pgdata) { - pg_log(PG_REPORT, "%s user relation files\n", - user_opts.transfer_mode == TRANSFER_MODE_LINK ? "Linking" : "Copying"); + if (user_opts.transfer_mode == TRANSFER_MODE_LINK) + pg_log(PG_REPORT, "Linking user relation files\n"); + else + pg_log(PG_REPORT, "Copying user relation files\n"); /* * Transferring files by tablespace is tricky because a single database diff --git a/src/bin/pg_upgrade/server.c b/src/bin/pg_upgrade/server.c index 12432bb..4892934 100644 --- a/src/bin/pg_upgrade/server.c +++ b/src/bin/pg_upgrade/server.c @@ -36,7 +36,7 @@ connectToServer(ClusterInfo *cluster, const char *db_name) if (conn) PQfinish(conn); - printf("Failure, exiting\n"); + printf(_("Failure, exiting\n")); exit(1); } @@ -136,7 +136,7 @@ executeQueryOrDie(PGconn *conn, const char *fmt,...) PQerrorMessage(conn)); PQclear(result); PQfinish(conn); - printf("Failure, exiting\n"); + printf(_("Failure, exiting\n")); exit(1); } else diff --git a/src/bin/pg_upgrade/util.c b/src/bin/pg_upgrade/util.c index aadc1cd..4f27c72 100644 --- a/src/bin/pg_upgrade/util.c +++ b/src/bin/pg_upgrade/util.c @@ -89,7 +89,7 @@ pg_log_v(eLogType type, const char *fmt, va_list ap) { char message[QUERY_ALLOC]; - vsnprintf(message, sizeof(message), fmt, ap); + vsnprintf(message, sizeof(message), _(fmt), ap); /* PG_VERBOSE and PG_STATUS are only output in verbose mode */ /* fopen() on log_opts.internal might have failed, so check it */ @@ -108,7 +108,7 @@ pg_log_v(eLogType type, const char *fmt, va_list ap) { case PG_VERBOSE: if (log_opts.verbose) - printf("%s", _(message)); + printf("%s", message); break; case PG_STATUS: @@ -123,17 +123,17 @@ pg_log_v(eLogType type, const char *fmt, va_list ap) strlen(message) <= MESSAGE_WIDTH - 2 ? message : message + strlen(message) - MESSAGE_WIDTH + 3 + 2); else - printf(" %s\n", _(message)); + printf(" %s\n", message); break; case PG_REPORT: case PG_WARNING: - printf("%s", _(message)); + printf("%s", message); break; case PG_FATAL: - printf("\n%s", _(message)); - printf("Failure, exiting\n"); + printf("\n%s", message); + printf(_("Failure, exiting\n")); exit(1); break; @@ -163,7 +163,7 @@ pg_fatal(const char *fmt,...) va_start(args, fmt); pg_log_v(PG_FATAL, fmt, args); va_end(args); - printf("Failure, exiting\n"); + printf(_("Failure, exiting\n")); exit(1); } -- 2.10.2 --------------1508852046E9E01350EAA448 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers --------------1508852046E9E01350EAA448--