Gettext issues (was Re: cvs commit: ports CHANGES)

Eivind Eklund eivind at FreeBSD.org
Tue Mar 2 05:20:11 PST 2004


On Mon, Mar 01, 2004 at 07:58:08PM -0800, Kris Kennaway wrote:
> On Mon, Mar 01, 2004 at 04:26:24PM +0000, Eivind Eklund wrote:
> 
> > The knob is there for a number of ports (but much fewer than I had
> > thought - I actually thought it was fairly universal):
> > 
> > devel/bison/Makefile
> > devel/gmake/Makefile
> > ftp/wget/Makefile
> > mail/mutt-devel/Makefile
> > mail/mutt/Makefile
> > net/darkstat/Makefile
> > 
> > This has actually seemed to be enough to stop most of the problems I
> > have with gettext (which shows you what kind of programs I run ;)
> > 
> > I think we should try to have it become universal - getting rid of
> > gettext is very useful for most of us.
> 
> I successfully removed gettext from a number of my installed ports,
> but it looks like glib20 and everything that depends on it absolutely
> requires gettext (there's a note in the ChangeLog suggesting that it
> was a design decision).  That means pretty much everything GNOME and
> KDE requires it, but it's still a step forward to proceed with other
> ports.

Looking at the code, I think you're wrong - it just autodetect.  Or at
least the code autodetect and contain ifdef's on ENABLE_NLS to
enable/disable code sections based on whether NLS is available or not.


For the more general case: I think we can use a dummy gettext library to
get around things needing gettext.  The gettext calls generally index on
the english string, making a dummy implementation very easy.

Below is an implementation (not tested) which should compliant with the basic
interface, and hopefully work.  A better variant might be actually have
all of this defined as inline functions in a header.

The docs I've found are at
    http://www.scit.wlv.ac.uk/cgi-bin/mansec?3C+gettext
and
    http://www.gnu.org/software/gettext/manual/html_node/gettext_145.html#SEC145

Eivind.

>>> gettext.h:
char *textdomain (const char *domain_name);
char *gettext(const char *msgid);
char *dgettext(const char *domain_name, const char *msgid);
char *dcgettext(const char *domain_name, const char *msgid, int category);
char *bindtextdomain (const char *domain_name, const char *dir_name);


>>> gettext.c:
char *
textdomain(const char *domain_name)
{
	return domain_name ? NULL : "messages";
}

char *
gettext(const char *msgid)
{
	return msgid;
}

char *
dgettext(const char *domain_name, const char *msgid) {
	return msgid;
}

char *
dcgettext(const char *domain_name, const char *msgid, int category) {
	return msgid;
}

char *
bindtextdomain(const char *domain_name, const char *dir_name) {
	if (domain_name == NULL || strcmp(domain_name, "") == 0) {
		return NULL;
	} else {
		return "messages";
	}
}


More information about the cvs-ports mailing list