Cleanup for gettext() calls

Started by Bruce Momjianover 21 years ago4 messagespatches
Jump to latest
#1Bruce Momjian
bruce@momjian.us

Our current use of gettext() calls is inconsistent. We use:

#define _(x) gettext((x))

in various C files to abreviate the use of gettext() around all string.
This patch makes that consistent by moving the define to include/c.h.

It also adds some missing gettext usage, particularly in src/port and
interfaces/ecpg.

I found that perl also defines _(x) so I undefined this in plperl. I
don't see c.h is externally used so it seems safe to just use it
consistently in our code.

The attached patch makes these adjustments.

Also, what is gettext_noop(x) used for? It seems it is just used to
mark strings that should not be translated, but why are certain strings
not to be translated?

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Attachments:

/pgpatches/gettexttext/plainDownload+576-583
#2Peter Eisentraut
peter_e@gmx.net
In reply to: Bruce Momjian (#1)
Re: Cleanup for gettext() calls

Bruce Momjian wrote:

It also adds some missing gettext usage, particularly in src/port and
interfaces/ecpg.

ecpg has no translation support, so that would be pretty pointless.

I found that perl also defines _(x) so I undefined this in plperl.

That kind of thing was the reason that it wasn't defined globally.

Also, what is gettext_noop(x) used for?

It marks strings for translation for the purpose of xgettext but does
not call gettext because it would not be valid program code at that
place.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

#3Bruce Momjian
bruce@momjian.us
In reply to: Peter Eisentraut (#2)
Re: Cleanup for gettext() calls

Peter Eisentraut wrote:

Bruce Momjian wrote:

It also adds some missing gettext usage, particularly in src/port and
interfaces/ecpg.

ecpg has no translation support, so that would be pretty pointless.

Well, gettext is coming into ecpglib via a symlink to port/exec.c:

./ecpglib/exec.c: log_error(gettext("could not identify current directory: %s"),

Seems we should enable internationalization for ecpg, at least for the
--help strings and stuff.

Peter says that the gettext() doesn't do anything if it isn't
initialized so I guess exec.c is OK. Does someone want to set up the
proper gettext initialization for ecpg so we can have this for 8.1?
ecpglib needs special library initialization like libpq.

I found that perl also defines _(x) so I undefined this in plperl.

That kind of thing was the reason that it wasn't defined globally.

Yea. I have Perl handled. I think we should just do with the _(x) and
if we find problems we can change them to _e(x) or something.

Also, what is gettext_noop(x) used for?

It marks strings for translation for the purpose of xgettext but does
not call gettext because it would not be valid program code at that
place.

OK I have added a comment to explain this:

/*
* These strings are to be translation via xgettext. We can't
* call gettext() because it is located in variable initialization and
* a function call can not be used.
*/
#define gettext_noop

Thanks.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#4Bruce Momjian
bruce@momjian.us
In reply to: Bruce Momjian (#3)
Re: Cleanup for gettext() calls

Bruce Momjian wrote:

Peter Eisentraut wrote:

Bruce Momjian wrote:

It also adds some missing gettext usage, particularly in src/port and
interfaces/ecpg.

ecpg has no translation support, so that would be pretty pointless.

Well, gettext is coming into ecpglib via a symlink to port/exec.c:

./ecpglib/exec.c: log_error(gettext("could not identify current directory: %s"),

Seems we should enable internationalization for ecpg, at least for the
--help strings and stuff.

Peter says that the gettext() doesn't do anything if it isn't
initialized so I guess exec.c is OK. Does someone want to set up the
proper gettext initialization for ecpg so we can have this for 8.1?
ecpglib needs special library initialization like libpq.

I have remove the ecpg part of my patch and added a TODO item for
internationalization of ecpg.

I found that perl also defines _(x) so I undefined this in plperl.

That kind of thing was the reason that it wasn't defined globally.

Yea. I have Perl handled. I think we should just do with the _(x) and
if we find problems we can change them to _e(x) or something.

Also, what is gettext_noop(x) used for?

It marks strings for translation for the purpose of xgettext but does
not call gettext because it would not be valid program code at that
place.

OK I have added a comment to explain this:

/*
* These strings are to be translation via xgettext. We can't
* call gettext() because it is located in variable initialization and
* a function call can not be used.
*/
#define gettext_noop

Thanks.

Patch applied to use the _() macro consistently, and added the macro
around some strings that were missing them.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073