Skip to content

Commit 77517ba

Browse files
committed
pg_upgrade: Add NLS
Reviewed-by: Michael Paquier <[email protected]>
1 parent 48dbcbf commit 77517ba

File tree

8 files changed

+75
-63
lines changed

8 files changed

+75
-63
lines changed

src/bin/pg_upgrade/function.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ check_loadable_libraries(void)
252252
if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
253253
pg_fatal("could not open file \"%s\": %s\n",
254254
output_path, strerror(errno));
255-
fprintf(script, "could not load library \"%s\":\n%s\n",
255+
fprintf(script, _("could not load library \"%s\":\n%s\n"),
256256
lib,
257257
PQerrorMessage(conn));
258258
}

src/bin/pg_upgrade/info.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ report_unmatched_relation(const RelInfo *rel, const DbInfo *db, bool is_new_db)
238238
{
239239
snprintf(reldesc + strlen(reldesc),
240240
sizeof(reldesc) - strlen(reldesc),
241-
" which is an index on \"%s.%s\"",
241+
_(" which is an index on \"%s.%s\""),
242242
hrel->nspname, hrel->relname);
243243
/* Shift attention to index's table for toast check */
244244
rel = hrel;
@@ -248,7 +248,7 @@ report_unmatched_relation(const RelInfo *rel, const DbInfo *db, bool is_new_db)
248248
if (i >= db->rel_arr.nrels)
249249
snprintf(reldesc + strlen(reldesc),
250250
sizeof(reldesc) - strlen(reldesc),
251-
" which is an index on OID %u", rel->indtable);
251+
_(" which is an index on OID %u"), rel->indtable);
252252
}
253253
if (rel->toastheap)
254254
{
@@ -260,15 +260,15 @@ report_unmatched_relation(const RelInfo *rel, const DbInfo *db, bool is_new_db)
260260
{
261261
snprintf(reldesc + strlen(reldesc),
262262
sizeof(reldesc) - strlen(reldesc),
263-
" which is the TOAST table for \"%s.%s\"",
263+
_(" which is the TOAST table for \"%s.%s\""),
264264
brel->nspname, brel->relname);
265265
break;
266266
}
267267
}
268268
if (i >= db->rel_arr.nrels)
269269
snprintf(reldesc + strlen(reldesc),
270270
sizeof(reldesc) - strlen(reldesc),
271-
" which is the TOAST table for OID %u", rel->toastheap);
271+
_(" which is the TOAST table for OID %u"), rel->toastheap);
272272
}
273273

274274
if (is_new_db)

src/bin/pg_upgrade/nls.mk

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# src/bin/pg_upgrade/nls.mk
2+
CATALOG_NAME = pg_upgrade
3+
AVAIL_LANGUAGES =
4+
GETTEXT_FILES = check.c controldata.c dump.c exec.c file.c function.c \
5+
info.c option.c parallel.c pg_upgrade.c relfilenode.c \
6+
server.c tablespace.c util.c version.c
7+
GETTEXT_TRIGGERS = pg_fatal pg_log:2 prep_status report_status:2
8+
GETTEXT_FLAGS = \
9+
pg_fatal:1:c-format \
10+
pg_log:2:c-format \
11+
prep_status:1:c-format \
12+
report_status:2:c-format

src/bin/pg_upgrade/option.c

+49-52
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,13 @@ parseCommandLine(int argc, char *argv[])
240240

241241
/* Get values from env if not already set */
242242
check_required_directory(&old_cluster.bindir, NULL, "PGBINOLD", "-b",
243-
"old cluster binaries reside");
243+
_("old cluster binaries reside"));
244244
check_required_directory(&new_cluster.bindir, NULL, "PGBINNEW", "-B",
245-
"new cluster binaries reside");
245+
_("new cluster binaries reside"));
246246
check_required_directory(&old_cluster.pgdata, &old_cluster.pgconfig,
247-
"PGDATAOLD", "-d", "old cluster data resides");
247+
"PGDATAOLD", "-d", _("old cluster data resides"));
248248
check_required_directory(&new_cluster.pgdata, &new_cluster.pgconfig,
249-
"PGDATANEW", "-D", "new cluster data resides");
249+
"PGDATANEW", "-D", _("new cluster data resides"));
250250

251251
#ifdef WIN32
252252

@@ -275,56 +275,53 @@ parseCommandLine(int argc, char *argv[])
275275
static void
276276
usage(void)
277277
{
278-
printf(_("pg_upgrade upgrades a PostgreSQL cluster to a different major version.\n\
279-
\nUsage:\n\
280-
pg_upgrade [OPTION]...\n\
281-
\n\
282-
Options:\n\
283-
-b, --old-bindir=BINDIR old cluster executable directory\n\
284-
-B, --new-bindir=BINDIR new cluster executable directory\n\
285-
-c, --check check clusters only, don't change any data\n\
286-
-d, --old-datadir=DATADIR old cluster data directory\n\
287-
-D, --new-datadir=DATADIR new cluster data directory\n\
288-
-j, --jobs number of simultaneous processes or threads to use\n\
289-
-k, --link link instead of copying files to new cluster\n\
290-
-o, --old-options=OPTIONS old cluster options to pass to the server\n\
291-
-O, --new-options=OPTIONS new cluster options to pass to the server\n\
292-
-p, --old-port=PORT old cluster port number (default %d)\n\
293-
-P, --new-port=PORT new cluster port number (default %d)\n\
294-
-r, --retain retain SQL and log files after success\n\
295-
-U, --username=NAME cluster superuser (default \"%s\")\n\
296-
-v, --verbose enable verbose internal logging\n\
297-
-V, --version display version information, then exit\n\
298-
-?, --help show this help, then exit\n\
299-
\n\
300-
Before running pg_upgrade you must:\n\
301-
create a new database cluster (using the new version of initdb)\n\
302-
shutdown the postmaster servicing the old cluster\n\
303-
shutdown the postmaster servicing the new cluster\n\
304-
\n\
305-
When you run pg_upgrade, you must provide the following information:\n\
306-
the data directory for the old cluster (-d DATADIR)\n\
307-
the data directory for the new cluster (-D DATADIR)\n\
308-
the \"bin\" directory for the old version (-b BINDIR)\n\
309-
the \"bin\" directory for the new version (-B BINDIR)\n\
310-
\n\
311-
For example:\n\
312-
pg_upgrade -d oldCluster/data -D newCluster/data -b oldCluster/bin -B newCluster/bin\n\
313-
or\n"), old_cluster.port, new_cluster.port, os_info.user);
278+
printf(_("pg_upgrade upgrades a PostgreSQL cluster to a different major version.\n\n"));
279+
printf(_("Usage:\n"));
280+
printf(_(" pg_upgrade [OPTION]...\n\n"));
281+
printf(_("Options:\n"));
282+
printf(_(" -b, --old-bindir=BINDIR old cluster executable directory\n"));
283+
printf(_(" -B, --new-bindir=BINDIR new cluster executable directory\n"));
284+
printf(_(" -c, --check check clusters only, don't change any data\n"));
285+
printf(_(" -d, --old-datadir=DATADIR old cluster data directory\n"));
286+
printf(_(" -D, --new-datadir=DATADIR new cluster data directory\n"));
287+
printf(_(" -j, --jobs number of simultaneous processes or threads to use\n"));
288+
printf(_(" -k, --link link instead of copying files to new cluster\n"));
289+
printf(_(" -o, --old-options=OPTIONS old cluster options to pass to the server\n"));
290+
printf(_(" -O, --new-options=OPTIONS new cluster options to pass to the server\n"));
291+
printf(_(" -p, --old-port=PORT old cluster port number (default %d)\n"), old_cluster.port);
292+
printf(_(" -P, --new-port=PORT new cluster port number (default %d)\n"), new_cluster.port);
293+
printf(_(" -r, --retain retain SQL and log files after success\n"));
294+
printf(_(" -U, --username=NAME cluster superuser (default \"%s\")\n"), os_info.user);
295+
printf(_(" -v, --verbose enable verbose internal logging\n"));
296+
printf(_(" -V, --version display version information, then exit\n"));
297+
printf(_(" -?, --help show this help, then exit\n"));
298+
printf(_("\n"
299+
"Before running pg_upgrade you must:\n"
300+
" create a new database cluster (using the new version of initdb)\n"
301+
" shutdown the postmaster servicing the old cluster\n"
302+
" shutdown the postmaster servicing the new cluster\n"));
303+
printf(_("\n"
304+
"When you run pg_upgrade, you must provide the following information:\n"
305+
" the data directory for the old cluster (-d DATADIR)\n"
306+
" the data directory for the new cluster (-D DATADIR)\n"
307+
" the \"bin\" directory for the old version (-b BINDIR)\n"
308+
" the \"bin\" directory for the new version (-B BINDIR)\n"));
309+
printf(_("\n"
310+
"For example:\n"
311+
" pg_upgrade -d oldCluster/data -D newCluster/data -b oldCluster/bin -B newCluster/bin\n"
312+
"or\n"));
314313
#ifndef WIN32
315-
printf(_("\
316-
$ export PGDATAOLD=oldCluster/data\n\
317-
$ export PGDATANEW=newCluster/data\n\
318-
$ export PGBINOLD=oldCluster/bin\n\
319-
$ export PGBINNEW=newCluster/bin\n\
320-
$ pg_upgrade\n"));
314+
printf(_(" $ export PGDATAOLD=oldCluster/data\n"
315+
" $ export PGDATANEW=newCluster/data\n"
316+
" $ export PGBINOLD=oldCluster/bin\n"
317+
" $ export PGBINNEW=newCluster/bin\n"
318+
" $ pg_upgrade\n"));
321319
#else
322-
printf(_("\
323-
C:\\> set PGDATAOLD=oldCluster/data\n\
324-
C:\\> set PGDATANEW=newCluster/data\n\
325-
C:\\> set PGBINOLD=oldCluster/bin\n\
326-
C:\\> set PGBINNEW=newCluster/bin\n\
327-
C:\\> pg_upgrade\n"));
320+
printf(_(" C:\\> set PGDATAOLD=oldCluster/data\n"
321+
" C:\\> set PGDATANEW=newCluster/data\n"
322+
" C:\\> set PGBINOLD=oldCluster/bin\n"
323+
" C:\\> set PGBINNEW=newCluster/bin\n"
324+
" C:\\> pg_upgrade\n"));
328325
#endif
329326
printf(_("\nReport bugs to <[email protected]>.\n"));
330327
}

src/bin/pg_upgrade/pg_upgrade.c

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ main(int argc, char **argv)
7575
char *deletion_script_file_name = NULL;
7676
bool live_check = false;
7777

78+
set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_upgrade"));
7879
parseCommandLine(argc, argv);
7980

8081
get_restricted_token(os_info.progname);

src/bin/pg_upgrade/relfilenode.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ void
3030
transfer_all_new_tablespaces(DbInfoArr *old_db_arr, DbInfoArr *new_db_arr,
3131
char *old_pgdata, char *new_pgdata)
3232
{
33-
pg_log(PG_REPORT, "%s user relation files\n",
34-
user_opts.transfer_mode == TRANSFER_MODE_LINK ? "Linking" : "Copying");
33+
if (user_opts.transfer_mode == TRANSFER_MODE_LINK)
34+
pg_log(PG_REPORT, "Linking user relation files\n");
35+
else
36+
pg_log(PG_REPORT, "Copying user relation files\n");
3537

3638
/*
3739
* Transferring files by tablespace is tricky because a single database

src/bin/pg_upgrade/server.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ connectToServer(ClusterInfo *cluster, const char *db_name)
3636
if (conn)
3737
PQfinish(conn);
3838

39-
printf("Failure, exiting\n");
39+
printf(_("Failure, exiting\n"));
4040
exit(1);
4141
}
4242

@@ -136,7 +136,7 @@ executeQueryOrDie(PGconn *conn, const char *fmt,...)
136136
PQerrorMessage(conn));
137137
PQclear(result);
138138
PQfinish(conn);
139-
printf("Failure, exiting\n");
139+
printf(_("Failure, exiting\n"));
140140
exit(1);
141141
}
142142
else

src/bin/pg_upgrade/util.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ pg_log_v(eLogType type, const char *fmt, va_list ap)
133133

134134
case PG_FATAL:
135135
printf("\n%s", message);
136-
printf("Failure, exiting\n");
136+
printf(_("Failure, exiting\n"));
137137
exit(1);
138138
break;
139139

@@ -163,7 +163,7 @@ pg_fatal(const char *fmt,...)
163163
va_start(args, fmt);
164164
pg_log_v(PG_FATAL, fmt, args);
165165
va_end(args);
166-
printf("Failure, exiting\n");
166+
printf(_("Failure, exiting\n"));
167167
exit(1);
168168
}
169169

0 commit comments

Comments
 (0)