Skip to content

Commit e1bdd07

Browse files
committed
Add localization support to ecpg.
Author: Euler Taveira de Oliveira <euler@timbira.com>
1 parent 4eb0900 commit e1bdd07

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1693
-1571
lines changed

src/interfaces/ecpg/compatlib/informix.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/informix.c,v 1.54 2008/01/08 01:14:52 tgl Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/informix.c,v 1.55 2008/05/16 15:20:03 petere Exp $ */
22

33
#define POSTGRES_ECPG_INTERNAL
44
#include "postgres_fe.h"
@@ -1004,7 +1004,7 @@ ECPG_informix_set_var(int number, void *pointer, int lineno)
10041004

10051005
sqlca->sqlcode = ECPG_OUT_OF_MEMORY;
10061006
strncpy(sqlca->sqlstate, "YE001", sizeof("YE001"));
1007-
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc), "Out of memory in line %d.", lineno);
1007+
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc), _("out of memory on line %d"), lineno);
10081008
sqlca->sqlerrm.sqlerrml = strlen(sqlca->sqlerrm.sqlerrmc);
10091009
/* free all memory we have allocated for the user */
10101010
ECPGfree_auto_mem();

src/interfaces/ecpg/ecpglib/connect.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.50 2008/03/27 07:56:00 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.51 2008/05/16 15:20:03 petere Exp $ */
22

33
#define POSTGRES_ECPG_INTERNAL
44
#include "postgres_fe.h"
@@ -144,14 +144,14 @@ ecpg_finish(struct connection * act)
144144
if (actual_connection == act)
145145
actual_connection = all_connections;
146146

147-
ecpg_log("ecpg_finish: Connection %s closed.\n", act->name);
147+
ecpg_log("ecpg_finish: connection %s closed\n", act->name);
148148

149149
for (cache = act->cache_head; cache; ptr = cache, cache = cache->next, ecpg_free(ptr));
150150
ecpg_free(act->name);
151151
ecpg_free(act);
152152
}
153153
else
154-
ecpg_log("ecpg_finish: called an extra time.\n");
154+
ecpg_log("ecpg_finish: called an extra time\n");
155155
}
156156

157157
bool
@@ -163,7 +163,7 @@ ECPGsetcommit(int lineno, const char *mode, const char *connection_name)
163163
if (!ecpg_init(con, connection_name, lineno))
164164
return (false);
165165

166-
ecpg_log("ECPGsetcommit line %d action = %s connection = %s\n", lineno, mode, con->name);
166+
ecpg_log("ECPGsetcommit on line %d: action \"%s\"; connection \"%s\"\n", lineno, mode, con->name);
167167

168168
if (con->autocommit == true && strncmp(mode, "off", strlen("off")) == 0)
169169
{
@@ -223,13 +223,13 @@ ECPGnoticeReceiver(void *arg, const PGresult *result)
223223
sqlstate = ECPG_SQLSTATE_ECPG_INTERNAL_ERROR;
224224

225225
if (message == NULL) /* Shouldn't happen, but need to be sure */
226-
message = "No message received";
226+
message = _("No message received");
227227

228228
/* these are not warnings */
229229
if (strncmp(sqlstate, "00", 2) == 0)
230230
return;
231231

232-
ecpg_log("ECPGnoticeReceiver %s\n", message);
232+
ecpg_log("ECPGnoticeReceiver: %s\n", message);
233233

234234
/* map to SQLCODE for backward compatibility */
235235
if (strcmp(sqlstate, ECPG_SQLSTATE_INVALID_CURSOR_NAME) == 0)
@@ -377,8 +377,8 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
377377
host = ecpg_strdup(tmp + 1, lineno);
378378
if (strncmp(dbname, "unix:", 5) != 0)
379379
{
380-
ecpg_log("ECPGconnect: socketname %s given for TCP connection in line %d\n", host, lineno);
381-
ecpg_raise(lineno, ECPG_CONNECT, ECPG_SQLSTATE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION, realname ? realname : "<DEFAULT>");
380+
ecpg_log("ECPGconnect: socketname %s given for TCP connection on line %d\n", host, lineno);
381+
ecpg_raise(lineno, ECPG_CONNECT, ECPG_SQLSTATE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION, realname ? realname : _("<DEFAULT>"));
382382
if (host)
383383
ecpg_free(host);
384384

@@ -403,8 +403,8 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
403403
{
404404
if (strcmp(dbname + offset, "localhost") != 0 && strcmp(dbname + offset, "127.0.0.1") != 0)
405405
{
406-
ecpg_log("ECPGconnect: non-localhost access via sockets in line %d\n", lineno);
407-
ecpg_raise(lineno, ECPG_CONNECT, ECPG_SQLSTATE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION, realname ? realname : "<DEFAULT>");
406+
ecpg_log("ECPGconnect: non-localhost access via sockets on line %d\n", lineno);
407+
ecpg_raise(lineno, ECPG_CONNECT, ECPG_SQLSTATE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION, realname ? realname : _("<DEFAULT>"));
408408
if (host)
409409
ecpg_free(host);
410410
if (port)
@@ -471,11 +471,11 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
471471
actual_connection = all_connections;
472472

473473
ecpg_log("ECPGconnect: opening database %s on %s port %s %s%s %s%s\n",
474-
realname ? realname : "<DEFAULT>",
475-
host ? host : "<DEFAULT>",
476-
port ? (ecpg_internal_regression_mode ? "<REGRESSION_PORT>" : port) : "<DEFAULT>",
477-
options ? "with options " : "", options ? options : "",
478-
user ? "for user " : "", user ? user : "");
474+
realname ? realname : _("<DEFAULT>"),
475+
host ? host : _("<DEFAULT>"),
476+
port ? (ecpg_internal_regression_mode ? _("<REGRESSION_PORT>") : port) : _("<DEFAULT>"),
477+
options ? _("with options ") : "", options ? options : "",
478+
user ? _("for user ") : "", user ? user : "");
479479

480480
connect_string = ecpg_alloc( strlen_or_null(host)
481481
+ strlen_or_null(port)
@@ -515,7 +515,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
515515
if (PQstatus(this->connection) == CONNECTION_BAD)
516516
{
517517
const char *errmsg = PQerrorMessage(this->connection);
518-
const char *db = realname ? realname : "<DEFAULT>";
518+
const char *db = realname ? realname : _("<DEFAULT>");
519519

520520
ecpg_log("ECPGconnect: could not open database: %s\n", errmsg);
521521

src/interfaces/ecpg/ecpglib/data.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.40 2007/11/15 21:14:45 momjian Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.41 2008/05/16 15:20:03 petere Exp $ */
22

33
#define POSTGRES_ECPG_INTERNAL
44
#include "postgres_fe.h"
@@ -60,7 +60,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
6060
else
6161
log_offset = offset;
6262

63-
ecpg_log("ecpg_get_data line %d: RESULT: %s offset: %ld array: %s\n", lineno, pval ? (binary ? "BINARY" : pval) : "EMPTY", log_offset, isarray ? "Yes" : "No");
63+
ecpg_log("ecpg_get_data on line %d: RESULT: %s offset: %ld; array: %s\n", lineno, pval ? (binary ? _("BINARY") : pval) : _("EMPTY"), log_offset, isarray ? _("yes") : _("no"));
6464

6565
/* We will have to decode the value */
6666

@@ -360,7 +360,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
360360
else
361361
ecpg_raise(lineno, ECPG_CONVERT_BOOL,
362362
ECPG_SQLSTATE_DATATYPE_MISMATCH,
363-
"different size");
363+
_("different size"));
364364
break;
365365
}
366366
else if (pval[0] == 't' && pval[1] == '\0')
@@ -372,7 +372,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
372372
else
373373
ecpg_raise(lineno, ECPG_CONVERT_BOOL,
374374
ECPG_SQLSTATE_DATATYPE_MISMATCH,
375-
"different size");
375+
_("different size"));
376376
break;
377377
}
378378
else if (pval[0] == '\0' && PQgetisnull(results, act_tuple, act_field))
@@ -490,7 +490,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
490490
/* did we get an error? */
491491
if (nres == NULL)
492492
{
493-
ecpg_log("ecpg_get_data line %d: RESULT: %s errno %d\n",
493+
ecpg_log("ecpg_get_data on line %d: RESULT %s; errno %d\n",
494494
lineno, pval ? pval : "", errno);
495495

496496
if (INFORMIX_MODE(compat))
@@ -553,7 +553,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
553553
/* did we get an error? */
554554
if (ires == NULL)
555555
{
556-
ecpg_log("ecpg_get_data line %d: RESULT: %s errno %d\n",
556+
ecpg_log("ecpg_get_data on line %d: RESULT %s; errno %d\n",
557557
lineno, pval ? pval : "", errno);
558558

559559
if (INFORMIX_MODE(compat))
@@ -607,7 +607,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
607607
/* did we get an error? */
608608
if (errno != 0)
609609
{
610-
ecpg_log("ecpg_get_data line %d: RESULT: %s errno %d\n",
610+
ecpg_log("ecpg_get_data on line %d: RESULT %s; errno %d\n",
611611
lineno, pval ? pval : "", errno);
612612

613613
if (INFORMIX_MODE(compat))
@@ -654,7 +654,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
654654
/* did we get an error? */
655655
if (errno != 0)
656656
{
657-
ecpg_log("ecpg_get_data line %d: RESULT: %s errno %d\n",
657+
ecpg_log("ecpg_get_data on line %d: RESULT %s; errno %d\n",
658658
lineno, pval ? pval : "", errno);
659659

660660
if (INFORMIX_MODE(compat))

src/interfaces/ecpg/ecpglib/descriptor.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* dynamic SQL support routines
22
*
3-
* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/descriptor.c,v 1.29 2008/01/15 10:31:47 meskes Exp $
3+
* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/descriptor.c,v 1.30 2008/05/16 15:20:03 petere Exp $
44
*/
55

66
#define POSTGRES_ECPG_INTERNAL
@@ -99,7 +99,7 @@ ECPGget_desc_header(int lineno, const char *desc_name, int *count)
9999

100100
*count = PQnfields(ECPGresult);
101101
sqlca->sqlerrd[2] = 1;
102-
ecpg_log("ECPGget_desc_header: found %d attributes.\n", *count);
102+
ecpg_log("ECPGget_desc_header: found %d attributes\n", *count);
103103
return true;
104104
}
105105

@@ -381,7 +381,7 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
381381
*/
382382
if (arrsize > 0 && ntuples > arrsize)
383383
{
384-
ecpg_log("ECPGget_desc line %d: Incorrect number of matches: %d don't fit into array of %d\n",
384+
ecpg_log("ECPGget_desc on line %d: incorrect number of matches; %d don't fit into array of %d\n",
385385
lineno, ntuples, arrsize);
386386
ecpg_raise(lineno, ECPG_TOO_MANY_MATCHES, ECPG_SQLSTATE_CARDINALITY_VIOLATION, NULL);
387387
return false;
@@ -450,7 +450,7 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
450450
*/
451451
if (data_var.ind_arrsize > 0 && ntuples > data_var.ind_arrsize)
452452
{
453-
ecpg_log("ECPGget_desc line %d: Incorrect number of matches (indicator): %d don't fit into array of %d\n",
453+
ecpg_log("ECPGget_desc on line %d: incorrect number of matches (indicator); %d don't fit into array of %d\n",
454454
lineno, ntuples, data_var.ind_arrsize);
455455
ecpg_raise(lineno, ECPG_TOO_MANY_MATCHES, ECPG_SQLSTATE_CARDINALITY_VIOLATION, NULL);
456456
return false;
@@ -724,6 +724,6 @@ ecpg_find_desc(int line, const char *name)
724724
bool
725725
ECPGdescribe(int line, bool input, const char *statement,...)
726726
{
727-
ecpg_log("ECPGdescribe called on line %d for %s in %s\n", line, (input) ? "input" : "output", statement);
727+
ecpg_log("ECPGdescribe called on line %d for %s: %s\n", line, (input) ? _("input") : _("output"), statement);
728728
return false;
729729
}

0 commit comments

Comments
 (0)