Adding gettext on xml

Discussion regarding the development of CEGUI itself - as opposed to questions about CEGUI usage that should be in the help forums.

Moderators: CEGUI MVP, CEGUI Team

xabila
Quite a regular
Quite a regular
Posts: 55
Joined: Tue Mar 10, 2009 09:39
Location: Bruxelles

Adding gettext on xml

Postby xabila » Tue Apr 07, 2009 07:25

I was wondering if there was any plan or any simple solution , to add gettext for text translation on cegui.

Right now i have different layout according to the language, but it will me more easy (and it 's awwfull to make it evolve when you have to resize...) to allow something like that :

Code: Select all

<Property Name="Text" Value="gettext("Cancel")" />


Thanks

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Tue Apr 07, 2009 13:54

Hi,

Thanks for the suggestion / question. To answer the question, there's no really easy and transparent way to do this at the moment. The closest way is to use the callback that can be passed to loadWindowLayout; this callback function (and it's just a simple function, no facy stuff!) is called for each property and returns a boolean as to whether to set the property or not. What you could do there, is check if the property is for a window text, perform the gettext call (or any other translation you might want), set the property directly from the callback, and return false to stop CEGUI from re-setting the property afterwards.

The property callback type is defined as:

Code: Select all

typedef bool PropertyCallback(Window* window, String& propname, String& propvalue, void* userdata);


Anyway, I acknowledge the "request" part of your message, and we will have see what comes up :)

CE.

xabila
Quite a regular
Quite a regular
Posts: 55
Joined: Tue Mar 10, 2009 09:39
Location: Bruxelles

Postby xabila » Tue Apr 07, 2009 14:15

Ok thanks, this could work.
I will check an example.
Thanks

xabila
Quite a regular
Quite a regular
Posts: 55
Joined: Tue Mar 10, 2009 09:39
Location: Bruxelles

Postby xabila » Wed Apr 08, 2009 12:38

Ok it works, just remenber to make the CallBack of our class static ;)

Rincevent
Not too shy to talk
Not too shy to talk
Posts: 22
Joined: Thu Oct 08, 2009 20:42

Re: Adding gettext on xml

Postby Rincevent » Wed Jan 12, 2011 09:23

Hi,

I know that this topic is quite old but I would also be interested by such a gettext feature.
The library had many changes since April 2009 so I was wondering what would be the best way to implement it today.

I know that now the text is already parsed and replaced by images or other component, maybe this could be done the same way?

What I would be interested in is a general localisation feature which translate automatically the text in any window/component using text file for example.

I am ready to help with the implementation of such a feature, but I would need to know where to start first ;)

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: Adding gettext on xml

Postby Kulik » Thu Jan 13, 2011 14:43

The only concern is translating stuff you load from layout XML, or maybe even looknfeel XML. I would start by implementing a clean callback method that would do that as suggested by CrazyEddie. Translating stuff you insert by code is IMO unnecessary as you should translate that yourself.

Perhaps make a wiki article about this? Or if the system is larger we can host it in our new contrib folder in svn.


Return to “CEGUI Library Development Discussion”

Who is online

Users browsing this forum: No registered users and 13 guests