[illumos-Developer] BEADM [WEBREV] 418 replace beadm by tbeadm with gettext support

Joerg Schilling Joerg.Schilling at fokus.fraunhofer.de
Fri Dec 10 01:59:54 PST 2010


Gordon Ross <gordon.w.ross at gmail.com> wrote:

> On Tue, Nov 30, 2010 at 2:51 PM, Alexander Stetsenko <ams at nexenta.com> wrote:
> > latest beadm command webrev:
> >
> > http://cr.illumos.org/view/l9tyxd9g/
>
> Why use tables of error message strings instead of doing gettext calls
> (or the _() macro) at the site were these strings are used?
> It appears most of them are used only once.
>
> If you really want defines, you could do like this:
> #define STRING1	gettext("string1")
> #define STRING2	gettext("string2")
>
> Also, if you do need tables of strings (which I don't think you do here)
> the more common way I've seen for doing that is like this:
>
> /* Howto: Tables of translated strings. */
>
> #ifndef I18N	/* never defined, just a trick for xgettext */
> #define gettext(S) S
> #endif
>
> const char *table[] = {
> 	gettext("string1"),
> 	gettext("string2"),
> 	NULL
> };

This does not work.

_(s) is defined as gettext(s) and if you later define gettext(s) to be s,
there will be no gettext call anymore.

I recommend to do the following:

#define	_(s)	gettext(s)
#define __(s)	s

const char *table[] = {
	__("string1"),
	__("string2"),
	NULL
};



gxgettext -k_ -k__ .....


Jörg

-- 
 EMail:joerg at schily.isdn.cs.tu-berlin.de (home) Jörg Schilling D-13353 Berlin
       js at cs.tu-berlin.de                (uni)  
       joerg.schilling at fokus.fraunhofer.de (work) Blog: http://schily.blogspot.com/
 URL:  http://cdrecord.berlios.de/private/ ftp://ftp.berlios.de/pub/schily



More information about the Developer mailing list