Rough draft: easier translation of psql help

Started by Peter Eisentrautover 16 years ago5 messageshackers
Jump to latest
#1Peter Eisentraut
peter_e@gmx.net

One of the main pains in translating PostgreSQL messages is translating
the SQL syntax synopses in psql. Things like:

msgid ""
"[ WITH [ RECURSIVE ] with_query [, ...] ]\n"
"SELECT [ ALL | DISTINCT [ ON ( expression [, ...] ) ] ]\n"
" * | expression [ [ AS ] output_name ] [, ...]\n"
" INTO [ TEMPORARY | TEMP ] [ TABLE ] new_table\n"
" [ FROM from_item [, ...] ]\n"
" [ WHERE condition ]\n"
" [ GROUP BY expression [, ...] ]\n"
" [ HAVING condition [, ...] ]\n"
" [ WINDOW window_name AS ( window_definition ) [, ...] ]\n"
" [ { UNION | INTERSECT | EXCEPT } [ ALL ] select ]\n"
" [ ORDER BY expression [ ASC | DESC | USING operator ] [ NULLS
{ FIRST | "
"LAST } ] [, ...] ]\n"
" [ LIMIT { count | ALL } ]\n"
" [ OFFSET start [ ROW | ROWS ] ]\n"
" [ FETCH { FIRST | NEXT } [ count ] { ROW | ROWS } ONLY ]\n"
" [ FOR { UPDATE | SHARE } [ OF table_name [, ...] ] [ NOWAIT ]
[...] ]"

Especially when small things are changed from release to release,
figuring this out on the part of the translator is cumbersome and
error-prone.

Instead of translating the whole string, that is (picking a shorter
example)

N_("ALTER TEXT SEARCH PARSER name RENAME TO newname")

we really only want to translate the placeholders, so it could look like
this:

appendPQExpBuffer(buf,
"ALTER TEXT SEARCH PARSER %s RENAME TO %s",
_("name"),
_("newname"));

This is what the attached patch produces.

Comments?

Attachments:

psql-help.patchtext/x-patch; charset=UTF-8; name=psql-help.patchDownload+85-21
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Peter Eisentraut (#1)
Re: Rough draft: easier translation of psql help

Peter Eisentraut <peter_e@gmx.net> writes:

Instead of translating the whole string, that is (picking a shorter
example)

N_("ALTER TEXT SEARCH PARSER name RENAME TO newname")

we really only want to translate the placeholders, so it could look like
this:

appendPQExpBuffer(buf,
"ALTER TEXT SEARCH PARSER %s RENAME TO %s",
_("name"),
_("newname"));

This is what the attached patch produces.

Seems like a reasonable idea.

Comments?

I'm not sure what the "const" here is good for, and I can think of
some compilers that are likely to get confused too:

+ void (* const syntaxfunc)(PQExpBuffer); /* function that prints the syntax associated with it */

Also, are you sure that code to identify the placeholders is robust?
Should you be defending against '%' in the syntax string?
Will the NLS infrastructure remember to build sql_help.c before
looking for strings?

regards, tom lane

#3Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Peter Eisentraut (#1)
Re: Rough draft: easier translation of psql help

Peter Eisentraut wrote:

Instead of translating the whole string, that is (picking a shorter
example)

N_("ALTER TEXT SEARCH PARSER name RENAME TO newname")

we really only want to translate the placeholders, so it could look like
this:

appendPQExpBuffer(buf,
"ALTER TEXT SEARCH PARSER %s RENAME TO %s",
_("name"),
_("newname"));

+1000

Should create_help.pl be run on "make dist"?

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

#4Josh Berkus
josh@agliodbs.com
In reply to: Peter Eisentraut (#1)
Re: Rough draft: easier translation of psql help

Peter,

This is what the attached patch produces.

Comments?

This is how other project handle transation of these kinds of strings.

--
Josh Berkus
PostgreSQL Experts Inc.
www.pgexperts.com

#5Peter Eisentraut
peter_e@gmx.net
In reply to: Alvaro Herrera (#3)
Re: Rough draft: easier translation of psql help

On Sun, 2009-09-13 at 23:46 -0400, Alvaro Herrera wrote:

Should create_help.pl be run on "make dist"?

It is.