[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: using gettext for libraries

From: Petr Vandrovec
Subject: Re: using gettext for libraries
Date: Wed, 3 Jan 2001 20:15:07 MET-1

On  3 Jan 01 at 17:02, Andrew Clausen wrote:
> Andrew Clausen wrote:
> > 
> > Hi all,
> > 
> > How should gettext be used for libraries?  i.e. how should
> > bindtextdomain() and textdomain() be used?
> > 
> > (Obviously, both the library and the program/library using
> > the program would like to have strings translated, but operate
> > from a different domain)

You should use bindtextdomain, dgettext, and eventually
dcgettext, dngettext, dcngettext and bind_textdomain_codeset. Forget 
about gettext, ngettext and other domain-less functions.
> From the glibc manual (should also be in the gettext manual):
> "The important point is that at any time exactly one domain
> is active."
> Why? It means you have to switch domains on all entry points into
> a library, OR at gettext() time.
> The former is a huge amount of bureaucracy.  The later is
> rather trivial to implement, by changing the _() macro.  But,
> in this case, it raises the question: "why bother with having
> an active text domain at all?  why not just pass the
> text domain to gettext()?"

It is here, and it is named dgettext().

> So, why is there always exactly one domain active?

Because of it is convient for programs. Libraries must always use
dgettext(), as does libc or other correctly internationalized libraries.

To get easy (_) macros in ncpfs, I'm using

#undef _
#define _(X) dgettext(PACKAGE, (X))
#undef N_
#define N_(X) (X)

in library .c files.

                                            Best regards,
                                                    Petr Vandrovec

reply via email to

[Prev in Thread] Current Thread [Next in Thread]