top of page
1.Adding Text

You can easily add Text by adding the following right into the <Section> of the LocalizationText.xml file.

<TextKey name="CarName">

<EN>The Name of the car</EN>

<DE>Der Name des Autos</DE>

</TextKey>

 

  • TextKey name="KEY" This is the Key you will call for when getting your Textfiles.

  • <EN>,<DE> those are example language text, you can add as many language text as you want.

2. Getting Text

There are 2 ways getting your Text, lets start with the easy one.

  • Update,OnGui, a Method which is called every Frame.

 

This is the easy one. This string will always be uptodate with the language files, because its updated every frame.

at the position where you would put your string "this is the string" you just call

 

  • LocalizationText.GetText("KEY")

 

The KEY here is the value of the name in your xml <TextKey name="KEY">

 

  • 3D Text Component.

 

This one is more tricky, because the text will be set once and normally never applied again. So we need

to reapply the Text whenever we change the Language settings.

 

First attach "LocalizationUpdateComponentText.cs" to one Gameobject(main camera, main character, emtpy component)

This is needed, so that we can reference all the gameobject that we want to change to a new language.

 

Second add a property for every Text GameObject in your class "LocalizationUpdateComponentText.cs"  which you want to be able to change the Text.

 

private GameObject myComponent;

 

Then add to SetAllObjects() (within LocalizationUpdateComonentText.cs)

 

myComponent = GameObject.Find("TheNameOfTheTextMeshComponent")

 

Now we do have a Reference to our Mesh that we can call when we need to change the language.

 

The last step is adding this to SetAllText()

 

myComponent.GetComponent<TextMesh>().text = LocalizationText.GetText("KEY");

 

3.Set your Language

Setting your language ingame on the fly is really easy you just have to use the following line.

 

LocalizationText.SetLanguage("EN");

 

This will change all your Text to the language which is set.

Localizaton++

bottom of page