Context Translations (Was: Re: 2.0.2 bugs & freeze)

Richard Laager rlaager at wiktel.com
Wed Jun 6 11:09:35 EDT 2007


On Wed, 2007-06-06 at 08:10 -0400, Luke Schierer wrote:
> 2.0.2 is currently scheduled for 1 week from tomorrow.  This means that
> we should enter string freeze for it on Sunday.  With that in mind, I do
> not know how to close #1157, as the only other string that occurs to
> me is "Name" which we use for a person's name elsewhere.  Any ideas?

I looked into this for a few hours the other day, but I haven't started
implementing. I don't think I'll get to it for 2.0.2. ;)

The correct fix is to enable some infrastructure for context-specific
translations. The problem there is one of backwards compatibility. I
*think* we need to do something along these lines:

Add code to detect pgettext() support to configure.ac. Use some code for
xgettext() so that it'll extract the context if new enough, otherwise
just fall back to the string as-is. Use some sed magic on the .po files
to replace the msgctxt stuff with "context|string" for older versions.

Then have this:

const char *
purple_pgettext(const char *context, const char *msg)
{
	const char *translation;

#ifdef HAVE_PGETTEXT
	/* The translator had pgettext() and so does the user. */
	translation = pgettext(context, msg).
	if (strcmp(msg, translation))
		return translation;
#else
	/* Try for combined context. The translator had pgettext(), but
	 * the user doesn't. */
	tmp = g_strconcat(context, "|", msg, NULL);
	translation = gettext(tmp);
	g_free(tmp);
	if (strcmp(msg, translation))
		return translation;
#endif

	return gettext(msg);
}

We'd universally call purple_pgettext() and everything should Just Work.
If a *translator* cares about context translations, they MUST upgrade
their gettext, but nobody else has to. This has the advantage over
glib-style "context|msg"-only translations of forwards-compatibility. If
at some point we wish to end support for older gettext installs, we can
simply remove the compatibility code and s/purple_pgettext/pgettext/.

I *think* this will work, but I need to start implementing to find out
for sure.

Richard
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://pidgin.im/pipermail/devel/attachments/20070606/84c91c09/attachment.sig>


More information about the Devel mailing list