Announcement

Collapse

The Infinity Blade Forums Have Moved

We've launched brand new Infinity Blade forums with improved features and revamped layout. We've also included a complete archive of the previous posts. Come check out the new Infinity Blade forums.
See more
See less

Displaying Localized Text

Collapse
This is a sticky topic.
X
X
  • Filter
  • Time
  • Show
Clear All
new posts

    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;
    3. Now, we'll set the text field to display the contents of 'MyString' on initialization:

    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;
    }
    4. Then, as usual, we'll bind the CLIK widget in the default properties:

    Code:
    defaultproperties
    {
        WidgetBindings.Add((WidgetName="myTextField",WidgetClass=class'GFxClikWidget'))	
    }
    5. Next, we need to figure out which Script package contains our HUD or menu script file. In my case, my HUD script is GFxMiniMapHud.uc and it is contained in the UTGame.u compiled Script.

    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."
    That's all there is to it! Just do a Make/Build of your game, then run the game. You should see the sentence: "This is a localized string." on the screen where you placed the CLIK label.

    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>" );
    You could use a standard Flash textfield for this as well, instead of a CLIK label. In that case, the script setup will be slightly different:

    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);
    Also be sure the variable in the class file is listed like so:
    Code:
    var config string MyString;
    Your INI file would have something along these lines in it:

    Code:
    [MyGame.MyClass]
    +MyString="This is a non-localized string."

    #2
    Thank you for the info, very helpful.

    Comment

    Working...
    X