1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-02 09:02:37 +03:00

Easier to translate psql help

Instead of requiring translators to translate the entire SQL command
synopses, change create_help.pl to only require them to translate the
placeholders, and paste those into the synopsis using a printf mechanism.
Make some small updates to the markup to make it easier to parse.

Note: This causes msgmerge of gettext 0.17 to segfault.  You will need
the patch from https://savannah.gnu.org/bugs/?27474 to make it work.
msgmerge usually only runs on babel.postgresql.org, however.
This commit is contained in:
Peter Eisentraut
2009-09-18 05:00:42 +00:00
parent ef9619609a
commit 20f7f019f9
21 changed files with 139 additions and 71 deletions

View File

@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2009, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/help.c,v 1.151 2009/07/24 19:35:44 petere Exp $
* $PostgreSQL: pgsql/src/bin/psql/help.c,v 1.152 2009/09/18 05:00:42 petere Exp $
*/
#include "postgres_fe.h"
@ -349,7 +349,6 @@ helpSQL(const char *topic, unsigned short int pager)
size_t len,
wordlen;
int nl_count = 0;
const char *ch;
/* User gets two chances: exact match, then the first word */
@ -386,10 +385,8 @@ helpSQL(const char *topic, unsigned short int pager)
if (pg_strncasecmp(topic, QL_HELP[i].cmd, len) == 0 ||
strcmp(topic, "*") == 0)
{
nl_count += 5;
for (ch = QL_HELP[i].syntax; *ch != '\0'; ch++)
if (*ch == '\n')
nl_count++;
nl_count += 5 + QL_HELP[i].nl_count;
/* If we have an exact match, exit. Fixes \h SELECT */
if (pg_strcasecmp(topic, QL_HELP[i].cmd) == 0)
break;
@ -403,13 +400,17 @@ helpSQL(const char *topic, unsigned short int pager)
if (pg_strncasecmp(topic, QL_HELP[i].cmd, len) == 0 ||
strcmp(topic, "*") == 0)
{
PQExpBufferData buffer;
initPQExpBuffer(&buffer);
QL_HELP[i].syntaxfunc(&buffer);
help_found = true;
fprintf(output, _("Command: %s\n"
"Description: %s\n"
"Syntax:\n%s\n\n"),
QL_HELP[i].cmd,
_(QL_HELP[i].help),
_(QL_HELP[i].syntax));
buffer.data);
/* If we have an exact match, exit. Fixes \h SELECT */
if (pg_strcasecmp(topic, QL_HELP[i].cmd) == 0)
break;