Here is a series of patches to add NLS to the remaining bin programs, which were moved from contrib a while ago. (If you're missing pgbench, I'm skipping that for now because it's more complicated.) I'll add this to the commit fest.
-- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
>From 1939efe002fde2cbc2012e7ae1af674e774e82cb Mon Sep 17 00:00:00 2001 From: Peter Eisentraut <pete...@gmx.net> Date: Fri, 14 Oct 2016 12:00:00 -0400 Subject: [PATCH 1/7] pg_archivecleanup: Add NLS --- src/bin/pg_archivecleanup/nls.mk | 4 ++ src/bin/pg_archivecleanup/pg_archivecleanup.c | 73 ++++++++++++++------------- 2 files changed, 41 insertions(+), 36 deletions(-) create mode 100644 src/bin/pg_archivecleanup/nls.mk diff --git a/src/bin/pg_archivecleanup/nls.mk b/src/bin/pg_archivecleanup/nls.mk new file mode 100644 index 0000000..fd959a5 --- /dev/null +++ b/src/bin/pg_archivecleanup/nls.mk @@ -0,0 +1,4 @@ +# src/bin/pg_archivecleanup/nls.mk +CATALOG_NAME = pg_archivecleanup +AVAIL_LANGUAGES = +GETTEXT_FILES = pg_archivecleanup.c diff --git a/src/bin/pg_archivecleanup/pg_archivecleanup.c b/src/bin/pg_archivecleanup/pg_archivecleanup.c index 319038f..f1651d4 100644 --- a/src/bin/pg_archivecleanup/pg_archivecleanup.c +++ b/src/bin/pg_archivecleanup/pg_archivecleanup.c @@ -70,7 +70,7 @@ Initialize(void) if (stat(archiveLocation, &stat_buf) != 0 || !S_ISDIR(stat_buf.st_mode)) { - fprintf(stderr, "%s: archive location \"%s\" does not exist\n", + fprintf(stderr, _("%s: archive location \"%s\" does not exist\n"), progname, archiveLocation); exit(2); } @@ -146,19 +146,19 @@ CleanupPriorWALFiles(void) printf("%s\n", WALFilePath); if (debug) fprintf(stderr, - "%s: file \"%s\" would be removed\n", + _("%s: file \"%s\" would be removed\n"), progname, WALFilePath); continue; } if (debug) - fprintf(stderr, "%s: removing file \"%s\"\n", + fprintf(stderr, _("%s: removing file \"%s\"\n"), progname, WALFilePath); rc = unlink(WALFilePath); if (rc != 0) { - fprintf(stderr, "%s: ERROR: could not remove file \"%s\": %s\n", + fprintf(stderr, _("%s: ERROR: could not remove file \"%s\": %s\n"), progname, WALFilePath, strerror(errno)); break; } @@ -166,14 +166,14 @@ CleanupPriorWALFiles(void) } if (errno) - fprintf(stderr, "%s: could not read archive location \"%s\": %s\n", + fprintf(stderr, _("%s: could not read archive location \"%s\": %s\n"), progname, archiveLocation, strerror(errno)); if (closedir(xldir)) - fprintf(stderr, "%s: could not close archive location \"%s\": %s\n", + fprintf(stderr, _("%s: could not close archive location \"%s\": %s\n"), progname, archiveLocation, strerror(errno)); } else - fprintf(stderr, "%s: could not open archive location \"%s\": %s\n", + fprintf(stderr, _("%s: could not open archive location \"%s\": %s\n"), progname, archiveLocation, strerror(errno)); } @@ -246,8 +246,8 @@ SetWALFileNameForCleanup(void) if (!fnameOK) { - fprintf(stderr, "%s: invalid filename input\n", progname); - fprintf(stderr, "Try \"%s --help\" for more information.\n", progname); + fprintf(stderr, _("%s: invalid filename input\n"), progname); + fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); exit(2); } } @@ -260,25 +260,25 @@ SetWALFileNameForCleanup(void) static void usage(void) { - printf("%s removes older WAL files from PostgreSQL archives.\n\n", progname); - printf("Usage:\n"); - printf(" %s [OPTION]... ARCHIVELOCATION OLDESTKEPTWALFILE\n", progname); - printf("\nOptions:\n"); - printf(" -d generate debug output (verbose mode)\n"); - printf(" -n dry run, show the names of the files that would be removed\n"); - printf(" -V, --version output version information, then exit\n"); - printf(" -x EXT clean up files if they have this extension\n"); - printf(" -?, --help show this help, then exit\n"); - printf("\n" - "For use as archive_cleanup_command in recovery.conf when standby_mode = on:\n" - " archive_cleanup_command = 'pg_archivecleanup [OPTION]... ARCHIVELOCATION %%r'\n" - "e.g.\n" - " archive_cleanup_command = 'pg_archivecleanup /mnt/server/archiverdir %%r'\n"); - printf("\n" - "Or for use as a standalone archive cleaner:\n" - "e.g.\n" - " pg_archivecleanup /mnt/server/archiverdir 000000010000000000000010.00000020.backup\n"); - printf("\nReport bugs to <pgsql-b...@postgresql.org>.\n"); + printf(_("%s removes older WAL files from PostgreSQL archives.\n\n"), progname); + printf(_("Usage:\n")); + printf(_(" %s [OPTION]... ARCHIVELOCATION OLDESTKEPTWALFILE\n"), progname); + printf(_("\nOptions:\n")); + printf(_(" -d generate debug output (verbose mode)\n")); + printf(_(" -n dry run, show the names of the files that would be removed\n")); + printf(_(" -V, --version output version information, then exit\n")); + printf(_(" -x EXT clean up files if they have this extension\n")); + printf(_(" -?, --help show this help, then exit\n")); + printf(_("\n" + "For use as archive_cleanup_command in recovery.conf when standby_mode = on:\n" + " archive_cleanup_command = 'pg_archivecleanup [OPTION]... ARCHIVELOCATION %%r'\n" + "e.g.\n" + " archive_cleanup_command = 'pg_archivecleanup /mnt/server/archiverdir %%r'\n")); + printf(_("\n" + "Or for use as a standalone archive cleaner:\n" + "e.g.\n" + " pg_archivecleanup /mnt/server/archiverdir 000000010000000000000010.00000020.backup\n")); + printf(_("\nReport bugs to <pgsql-b...@postgresql.org>.\n")); } /*------------ MAIN ----------------------------------------*/ @@ -287,6 +287,7 @@ main(int argc, char **argv) { int c; + set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_archivecleanup")); progname = get_progname(argv[0]); if (argc > 1) @@ -318,7 +319,7 @@ main(int argc, char **argv) * from xlogfile names */ break; default: - fprintf(stderr, "Try \"%s --help\" for more information.\n", progname); + fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); exit(2); break; } @@ -338,8 +339,8 @@ main(int argc, char **argv) } else { - fprintf(stderr, "%s: must specify archive location\n", progname); - fprintf(stderr, "Try \"%s --help\" for more information.\n", progname); + fprintf(stderr, _("%s: must specify archive location\n"), progname); + fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); exit(2); } @@ -350,15 +351,15 @@ main(int argc, char **argv) } else { - fprintf(stderr, "%s: must specify restartfilename\n", progname); - fprintf(stderr, "Try \"%s --help\" for more information.\n", progname); + fprintf(stderr, _("%s: must specify restartfilename\n"), progname); + fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); exit(2); } if (optind < argc) { - fprintf(stderr, "%s: too many parameters\n", progname); - fprintf(stderr, "Try \"%s --help\" for more information.\n", progname); + fprintf(stderr, _("%s: too many parameters\n"), progname); + fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); exit(2); } @@ -376,7 +377,7 @@ main(int argc, char **argv) { snprintf(WALFilePath, MAXPGPATH, "%s/%s", archiveLocation, exclusiveCleanupFileName); - fprintf(stderr, "%s: keep WAL file \"%s\" and later\n", + fprintf(stderr, _("%s: keep WAL file \"%s\" and later\n"), progname, WALFilePath); } -- 2.10.1
>From 9a2254f56ad99f4fbc413002a859d7836eb24e90 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut <pete...@gmx.net> Date: Fri, 14 Oct 2016 12:00:00 -0400 Subject: [PATCH 2/7] pg_test_fsync: Add NLS --- src/bin/pg_test_fsync/nls.mk | 5 +++ src/bin/pg_test_fsync/pg_test_fsync.c | 69 ++++++++++++++++++----------------- 2 files changed, 40 insertions(+), 34 deletions(-) create mode 100644 src/bin/pg_test_fsync/nls.mk diff --git a/src/bin/pg_test_fsync/nls.mk b/src/bin/pg_test_fsync/nls.mk new file mode 100644 index 0000000..6c95731 --- /dev/null +++ b/src/bin/pg_test_fsync/nls.mk @@ -0,0 +1,5 @@ +# src/bin/pg_test_fsync/nls.mk +CATALOG_NAME = pg_test_fsync +AVAIL_LANGUAGES = +GETTEXT_FILES = pg_test_fsync.c +GETTEXT_TRIGGERS = die diff --git a/src/bin/pg_test_fsync/pg_test_fsync.c b/src/bin/pg_test_fsync/pg_test_fsync.c index c842762..daee4a8 100644 --- a/src/bin/pg_test_fsync/pg_test_fsync.c +++ b/src/bin/pg_test_fsync/pg_test_fsync.c @@ -44,7 +44,7 @@ do { \ if (CreateThread(NULL, 0, process_alarm, NULL, 0, NULL) == \ INVALID_HANDLE_VALUE) \ { \ - fprintf(stderr, "Cannot create thread for alarm\n"); \ + fprintf(stderr, _("Cannot create thread for alarm\n")); \ exit(1); \ } \ gettimeofday(&start_t, NULL); \ @@ -96,6 +96,7 @@ static void die(const char *str); int main(int argc, char *argv[]) { + set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_test_fsync")); progname = get_progname(argv[0]); handle_args(argc, argv); @@ -148,7 +149,7 @@ handle_args(int argc, char *argv[]) { if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0) { - printf("Usage: %s [-f FILENAME] [-s SECS-PER-TEST]\n", progname); + printf(_("Usage: %s [-f FILENAME] [-s SECS-PER-TEST]\n"), progname); exit(0); } if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0) @@ -172,7 +173,7 @@ handle_args(int argc, char *argv[]) break; default: - fprintf(stderr, "Try \"%s --help\" for more information.\n", + fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); exit(1); break; @@ -182,18 +183,18 @@ handle_args(int argc, char *argv[]) if (argc > optind) { fprintf(stderr, - "%s: too many command-line arguments (first is \"%s\")\n", + _("%s: too many command-line arguments (first is \"%s\")\n"), progname, argv[optind]); - fprintf(stderr, "Try \"%s --help\" for more information.\n", + fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); exit(1); } - printf("%d seconds per test\n", secs_per_test); + printf(_("%d seconds per test\n"), secs_per_test); #if PG_O_DIRECT != 0 - printf("O_DIRECT supported on this platform for open_datasync and open_sync.\n"); + printf(_("O_DIRECT supported on this platform for open_datasync and open_sync.\n")); #else - printf("Direct I/O is not supported on this platform.\n"); + printf(_("Direct I/O is not supported on this platform.\n")); #endif } @@ -239,10 +240,10 @@ test_sync(int writes_per_op) bool fs_warning = false; if (writes_per_op == 1) - printf("\nCompare file sync methods using one %dkB write:\n", XLOG_BLCKSZ_K); + printf(_("\nCompare file sync methods using one %dkB write:\n"), XLOG_BLCKSZ_K); else - printf("\nCompare file sync methods using two %dkB writes:\n", XLOG_BLCKSZ_K); - printf("(in wal_sync_method preference order, except fdatasync is Linux's default)\n"); + printf(_("\nCompare file sync methods using two %dkB writes:\n"), XLOG_BLCKSZ_K); + printf(_("(in wal_sync_method preference order, except fdatasync is Linux's default)\n")); /* * Test open_datasync if available @@ -271,7 +272,7 @@ test_sync(int writes_per_op) close(tmpfile); } #else - printf(NA_FORMAT, "n/a\n"); + printf(NA_FORMAT, _("n/a\n")); #endif /* @@ -296,7 +297,7 @@ test_sync(int writes_per_op) STOP_TIMER; close(tmpfile); #else - printf(NA_FORMAT, "n/a\n"); + printf(NA_FORMAT, _("n/a\n")); #endif /* @@ -344,7 +345,7 @@ test_sync(int writes_per_op) STOP_TIMER; close(tmpfile); #else - printf(NA_FORMAT, "n/a\n"); + printf(NA_FORMAT, _("n/a\n")); #endif /* @@ -356,7 +357,7 @@ test_sync(int writes_per_op) #ifdef OPEN_SYNC_FLAG if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG | PG_O_DIRECT, 0)) == -1) { - printf(NA_FORMAT, "n/a*\n"); + printf(NA_FORMAT, _("n/a*\n")); fs_warning = true; } else @@ -381,28 +382,28 @@ test_sync(int writes_per_op) close(tmpfile); } #else - printf(NA_FORMAT, "n/a\n"); + printf(NA_FORMAT, _("n/a\n")); #endif if (fs_warning) { - printf("* This file system and its mount options do not support direct\n"); - printf("I/O, e.g. ext4 in journaled mode.\n"); + printf(_("* This file system and its mount options do not support direct\n" + " I/O, e.g. ext4 in journaled mode.\n")); } } static void test_open_syncs(void) { - printf("\nCompare open_sync with different write sizes:\n"); - printf("(This is designed to compare the cost of writing 16kB in different write\n" - "open_sync sizes.)\n"); - - test_open_sync(" 1 * 16kB open_sync write", 16); - test_open_sync(" 2 * 8kB open_sync writes", 8); - test_open_sync(" 4 * 4kB open_sync writes", 4); - test_open_sync(" 8 * 2kB open_sync writes", 2); - test_open_sync("16 * 1kB open_sync writes", 1); + printf(_("\nCompare open_sync with different write sizes:\n")); + printf(_("(This is designed to compare the cost of writing 16kB in different write\n" + "open_sync sizes.)\n")); + + test_open_sync(_(" 1 * 16kB open_sync write"), 16); + test_open_sync(_(" 2 * 8kB open_sync writes"), 8); + test_open_sync(_(" 4 * 4kB open_sync writes"), 4); + test_open_sync(_(" 8 * 2kB open_sync writes"), 2); + test_open_sync(_("16 * 1kB open_sync writes"), 1); } /* @@ -422,7 +423,7 @@ test_open_sync(const char *msg, int writes_size) #ifdef OPEN_SYNC_FLAG if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG | PG_O_DIRECT, 0)) == -1) - printf(NA_FORMAT, "n/a*\n"); + printf(NA_FORMAT, _("n/a*\n")); else { START_TIMER; @@ -439,7 +440,7 @@ test_open_sync(const char *msg, int writes_size) close(tmpfile); } #else - printf(NA_FORMAT, "n/a\n"); + printf(NA_FORMAT, _("n/a\n")); #endif } @@ -455,9 +456,9 @@ test_file_descriptor_sync(void) * against the same file. Possibly this should be done with writethrough * on platforms which support it. */ - printf("\nTest if fsync on non-write file descriptor is honored:\n"); - printf("(If the times are similar, fsync() can sync data written on a different\n" - "descriptor.)\n"); + printf(_("\nTest if fsync on non-write file descriptor is honored:\n")); + printf(_("(If the times are similar, fsync() can sync data written on a different\n" + "descriptor.)\n")); /* * first write, fsync and close, which is the normal behavior without @@ -521,7 +522,7 @@ test_non_sync(void) /* * Test a simple write without fsync */ - printf("\nNon-sync'ed %dkB writes:\n", XLOG_BLCKSZ_K); + printf(_("\nNon-sync'ed %dkB writes:\n"), XLOG_BLCKSZ_K); printf(LABEL_FORMAT, "write"); fflush(stdout); @@ -598,6 +599,6 @@ process_alarm(LPVOID param) static void die(const char *str) { - fprintf(stderr, "%s: %s\n", str, strerror(errno)); + fprintf(stderr, _("%s: %s\n"), _(str), strerror(errno)); exit(1); } -- 2.10.1
>From 793b52b88dff818fa41e7c4c1180292e49681fcc Mon Sep 17 00:00:00 2001 From: Peter Eisentraut <pete...@gmx.net> Date: Fri, 14 Oct 2016 12:00:00 -0400 Subject: [PATCH 3/7] pg_test_timing: Add NLS --- doc/src/sgml/ref/pgtesttiming.sgml | 16 ++++++++-------- src/bin/pg_test_timing/nls.mk | 4 ++++ src/bin/pg_test_timing/pg_test_timing.c | 28 ++++++++++++++++------------ 3 files changed, 28 insertions(+), 20 deletions(-) create mode 100644 src/bin/pg_test_timing/nls.mk diff --git a/doc/src/sgml/ref/pgtesttiming.sgml b/doc/src/sgml/ref/pgtesttiming.sgml index f07a060..e3539cf 100644 --- a/doc/src/sgml/ref/pgtesttiming.sgml +++ b/doc/src/sgml/ref/pgtesttiming.sgml @@ -96,9 +96,9 @@ <title>Interpreting results</title> <screen> Testing timing overhead for 3 seconds. -Per loop time including overhead: 35.96 nsec +Per loop time including overhead: 35.96 ns Histogram of timing durations: -< usec % of total count + < us % of total count 1 96.40465 80435604 2 3.59518 2999652 4 0.00015 126 @@ -109,9 +109,9 @@ <title>Interpreting results</title> <para> Note that different units are used for the per loop time than the - histogram. The loop can have resolution within a few nanoseconds (nsec), + histogram. The loop can have resolution within a few nanoseconds (ns), while the individual timing calls can only resolve down to one microsecond - (usec). + (us). </para> </refsect2> @@ -157,9 +157,9 @@ <title>Changing time sources</title> tsc hpet acpi_pm # echo acpi_pm > /sys/devices/system/clocksource/clocksource0/current_clocksource # pg_test_timing -Per loop time including overhead: 722.92 nsec +Per loop time including overhead: 722.92 ns Histogram of timing durations: -< usec % of total count + < us % of total count 1 27.84870 1155682 2 72.05956 2990371 4 0.07810 3241 @@ -170,7 +170,7 @@ <title>Changing time sources</title> <para> In this configuration, the sample <command>EXPLAIN ANALYZE</command> above - takes 115.9 ms. That's 1061 nsec of timing overhead, again a small multiple + takes 115.9 ms. That's 1061 ns of timing overhead, again a small multiple of what's measured directly by this utility. That much timing overhead means the actual query itself is only taking a tiny fraction of the accounted for time, most of it is being consumed in overhead instead. In @@ -211,7 +211,7 @@ <title>Changing time sources</title> Testing timing overhead for 3 seconds. Per timing duration including loop overhead: 97.75 ns Histogram of timing durations: -< usec % of total count + < us % of total count 1 90.23734 27694571 2 9.75277 2993204 4 0.00981 3010 diff --git a/src/bin/pg_test_timing/nls.mk b/src/bin/pg_test_timing/nls.mk new file mode 100644 index 0000000..e12ea5c --- /dev/null +++ b/src/bin/pg_test_timing/nls.mk @@ -0,0 +1,4 @@ +# src/bin/pg_test_timing/nls.mk +CATALOG_NAME = pg_test_timing +AVAIL_LANGUAGES = +GETTEXT_FILES = pg_test_timing.c diff --git a/src/bin/pg_test_timing/pg_test_timing.c b/src/bin/pg_test_timing/pg_test_timing.c index e5c11de..2f1ab7c 100644 --- a/src/bin/pg_test_timing/pg_test_timing.c +++ b/src/bin/pg_test_timing/pg_test_timing.c @@ -25,6 +25,7 @@ main(int argc, char *argv[]) { uint64 loop_count; + set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_test_timing")); progname = get_progname(argv[0]); handle_args(argc, argv); @@ -51,7 +52,7 @@ handle_args(int argc, char *argv[]) { if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0) { - printf("Usage: %s [-d DURATION]\n", progname); + printf(_("Usage: %s [-d DURATION]\n"), progname); exit(0); } if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0) @@ -71,7 +72,7 @@ handle_args(int argc, char *argv[]) break; default: - fprintf(stderr, "Try \"%s --help\" for more information.\n", + fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); exit(1); break; @@ -81,23 +82,26 @@ handle_args(int argc, char *argv[]) if (argc > optind) { fprintf(stderr, - "%s: too many command-line arguments (first is \"%s\")\n", + _("%s: too many command-line arguments (first is \"%s\")\n"), progname, argv[optind]); - fprintf(stderr, "Try \"%s --help\" for more information.\n", + fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); exit(1); } if (test_duration > 0) { - printf("Testing timing overhead for %d seconds.\n", test_duration); + printf(ngettext("Testing timing overhead for %d second.\n", + "Testing timing overhead for %d seconds.\n", + test_duration), + test_duration); } else { fprintf(stderr, - "%s: duration must be a positive integer (duration is \"%d\")\n", + _("%s: duration must be a positive integer (duration is \"%d\")\n"), progname, test_duration); - fprintf(stderr, "Try \"%s --help\" for more information.\n", + fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); exit(1); } @@ -133,8 +137,8 @@ test_timing(int32 duration) /* Did time go backwards? */ if (diff < 0) { - printf("Detected clock going backwards in time.\n"); - printf("Time warp: %d microseconds\n", diff); + fprintf(stderr, _("Detected clock going backwards in time.\n")); + fprintf(stderr, _("Time warp: %d ms\n"), diff); exit(1); } @@ -157,7 +161,7 @@ test_timing(int32 duration) INSTR_TIME_SUBTRACT(end_time, start_time); - printf("Per loop time including overhead: %0.2f nsec\n", + printf(_("Per loop time including overhead: %0.2f ns\n"), INSTR_TIME_GET_DOUBLE(end_time) * 1e9 / loop_count); return loop_count; @@ -173,8 +177,8 @@ output(uint64 loop_count) while (max_bit > 0 && histogram[max_bit] == 0) max_bit--; - printf("Histogram of timing durations:\n"); - printf("%6s %10s %10s\n", "< usec", "% of total", "count"); + printf(_("Histogram of timing durations:\n")); + printf("%6s %10s %10s\n", _("< us"), _("% of total"), _("count")); for (i = 0; i <= max_bit; i++) { -- 2.10.1
>From 36ddce4817502758fb82c86a26e8c1113be508d1 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut <pete...@gmx.net> Date: Fri, 14 Oct 2016 12:00:00 -0400 Subject: [PATCH 4/7] pg_upgrade: Add NLS --- src/bin/pg_upgrade/function.c | 2 +- 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 | 4 +- 7 files changed, 71 insertions(+), 59 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/nls.mk b/src/bin/pg_upgrade/nls.mk new file mode 100644 index 0000000..9c468f8 --- /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_stats: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 <pgsql-b...@postgresql.org>.\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..b261fd6 100644 --- a/src/bin/pg_upgrade/util.c +++ b/src/bin/pg_upgrade/util.c @@ -133,7 +133,7 @@ pg_log_v(eLogType type, const char *fmt, va_list ap) case PG_FATAL: printf("\n%s", _(message)); - printf("Failure, exiting\n"); + 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.1
>From 6d6c6c51251893bcbfc72edc6002580278b59c5b Mon Sep 17 00:00:00 2001 From: Peter Eisentraut <pete...@gmx.net> Date: Sat, 15 Oct 2016 12:00:00 -0400 Subject: [PATCH 5/7] pg_xlogdump: Add NLS --- src/bin/pg_xlogdump/nls.mk | 6 ++++ src/bin/pg_xlogdump/pg_xlogdump.c | 75 ++++++++++++++++++++------------------- 2 files changed, 44 insertions(+), 37 deletions(-) create mode 100644 src/bin/pg_xlogdump/nls.mk diff --git a/src/bin/pg_xlogdump/nls.mk b/src/bin/pg_xlogdump/nls.mk new file mode 100644 index 0000000..2b254c3 --- /dev/null +++ b/src/bin/pg_xlogdump/nls.mk @@ -0,0 +1,6 @@ +# src/bin/pg_xlogdump/nls.mk +CATALOG_NAME = pg_xlogdump +AVAIL_LANGUAGES = +GETTEXT_FILES = pg_xlogdump.c +GETTEXT_TRIGGERS = fatal_error +GETTEXT_FLAGS = fatal_error:1:c-format diff --git a/src/bin/pg_xlogdump/pg_xlogdump.c b/src/bin/pg_xlogdump/pg_xlogdump.c index 7490398..d070312 100644 --- a/src/bin/pg_xlogdump/pg_xlogdump.c +++ b/src/bin/pg_xlogdump/pg_xlogdump.c @@ -79,9 +79,9 @@ fatal_error(const char *fmt,...) fflush(stdout); - fprintf(stderr, "%s: FATAL: ", progname); + fprintf(stderr, _("%s: FATAL: "), progname); va_start(args, fmt); - vfprintf(stderr, fmt, args); + vfprintf(stderr, _(fmt), args); va_end(args); fputc('\n', stderr); @@ -670,27 +670,27 @@ XLogDumpDisplayStats(XLogDumpConfig *config, XLogDumpStats *stats) static void usage(void) { - printf("%s decodes and displays PostgreSQL transaction logs for debugging.\n\n", + printf(_("%s decodes and displays PostgreSQL transaction logs for debugging.\n\n"), progname); - printf("Usage:\n"); - printf(" %s [OPTION]... [STARTSEG [ENDSEG]] \n", progname); - printf("\nOptions:\n"); - printf(" -b, --bkp-details output detailed information about backup blocks\n"); - printf(" -e, --end=RECPTR stop reading at log position RECPTR\n"); - printf(" -f, --follow keep retrying after reaching end of WAL\n"); - printf(" -n, --limit=N number of records to display\n"); - printf(" -p, --path=PATH directory in which to find log segment files\n"); - printf(" (default: ./pg_wal)\n"); - printf(" -r, --rmgr=RMGR only show records generated by resource manager RMGR\n"); - printf(" use --rmgr=list to list valid resource manager names\n"); - printf(" -s, --start=RECPTR start reading at log position RECPTR\n"); - printf(" -t, --timeline=TLI timeline from which to read log records\n"); - printf(" (default: 1 or the value used in STARTSEG)\n"); - printf(" -V, --version output version information, then exit\n"); - printf(" -x, --xid=XID only show records with TransactionId XID\n"); - printf(" -z, --stats[=record] show statistics instead of records\n"); - printf(" (optionally, show per-record statistics)\n"); - printf(" -?, --help show this help, then exit\n"); + printf(_("Usage:\n")); + printf(_(" %s [OPTION]... [STARTSEG [ENDSEG]] \n"), progname); + printf(_("\nOptions:\n")); + printf(_(" -b, --bkp-details output detailed information about backup blocks\n")); + printf(_(" -e, --end=RECPTR stop reading at log position RECPTR\n")); + printf(_(" -f, --follow keep retrying after reaching end of WAL\n")); + printf(_(" -n, --limit=N number of records to display\n")); + printf(_(" -p, --path=PATH directory in which to find log segment files\n" + " (default: ./pg_wal)\n")); + printf(_(" -r, --rmgr=RMGR only show records generated by resource manager RMGR\n" + " use --rmgr=list to list valid resource manager names\n")); + printf(_(" -s, --start=RECPTR start reading at log position RECPTR\n")); + printf(_(" -t, --timeline=TLI timeline from which to read log records\n" + " (default: 1 or the value used in STARTSEG)\n")); + printf(_(" -V, --version output version information, then exit\n")); + printf(_(" -x, --xid=XID only show records with TransactionId XID\n")); + printf(_(" -z, --stats[=record] show statistics instead of records\n" + " (optionally, show per-record statistics)\n")); + printf(_(" -?, --help show this help, then exit\n")); } int @@ -725,6 +725,7 @@ main(int argc, char **argv) int option; int optindex = 0; + set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_xlogdump")); progname = get_progname(argv[0]); memset(&private, 0, sizeof(XLogDumpPrivate)); @@ -748,7 +749,7 @@ main(int argc, char **argv) if (argc <= 1) { - fprintf(stderr, "%s: no arguments specified\n", progname); + fprintf(stderr, _("%s: no arguments specified\n"), progname); goto bad_argument; } @@ -763,7 +764,7 @@ main(int argc, char **argv) case 'e': if (sscanf(optarg, "%X/%X", &xlogid, &xrecoff) != 2) { - fprintf(stderr, "%s: could not parse end log position \"%s\"\n", + fprintf(stderr, _("%s: could not parse end log position \"%s\"\n"), progname, optarg); goto bad_argument; } @@ -779,7 +780,7 @@ main(int argc, char **argv) case 'n': if (sscanf(optarg, "%d", &config.stop_after_records) != 1) { - fprintf(stderr, "%s: could not parse limit \"%s\"\n", + fprintf(stderr, _("%s: could not parse limit \"%s\"\n"), progname, optarg); goto bad_argument; } @@ -808,7 +809,7 @@ main(int argc, char **argv) if (config.filter_by_rmgr == -1) { - fprintf(stderr, "%s: resource manager \"%s\" does not exist\n", + fprintf(stderr, _("%s: resource manager \"%s\" does not exist\n"), progname, optarg); goto bad_argument; } @@ -817,7 +818,7 @@ main(int argc, char **argv) case 's': if (sscanf(optarg, "%X/%X", &xlogid, &xrecoff) != 2) { - fprintf(stderr, "%s: could not parse start log position \"%s\"\n", + fprintf(stderr, _("%s: could not parse start log position \"%s\"\n"), progname, optarg); goto bad_argument; } @@ -827,7 +828,7 @@ main(int argc, char **argv) case 't': if (sscanf(optarg, "%d", &private.timeline) != 1) { - fprintf(stderr, "%s: could not parse timeline \"%s\"\n", + fprintf(stderr, _("%s: could not parse timeline \"%s\"\n"), progname, optarg); goto bad_argument; } @@ -839,7 +840,7 @@ main(int argc, char **argv) case 'x': if (sscanf(optarg, "%u", &config.filter_by_xid) != 1) { - fprintf(stderr, "%s: could not parse \"%s\" as a valid xid\n", + fprintf(stderr, _("%s: could not parse \"%s\" as a valid xid\n"), progname, optarg); goto bad_argument; } @@ -854,7 +855,7 @@ main(int argc, char **argv) config.stats_per_record = true; else if (strcmp(optarg, "rmgr") != 0) { - fprintf(stderr, "%s: unrecognised argument to --stats: %s\n", + fprintf(stderr, _("%s: unrecognised argument to --stats: %s\n"), progname, optarg); goto bad_argument; } @@ -868,7 +869,7 @@ main(int argc, char **argv) if ((optind + 2) < argc) { fprintf(stderr, - "%s: too many command-line arguments (first is \"%s\")\n", + _("%s: too many command-line arguments (first is \"%s\")\n"), progname, argv[optind + 2]); goto bad_argument; } @@ -879,7 +880,7 @@ main(int argc, char **argv) if (!verify_directory(private.inpath)) { fprintf(stderr, - "%s: path \"%s\" cannot be opened: %s\n", + _("%s: path \"%s\" cannot be opened: %s\n"), progname, private.inpath, strerror(errno)); goto bad_argument; } @@ -917,7 +918,7 @@ main(int argc, char **argv) else if (!XLByteInSeg(private.startptr, segno)) { fprintf(stderr, - "%s: start log position %X/%X is not inside file \"%s\"\n", + _("%s: start log position %X/%X is not inside file \"%s\"\n"), progname, (uint32) (private.startptr >> 32), (uint32) private.startptr, @@ -961,7 +962,7 @@ main(int argc, char **argv) private.endptr != (segno + 1) * XLogSegSize) { fprintf(stderr, - "%s: end log position %X/%X is not inside file \"%s\"\n", + _("%s: end log position %X/%X is not inside file \"%s\"\n"), progname, (uint32) (private.endptr >> 32), (uint32) private.endptr, @@ -973,7 +974,7 @@ main(int argc, char **argv) /* we don't know what to print */ if (XLogRecPtrIsInvalid(private.startptr)) { - fprintf(stderr, "%s: no start log position given.\n", progname); + fprintf(stderr, _("%s: no start log position given.\n"), progname); goto bad_argument; } @@ -998,7 +999,7 @@ main(int argc, char **argv) * a segment (e.g. we were used in file mode). */ if (first_record != private.startptr && (private.startptr % XLogSegSize) != 0) - printf("first record is after %X/%X, at %X/%X, skipping over %u bytes\n", + printf(_("first record is after %X/%X, at %X/%X, skipping over %u bytes\n"), (uint32) (private.startptr >> 32), (uint32) private.startptr, (uint32) (first_record >> 32), (uint32) first_record, (uint32) (first_record - private.startptr)); @@ -1057,6 +1058,6 @@ main(int argc, char **argv) return EXIT_SUCCESS; bad_argument: - fprintf(stderr, "Try \"%s --help\" for more information.\n", progname); + fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); return EXIT_FAILURE; } -- 2.10.1
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers