On 2021-09-11 11:20, AdaMagica wrote:
Is there no way to use the character € directly? Imagine, you want to write cyrillc on label of a gui? Would you use hex values or would you write
Я говорю по-русски.
I would never use Cyrillic in the source code.
Anyway, this is a question regarding the encoding of literals in Ada.
Ada 2X supports Unicode and GNAT supports Unicode sources.
I never tried it but I suppose the following should work:
Strings_Edit.UTF8.Handling.To_UTF8 ('€');
Here '€' should be resolved to Wide_Character'('€') and then converted
to a UTF-8 encoded String.
As for labels, icons etc, I use GTK style properties.
I.e. let I have a label with a text on it. Usually this label would be
packed in some larger container widget, e.g. Gtk_Grid_Record. I derive a
custom widget from Gtk_Grid_Record. Then I call Initialize_Class_Record
once to create the new widget "type" (used G_New). There I add style
properties like this:
Class_Record : aliased Ada_GObject_Class := Uninitialized_Class;
...
procedure Initialize
( Widget : not null access My_Widget_Record'Class
) is
begin
G_New (Widget, Get_Type); -- Get_Type will register class
...
function Get_Type return GType is
begin
if Initialize_Class_Record
( Ancestor => Gtk.Grid.Get_Type, -- Parent class
Class_Record => Class_Record'Access,
Type_Name => "mywidget"
) then -- Not yet registerd
Install_Style_Property
( GLib.Types.Class_Ref (Class_Record.The_Type),
Gnew_String
( Name => "label",
Nick => "Label",
Blurb => "Label text I want to be able to change",
Default => "I speak English"
) );
...
end if;
return Class_Record.The_Type;
end Get_Type;
The widget must handle "style-updated" from where it would use Style_Get
to get the label text and set it into the label.
So, a Russian localization would be a CSS sheet file defining the
property "label":
---------------------------
mywidget {
-mywidget-label: "Я говорю по-русски";
}
---------------------------
P.S. Inventors of GTK CSS sheets apparently misspelled the word "sheet",
they should have used the letter 'i'! (:-))
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)