[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Gettext bug when translating strings from iso88592-2
From: |
Bruno Haible |
Subject: |
Re: Gettext bug when translating strings from iso88592-2 |
Date: |
Mon, 23 Aug 2004 15:35:40 +0200 |
User-agent: |
KMail/1.5 |
Tomasz Torcz wrote:
> Program has strings in latin2 (iso-8859-2):
> char *good = _("good");
> char *bad = _("bąd"); /* contains characte in iso 8859-2 */
>
> setlocale(LC_ALL, "");
> textdomain("example");
There are two problems with your program:
1) You fetch the translations before having set the locale and textdomain;
therefore the _(...) here will do nothing.
2) You expect that gettext will somehow convert the msgid from iso-8859-2
(your source encoding) to utf-8 (the PO file's encoding). This is not
true: the gettext documentation says
"Note that the MSGID argument to `gettext' is not subject to
character set conversion. Also, when `gettext' does not find a
translation for MSGID, it returns MSGID unchanged - independently of
the current output character set. It is therefore recommended that all
MSGIDs be US-ASCII strings."
A possible solution for you is to change your source code to UTF-8.
Another possible solution is to convert the msgid yourself from ISO-8859-2
to UTF-8 before passing it to the gettext function.
Bruno