From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Internationalization for Ada
Date: Sat, 12 Dec 2009 12:51:35 +0100
Date: 2009-12-12T12:52:03+01:00 [thread overview]
Message-ID: <tygwh350oj4k$.1wy0evvtlxgie.dlg@40tude.net> (raw)
In-Reply-To: 7cdd6689-077e-4438-a493-428823bb1ee2@k19g2000yqc.googlegroups.com
On Sat, 12 Dec 2009 01:23:07 -0800 (PST), Ludovic Brenta wrote:
> vlc wrote on comp.lang.ada:
>>
>> Is there a preferred way for internationalization in Ada 2005 - like
>> GNU gettext for GNU/Linux? If anyone has experience with this topic, I
>> would be glad for a link which directs me into the right direction,
>> also if there is something special for GtkAda.
>>
>> Thanks a lot in advance!
>
> See the package GtkAda.Intl in GtkAda.
Yes, but there is also other way based on widget style properties, which I
prefer.
Each variable text is made a style property of its container widget. When
the widget is initialized, its class record is initialized as well. Here
the necessary style properties are added:
if <the class record was initialized> then
Class_Install_Style_Property
( Class_Record, -- Freshly initialized class record
Gnew_String
( Name => "fancy text",
Nick => "hey",
Default => "hey",
Blurb => "The text to appear in the label"
) );
In the widget's "style_set" event handler the texts are actually set. E.g.
procedure Style_Set (Widget : access Gtk_Fancy_Widget_Record'Class) is
begin
Set_Text (Widget.Label, Style_Get Widget, "fancy text");
...
The texts and other styles are then defined in the GTK resource file. That
need to be done only if necessary, because there is a default for any
property. Only in order to change the texts you provide and load another
resource file. This can be done several times, if you properly handle the
event "style_set".
The advantage of this method is that it does not require any tools or any
additional files to work. It does not depend on the OS and its settings.
(E.g. when I use German locale, I still don't want texts in German). Style
properties can be more than only texts. For example you can have images
there. The way properties are matched are very elaborated, you can define
quite complex rules (by class name, by widget name etc), instead of simple
equality in the case of locales.
A more detailed description how to deal with GTK style properties in
GtkAda:
http://www.dmitry-kazakov.de/ada/gtkada_contributions.htm#4
On GTK resource files see:
http://library.gnome.org/devel/gtk/unstable/gtk-Resource-Files.html
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2009-12-12 11:51 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-11 23:15 Internationalization for Ada vlc
2009-12-12 9:23 ` Ludovic Brenta
2009-12-12 11:51 ` Dmitry A. Kazakov [this message]
2009-12-12 12:17 ` Georg Bauhaus
2009-12-12 12:24 ` Georg Bauhaus
2009-12-12 17:01 ` vlc
2009-12-12 17:18 ` Ludovic Brenta
2009-12-13 14:35 ` Christophe Chaumet
2009-12-14 15:18 ` Jacob Sparre Andersen
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox