Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8032d76

Browse files
committed
Gettext plural support
In the backend, I changed only a handful of exemplary or important-looking instances to make use of the plural support; there is probably more work there. For the rest of the source, this should cover all relevant cases.
1 parent 845693f commit 8032d76

File tree

15 files changed

+105
-53
lines changed

15 files changed

+105
-53
lines changed

src/backend/catalog/dependency.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/catalog/dependency.c,v 1.86 2009/01/22 20:16:00 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/catalog/dependency.c,v 1.87 2009/03/26 22:26:06 petere Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -885,8 +885,11 @@ reportDependentObjects(const ObjectAddresses *targetObjects,
885885
}
886886

887887
if (numNotReportedClient > 0)
888-
appendStringInfo(&clientdetail, _("\nand %d other objects "
889-
"(see server log for list)"),
888+
appendStringInfo(&clientdetail, ngettext("\nand %d other object "
889+
"(see server log for list)",
890+
"\nand %d other objects "
891+
"(see server log for list)",
892+
numNotReportedClient),
890893
numNotReportedClient);
891894

892895
if (!ok)
@@ -911,7 +914,9 @@ reportDependentObjects(const ObjectAddresses *targetObjects,
911914
{
912915
ereport(msglevel,
913916
/* translator: %d always has a value larger than 1 */
914-
(errmsg("drop cascades to %d other objects",
917+
(errmsg(ngettext("drop cascades to %d other object",
918+
"drop cascades to %d other objects",
919+
numReportedClient + numNotReportedClient),
915920
numReportedClient + numNotReportedClient),
916921
errdetail("%s", clientdetail.data),
917922
errdetail_log("%s", logdetail.data)));

src/backend/catalog/pg_proc.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/catalog/pg_proc.c,v 1.161 2009/01/22 20:16:01 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/catalog/pg_proc.c,v 1.162 2009/03/26 22:26:06 petere Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -112,7 +112,9 @@ ProcedureCreate(const char *procedureName,
112112
if (parameterCount < 0 || parameterCount > FUNC_MAX_ARGS)
113113
ereport(ERROR,
114114
(errcode(ERRCODE_TOO_MANY_ARGUMENTS),
115-
errmsg("functions cannot have more than %d arguments",
115+
errmsg(ngettext("functions cannot have more than %d argument",
116+
"functions cannot have more than %d arguments",
117+
FUNC_MAX_ARGS),
116118
FUNC_MAX_ARGS)));
117119
/* note: the above is correct, we do NOT count output arguments */
118120

src/backend/catalog/pg_shdepend.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/catalog/pg_shdepend.c,v 1.31 2009/01/22 20:16:01 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/catalog/pg_shdepend.c,v 1.32 2009/03/26 22:26:06 petere Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -655,12 +655,18 @@ checkSharedDependencies(Oid classId, Oid objectId,
655655
}
656656

657657
if (numNotReportedDeps > 0)
658-
appendStringInfo(&descs, _("\nand %d other objects "
659-
"(see server log for list)"),
658+
appendStringInfo(&descs, ngettext("\nand %d other object "
659+
"(see server log for list)",
660+
"\nand %d other objects "
661+
"(see server log for list)",
662+
numNotReportedDeps),
660663
numNotReportedDeps);
661664
if (numNotReportedDbs > 0)
662-
appendStringInfo(&descs, _("\nand objects in %d other databases "
663-
"(see server log for list)"),
665+
appendStringInfo(&descs, ngettext("\nand objects in %d other database "
666+
"(see server log for list)",
667+
"\nand objects in %d other databases "
668+
"(see server log for list)",
669+
numNotReportedDbs),
664670
numNotReportedDbs);
665671

666672
*detail_msg = descs.data;
@@ -1043,7 +1049,7 @@ storeObjectDescription(StringInfo descs, objectType type,
10431049

10441050
case REMOTE_OBJECT:
10451051
/* translator: %s will always be "database %s" */
1046-
appendStringInfo(descs, _("%d objects in %s"), count, objdesc);
1052+
appendStringInfo(descs, ngettext("%d object in %s", "%d objects in %s", count), count, objdesc);
10471053
break;
10481054

10491055
default:

src/backend/executor/execQual.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.241 2009/01/09 15:46:10 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.242 2009/03/26 22:26:06 petere Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -616,7 +616,9 @@ ExecEvalVar(ExprState *exprstate, ExprContext *econtext,
616616
ereport(ERROR,
617617
(errcode(ERRCODE_DATATYPE_MISMATCH),
618618
errmsg("table row type and query-specified row type do not match"),
619-
errdetail("Table row contains %d attributes, but query expects %d.",
619+
errdetail(ngettext("Table row contains %d attribute, but query expects %d.",
620+
"Table row contains %d attributes, but query expects %d.",
621+
slot_tupdesc->natts),
620622
slot_tupdesc->natts, var_tupdesc->natts)));
621623
else if (var_tupdesc->natts < slot_tupdesc->natts)
622624
needslow = true;
@@ -1041,7 +1043,9 @@ init_fcache(Oid foid, FuncExprState *fcache,
10411043
if (list_length(fcache->args) > FUNC_MAX_ARGS)
10421044
ereport(ERROR,
10431045
(errcode(ERRCODE_TOO_MANY_ARGUMENTS),
1044-
errmsg("cannot pass more than %d arguments to a function",
1046+
errmsg(ngettext("cannot pass more than %d argument to a function",
1047+
"cannot pass more than %d arguments to a function",
1048+
FUNC_MAX_ARGS),
10451049
FUNC_MAX_ARGS)));
10461050

10471051
/* Set up the primary fmgr lookup information */
@@ -1310,7 +1314,9 @@ tupledesc_match(TupleDesc dst_tupdesc, TupleDesc src_tupdesc)
13101314
ereport(ERROR,
13111315
(errcode(ERRCODE_DATATYPE_MISMATCH),
13121316
errmsg("function return row and query-specified return row do not match"),
1313-
errdetail("Returned row contains %d attributes, but query expects %d.",
1317+
errdetail(ngettext("Returned row contains %d attribute, but query expects %d.",
1318+
"Returned row contains %d attributes, but query expects %d.",
1319+
src_tupdesc->natts),
13141320
src_tupdesc->natts, dst_tupdesc->natts)));
13151321

13161322
for (i = 0; i < dst_tupdesc->natts; i++)

src/backend/parser/parse_func.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/parser/parse_func.c,v 1.211 2009/01/01 17:23:45 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/parser/parse_func.c,v 1.212 2009/03/26 22:26:06 petere Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -89,7 +89,9 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
8989
if (list_length(fargs) > FUNC_MAX_ARGS)
9090
ereport(ERROR,
9191
(errcode(ERRCODE_TOO_MANY_ARGUMENTS),
92-
errmsg("cannot pass more than %d arguments to a function",
92+
errmsg(ngettext("cannot pass more than %d argument to a function",
93+
"cannot pass more than %d arguments to a function",
94+
FUNC_MAX_ARGS),
9395
FUNC_MAX_ARGS),
9496
parser_errposition(pstate, location)));
9597

@@ -259,7 +261,9 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
259261
if (nargsplusdefs >= FUNC_MAX_ARGS)
260262
ereport(ERROR,
261263
(errcode(ERRCODE_TOO_MANY_ARGUMENTS),
262-
errmsg("cannot pass more than %d arguments to a function",
264+
errmsg(ngettext("cannot pass more than %d argument to a function",
265+
"cannot pass more than %d arguments to a function",
266+
FUNC_MAX_ARGS),
263267
FUNC_MAX_ARGS),
264268
parser_errposition(pstate, location)));
265269

@@ -538,7 +542,9 @@ func_select_candidate(int nargs,
538542
if (nargs > FUNC_MAX_ARGS)
539543
ereport(ERROR,
540544
(errcode(ERRCODE_TOO_MANY_ARGUMENTS),
541-
errmsg("cannot pass more than %d arguments to a function",
545+
errmsg(ngettext("cannot pass more than %d argument to a function",
546+
"cannot pass more than %d arguments to a function",
547+
FUNC_MAX_ARGS),
542548
FUNC_MAX_ARGS)));
543549

544550
/*
@@ -1413,7 +1419,9 @@ LookupFuncNameTypeNames(List *funcname, List *argtypes, bool noError)
14131419
if (argcount > FUNC_MAX_ARGS)
14141420
ereport(ERROR,
14151421
(errcode(ERRCODE_TOO_MANY_ARGUMENTS),
1416-
errmsg("functions cannot have more than %d arguments",
1422+
errmsg(ngettext("functions cannot have more than %d argument",
1423+
"functions cannot have more than %d arguments",
1424+
FUNC_MAX_ARGS),
14171425
FUNC_MAX_ARGS)));
14181426

14191427
args_item = list_head(argtypes);
@@ -1451,7 +1459,9 @@ LookupAggNameTypeNames(List *aggname, List *argtypes, bool noError)
14511459
if (argcount > FUNC_MAX_ARGS)
14521460
ereport(ERROR,
14531461
(errcode(ERRCODE_TOO_MANY_ARGUMENTS),
1454-
errmsg("functions cannot have more than %d arguments",
1462+
errmsg(ngettext("functions cannot have more than %d argument",
1463+
"functions cannot have more than %d arguments",
1464+
FUNC_MAX_ARGS),
14551465
FUNC_MAX_ARGS)));
14561466

14571467
i = 0;

src/backend/postmaster/bgwriter.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $PostgreSQL: pgsql/src/backend/postmaster/bgwriter.c,v 1.56 2009/02/18 15:58:41 heikki Exp $
40+
* $PostgreSQL: pgsql/src/backend/postmaster/bgwriter.c,v 1.57 2009/03/26 22:26:06 petere Exp $
4141
*
4242
*-------------------------------------------------------------------------
4343
*/
@@ -459,7 +459,9 @@ BackgroundWriterMain(void)
459459
(flags & CHECKPOINT_CAUSE_XLOG) &&
460460
elapsed_secs < CheckPointWarning)
461461
ereport(LOG,
462-
(errmsg("checkpoints are occurring too frequently (%d seconds apart)",
462+
(errmsg(ngettext("checkpoints are occurring too frequently (%d second apart)",
463+
"checkpoints are occurring too frequently (%d seconds apart)",
464+
elapsed_secs),
463465
elapsed_secs),
464466
errhint("Consider increasing the configuration parameter \"checkpoint_segments\".")));
465467

src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.168 2009/03/20 09:21:08 petere Exp $
18+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.169 2009/03/26 22:26:07 petere Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -884,7 +884,10 @@ EndRestoreBlobs(ArchiveHandle *AH)
884884
ahprintf(AH, "COMMIT;\n\n");
885885
}
886886

887-
ahlog(AH, 1, "restored %d large objects\n", AH->blobCount);
887+
ahlog(AH, 1, ngettext("restored %d large object\n",
888+
"restored %d large objects\n",
889+
AH->blobCount),
890+
AH->blobCount);
888891
}
889892

890893

@@ -1230,7 +1233,9 @@ dump_lo_buf(ArchiveHandle *AH)
12301233
size_t res;
12311234

12321235
res = lo_write(AH->connection, AH->loFd, AH->lo_buf, AH->lo_buf_used);
1233-
ahlog(AH, 5, "wrote %lu bytes of large object data (result = %lu)\n",
1236+
ahlog(AH, 5, ngettext("wrote %lu byte of large object data (result = %lu)\n",
1237+
"wrote %lu bytes of large object data (result = %lu)\n",
1238+
AH->lo_buf_used),
12341239
(unsigned long) AH->lo_buf_used, (unsigned long) res);
12351240
if (res != AH->lo_buf_used)
12361241
die_horribly(AH, modulename,
@@ -1781,7 +1786,9 @@ _discoverArchiveFormat(ArchiveHandle *AH)
17811786
AH->lookaheadLen = 0; /* Don't bother since we've reset the file */
17821787

17831788
#if 0
1784-
write_msg(modulename, "read %lu bytes into lookahead buffer\n",
1789+
write_msg(modulename, ngettext("read %lu byte into lookahead buffer\n",
1790+
"read %lu bytes into lookahead buffer\n",
1791+
AH->lookaheadLen),
17851792
(unsigned long) AH->lookaheadLen);
17861793
#endif
17871794

src/bin/pg_dump/pg_backup_tar.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
*
1818
* IDENTIFICATION
19-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.63 2009/02/02 20:07:37 adunstan Exp $
19+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.64 2009/03/26 22:26:07 petere Exp $
2020
*
2121
*-------------------------------------------------------------------------
2222
*/
@@ -550,7 +550,9 @@ _tarReadRaw(ArchiveHandle *AH, void *buf, size_t len, TAR_MEMBER *th, FILE *fh)
550550
}
551551

552552
#if 0
553-
write_msg(modulename, "requested %d bytes, got %d from lookahead and %d from file\n",
553+
write_msg(modulename, ngettext("requested %d byte, got %d from lookahead and %d from file\n",
554+
"requested %d bytes, got %d from lookahead and %d from file\n",
555+
reqLen),
554556
reqLen, used, res);
555557
#endif
556558

@@ -1246,7 +1248,9 @@ _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th)
12461248

12471249
if (len != 512)
12481250
die_horribly(AH, modulename,
1249-
"incomplete tar header found (%lu bytes)\n",
1251+
ngettext("incomplete tar header found (%lu byte)\n",
1252+
"incomplete tar header found (%lu bytes)\n",
1253+
len),
12501254
(unsigned long) len);
12511255

12521256
/* Calc checksum */

src/bin/pg_dump/pg_dump.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* by PostgreSQL
1313
*
1414
* IDENTIFICATION
15-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.530 2009/03/22 16:44:26 tgl Exp $
15+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.531 2009/03/26 22:26:07 petere Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -5004,7 +5004,9 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
50045004
numConstrs = PQntuples(res);
50055005
if (numConstrs != tbinfo->ncheck)
50065006
{
5007-
write_msg(NULL, "expected %d check constraints on table \"%s\" but found %d\n",
5007+
write_msg(NULL, ngettext("expected %d check constraint on table \"%s\" but found %d\n",
5008+
"expected %d check constraints on table \"%s\" but found %d\n",
5009+
tbinfo->ncheck),
50085010
tbinfo->ncheck, tbinfo->dobj.name, numConstrs);
50095011
write_msg(NULL, "(The system catalogs might be corrupted.)\n");
50105012
exit_nicely();
@@ -6335,7 +6337,9 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
63356337
ntups = PQntuples(res);
63366338
if (ntups != 1)
63376339
{
6338-
write_msg(NULL, "query returned %d rows instead of one: %s\n",
6340+
write_msg(NULL, ngettext("query returned %d row instead of one: %s\n",
6341+
"query returned %d rows instead of one: %s\n",
6342+
ntups),
63396343
ntups, query->data);
63406344
exit_nicely();
63416345
}
@@ -6532,7 +6536,9 @@ dumpDomain(Archive *fout, TypeInfo *tinfo)
65326536
ntups = PQntuples(res);
65336537
if (ntups != 1)
65346538
{
6535-
write_msg(NULL, "query returned %d rows instead of one: %s\n",
6539+
write_msg(NULL, ngettext("query returned %d row instead of one: %s\n",
6540+
"query returned %d rows instead of one: %s\n",
6541+
ntups),
65366542
ntups, query->data);
65376543
exit_nicely();
65386544
}
@@ -7181,7 +7187,9 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
71817187
ntups = PQntuples(res);
71827188
if (ntups != 1)
71837189
{
7184-
write_msg(NULL, "query returned %d rows instead of one: %s\n",
7190+
write_msg(NULL, ngettext("query returned %d row instead of one: %s\n",
7191+
"query returned %d rows instead of one: %s\n",
7192+
ntups),
71857193
ntups, query->data);
71867194
exit_nicely();
71877195
}
@@ -10518,7 +10526,9 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
1051810526

1051910527
if (PQntuples(res) != 1)
1052010528
{
10521-
write_msg(NULL, "query to get data of sequence \"%s\" returned %d rows (expected 1)\n",
10529+
write_msg(NULL, ngettext("query to get data of sequence \"%s\" returned %d row (expected 1)\n",
10530+
"query to get data of sequence \"%s\" returned %d rows (expected 1)\n",
10531+
PQntuples(res)),
1052210532
tbinfo->dobj.name, PQntuples(res));
1052310533
exit_nicely();
1052410534
}

src/bin/psql/describe.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
* Copyright (c) 2000-2009, PostgreSQL Global Development Group
1010
*
11-
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.202 2009/03/25 13:11:43 petere Exp $
11+
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.203 2009/03/26 22:26:07 petere Exp $
1212
*/
1313
#include "postgres_fe.h"
1414

@@ -1891,10 +1891,8 @@ describeRoles(const char *pattern, bool verbose)
18911891

18921892
if (conns == 0)
18931893
appendPQExpBuffer(&buf, _("No connections"));
1894-
else if (conns == 1)
1895-
appendPQExpBuffer(&buf, _("1 connection"));
18961894
else
1897-
appendPQExpBuffer(&buf, _("%d connections"), conns);
1895+
appendPQExpBuffer(&buf, ngettext("1 connection", "%d connections", conns), conns);
18981896
}
18991897

19001898
attr[i] = pg_strdup(buf.data);

0 commit comments

Comments
 (0)