Page 1 of 1

Adding gettext on xml

Posted: Tue Apr 07, 2009 07:25
by xabila
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

Posted: Tue Apr 07, 2009 13:54
by CrazyEddie
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.

Posted: Tue Apr 07, 2009 14:15
by xabila
Ok thanks, this could work.
I will check an example.
Thanks

Posted: Wed Apr 08, 2009 12:38
by xabila
Ok it works, just remenber to make the CallBack of our class static ;)

Re: Adding gettext on xml

Posted: Wed Jan 12, 2011 09:23
by Rincevent
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 ;)

Re: Adding gettext on xml

Posted: Thu Jan 13, 2011 14:43
by Kulik
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.