Re: gettext and utf-8 in Gnome 2



Gediminas Paulauskas wrote:

In Gtk+ 2 all user-visible text is in Unicode. This includes
translations which come from po files. There are two ways to achieve
this:

bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");  /* add this call */
textdomain (GETTEXT_PACKAGE);

or force all po files to be in utf-8.

I have added bind_textdomain_codeset () to gnome-games, and saw correct
translations. But then I understood it may be not correct/sufficient.
There are other things which work with the same translation, namely:

1. intltool
2. libglade
3. libbonoboui

intltool reads various text files, and adds translatable strings to pot
file. Later libglade (.glade2 files) and libbonoboui (.xml files) call
gettext for these strings to get translations. They use dgettext
(domain, string) for that. But they do not call bind_textdomain_codeset
(), so get translations in the codeset which po file is saved in.

Libglade requires that the translation domain has been set up by the application before it can translate strings in the glade file. It has no way to know where the message catalogs are (hence it can't call bindtextdomain), whether transcoding of the messages is necessary (so it can't really call bind_textdomain_codeset), and as a library has no business changing the default translation domain (hence shouldn't call textdomain).



intltool-merge, however, makes .desktop, .keys, .schema, .server and
other files encoded in utf-8 correctly (if used with -u option).

Translations are not inline in glade files (they are in po files), so no special handling should be necessary. Intltool may still need extending to support glade2 files correctly (which should be a lot easier to support than glade1 files).


Gtk+-2.0 itself always gets strings in utf-8. So the, question is, do
all apps and libraries need to call bind_textdomain_codeset (), or
should all translators be forced to convert their translations to utf-8?

Applications should call it if appropriate. Libraries should call it for their own translation domains if required. Libraries like libglade that work with foreign translation domains (ie. those belonging to the app) have no business changing how those domains are interpreted -- that is the job of the owner of the domain.

James.

--
Email: james daa com au
WWW:   http://www.daa.com.au/~james/





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