The translation nightmare: solved.
- From: Michael Meeks <michael helixcode com>
- To: Darin Adler <darin eazel com>, Martin Baulig <martin home-of-linux org>, John Sullivan <sullivan eazel com>, Ettore Perazzoli <ettore helixcode com>
- Cc: gnome-components-list gnome org
- Subject: The translation nightmare: solved.
- Date: Wed, 11 Oct 2000 16:21:45 -0400 (EDT)
Hi,
I had a most unpleasant double shock last night wrt. to
translation of menu items. Anyhow; the fix is all committed and (
seemingly ) working, here is the hunk I added to the FAQ:
* When I look at the xml being transfered I see that many elements
show up as hex strings; why is this ?
* I get a warning saying that something is not correctly encoded,
what does that mean ?
At a very late stage in the development of the new UI
handler two things were discovered:
a) Translated text is not encoded as UTF-8 instead some native
8bit encoding is used.
b) libxml 1 is not capable of cleanly handling UTF-8.
Incredible though it may sound, this is ostensibly for purposes of
validation [ see eg. entities.c (xmlEncodeEntitiesReenterant) ]
Consequently until Gnome 2.0, when we can switch all
translated strings to UTF-8 and also upgrade to libxml 2 ( which fixes
these issues ) the following hack has been added:
As properties are set; if they are named 'label' or 'tip',
they are encoded into hex. When these properties are read and synced
with widget's text they are de-coded back to a sequence of chars.
This also applies to the status text. This then allows translation
in the normal way. The changes involve no programmatic change. The
changes are also done on translation of xml files using the normal
bonobo_ui_util_set_ui mechanism.
However, some non translation aware code may need to be fixed,
if you see a warning about encoding, it means your code is i18n broken.
This most commonly happens when people construct fragments themselfs
such as:
const char xml [] = "<menuitem label=\"Foo\">";
bonobo_ui_component_set (
component, "/menu", xml, ev);
To do this correctly now, a helper function has been added,
the correct replacement for this is:
const char xml [] = "<menuitem _label=\"Foo\">";
bonobo_ui_component_set_translate (
component, "/menu", xml,ev);
In the unlikely event that you want to encode strings
yourself, the routines that deal with the process are:
bonobo_ui_util_encode_str and
bonobo_ui_util_decode_str
If you find yourself needing to use these a lot, something is
probably wrong ( or you are setting filenames as labels or somesuch ),
please mail the list.
Regards,
Michael.
--
mmeeks gnu org <><, Pseudo Engineer, itinerant idiot
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]