aboutsummaryrefslogtreecommitdiff
path: root/src/bin/scripts/createlang.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2007-12-12 21:41:47 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2007-12-12 21:41:47 +0000
commitdf4271fedd3a3428ffafb9c2cff7de37e13976a0 (patch)
tree7bae4d81aa5a895c4a9402428f500992f700bc2a /src/bin/scripts/createlang.c
parent286049dbe4e2763412ef71f62c61b2b297aed6cc (diff)
downloadpostgresql-df4271fedd3a3428ffafb9c2cff7de37e13976a0.tar.gz
postgresql-df4271fedd3a3428ffafb9c2cff7de37e13976a0.zip
Improve the method of localizing column names and other fixed strings in
psql's \d commands and other uses of printQuery(). Previously we would pass these strings through gettext() and then send them to the server as literals in the SQL query. But the code was not set up to handle doubling of quotes in the strings, causing failure if a translation attempted to use the wrong kind of quote marks, as indeed is now the case for (at least) the French translation of \dFp. Another hazard was that gettext() would translate to whatever encoding was implied by the client's LC_CTYPE setting, which might be different from the client_encoding setting, which would probably cause the server to reject the query as mis-encoded. The new arrangement is to send the untranslated ASCII strings to the server, and do the translations inside printQuery() after the query results come back. Per report from Guillaume Lelarge and subsequent discussion.
Diffstat (limited to 'src/bin/scripts/createlang.c')
-rw-r--r--src/bin/scripts/createlang.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/bin/scripts/createlang.c b/src/bin/scripts/createlang.c
index 6fe6f25e6f3..3c0838e32a3 100644
--- a/src/bin/scripts/createlang.c
+++ b/src/bin/scripts/createlang.c
@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/scripts/createlang.c,v 1.27 2007/12/11 19:57:32 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/createlang.c,v 1.28 2007/12/12 21:41:47 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -125,6 +125,7 @@ main(int argc, char *argv[])
if (listlangs)
{
printQueryOpt popt;
+ static const bool trans_columns[] = {false, true};
conn = connectDatabase(dbname, host, port, username, password,
progname);
@@ -132,7 +133,9 @@ main(int argc, char *argv[])
printfPQExpBuffer(&sql, "SELECT lanname as \"%s\", "
"(CASE WHEN lanpltrusted THEN '%s' ELSE '%s' END) as \"%s\" "
"FROM pg_catalog.pg_language WHERE lanispl;",
- _("Name"), _("yes"), _("no"), _("Trusted?"));
+ gettext_noop("Name"),
+ gettext_noop("yes"), gettext_noop("no"),
+ gettext_noop("Trusted?"));
result = executeQuery(conn, sql.data, progname, echo);
memset(&popt, 0, sizeof(popt));
@@ -142,6 +145,8 @@ main(int argc, char *argv[])
popt.topt.stop_table = true;
popt.topt.encoding = PQclientEncoding(conn);
popt.title = _("Procedural Languages");
+ popt.trans_headers = true;
+ popt.trans_columns = trans_columns;
printQuery(result, &popt, stdout, NULL);
PQfinish(conn);