[Solved] MyGUI translation system?


10-04-2011 15:12:04


we would like to use MyGUI for translating our game into different languages.

I couldn't find any documentation on it, so I just tried it like this. I inserted a new tag in core_language_english_tag.xml:

<?xml version="1.0" encoding="UTF-8"?>
<Tag name="MyGUI_MessageBox_Ok">Ok</Tag>
<Tag name="MyGUI_MessageBox_Yes">Yes</Tag>
<Tag name="MyGUI_MessageBox_No">No</Tag>
<Tag name="MyGUI_MessageBox_Abort">Abort</Tag>
<Tag name="MyGUI_MessageBox_Retry">Retry</Tag>
<Tag name="MyGUI_MessageBox_Ignore">Ignore</Tag>
<Tag name="MyGUI_MessageBox_Cancel">Cancel</Tag>
<Tag name="MyGUI_MessageBox_Try">Try</Tag>
<Tag name="MyGUI_MessageBox_Continue">Continue</Tag>

<Tag name="MyApp_TestString">Test</Tag>

Then, I made a new widget in our Options.layout:

<Widget type="StaticText" skin="StaticText" position="32 488 144 24">
<Property key="Widget_Caption" value="MyApp_TestString"/>
<Property key="Text_TextColour" value="0.5 0.9 1"/>

But it doesn't work, in game it shows MyApp_TestString instead of Test.

Am I doing something wrong?


10-04-2011 16:39:29



10-04-2011 18:15:30

Ok, so it's possible when using #{TagName} as string in layout.

But, I tried it out, and for tooltips (userString) it doesnt work:

<Widget type="List" skin="List" position="14 16 148 504" name="TrackList">
<UserString key="tip" value="#{ChangeTrack}"/>

What is displayed in tooltip:eTrack} in black color.

Do I have to use something different for user strings, or is it not possible?


10-04-2011 18:24:33

I solved it for tool tips.

I iterate through all widgets that have a tooltip, and use LanguageManager::replaceTags to modify the user string.
void App::setToolTips(EnumeratorWidgetPtr widgets)
while (widgets.next())
WidgetPtr wp = widgets.current();
bool tip = wp->isUserString("tip");
if (tip) // if has tooltip string
// needed for translation
wp->setUserString("tip", LanguageManager::getInstance().replaceTags(wp->getUserString("tip")));

wp->eventToolTip = newDelegate(this, &App::notifyToolTip);
//Log(wp->getName() + (tip ? " *" : ""));


10-04-2011 19:41:17

Or you can use setCaptionWithReplacing instead of setCaption . It also replace "\\n" with '\n' (new line) character.