Announcement
Collapse
No announcement yet.
Displaying Localized Text
Collapse
This is a sticky topic.
X
X
-
Displaying Localized Text
Before proceeding, please be sure to read this UDN topic: Localized Text in the Unreal Engine
1. Place a CLIK label in your HUD or menu, with the instance name of: myTextField
2. Next, add the variable which will contain the localized text you want displayed as well as the GFx CLIK widget variable at the top of your HUD or menu UnrealScript class:
Code:var GFxClikWidget MyTextField; var localized string MyLocalizedString;
Code:event bool WidgetInitialized(name WidgetName, name WidgetPath, GFxObject Widget) { switch(WidgetName) { case ('myTextField'): MyTextField = GFxClikWidget(Widget); MyTextField.SetString("text", MyLocalizedString); default: break; } return true; }
Code:defaultproperties { WidgetBindings.Add((WidgetName="myTextField",WidgetClass=class'GFxClikWidget')) }
So I'll go to this directory: C:\UDK\UDK-2010-11\UDKGame\Localization\INT\
and open the file: utgame.int in a text editor. This is the international (English) localized ini file that matches the UTGame.u script package. Obviously, if your HUD or menu class is located in a different script package, you'll want to open or create an INT file for it instead.
6. At the bottom of this file, I'll add the HUD's class name as a section, then add the variable 'MyLocalizedString' as the key, and the text I want it to display as the value. Be sure to replace 'GFxMinimapHud' with the name of your actual HUD or menu class:
Code:[GFxMinimapHud] MyLocalizedString="This is a localized string."
Alternatively, you can call the Localization function like this:
Code:var string MyString; MyString = Localize("GFxMinimapHud", "MyLocalizedString", "utgame");
- Replace "GFxMinimapHud" with the heading name in your INT file.
- Replace "MyLocalizedString" with the key name.
- Replace "utgame" with your localization filename minus the file extension.
Or, you could use this line of code as well:
Code:class'GFxObject'.static.TranslateString( "<Strings:NameOfLocalizedFile.LocalizedHeader.LocalizedVar>" );
Code:var GFxObject MyTextField; var localized string MyString; MyTextField = GetVariableObject("_root.myTextField"); MyTextField.SetText(MyString);
Using Config Files
You can also use an INI file in the Config directory to store text to be displayed; however, it will not be localized. That procedure follows:
You must specifiy the name of the INI file to be used in your class by adding: config(nameofini) to the class declaration. Like so:
Code:class MyClass extends GFxMoviePlayer config(MyConfigFile);
Code:var config string MyString;
Code:[MyGame.MyClass] +MyString="This is a non-localized string."
Tags: None
- Stuck
Leave a comment: