[fpc-devel] Bug in Gettext?

Michael Van Canneyt michael at freepascal.org
Fri Jan 9 10:49:28 CET 2009

On Fri, 9 Jan 2009, Klaus Reimer wrote:

> Hello,
> I have a question regarding the Unit "gettext" which is used to parse a
> MO file and to translate texts with this file.
> I have writte a Lazarus application which uses the DefaultTranslator
> class to translate the application. This translator uses the gettext
> Unit of Free Pascal. The problem is that all strings which uses a
> "message context" in the PO file are not translated at all. Lazarus
> automatically writes message contexts to the PO file when same texts are
> used in different parts of the application.
> So my first thought was that this is a bug in the DefaultTranslator that
> it does not pass the message context to the gettext unit. I was going to
> add this to the DefaultTranslator unit but then I noticed that i have no
> idea how to translate a text whcih uses a message context with the
> gettext unit.
> So can someone tell me how to do this? According to the GNU gettext
> documentation the context is prefixed to the original text separated
> with an EOT character (#4). So the "orig" text in my case is this:
>   'TFORM1.BUTTON1.CAPTION' + #4 + 'Test'
> But If I pass this string to the translate method of gettext then this
> also returns an empty string because the generated hash code for this
> string is not found in the hash table of the MO file.
> So how can I translate texts which uses message contexts?

Probably the error is in the hash code ?
Does GNU gettext take the #4 into account when it generates the hash code ?


More information about the fpc-devel mailing list