Multilanguage GUI

Hi,

I am just wondering how to make multilanguage GUI’s.

This seem a very noob problem…

My idea is to create a languageClass with a public static Dictionary myDictionary.
The keys would be the strings in English, while the values - these strings in other languages.
The language class would operate on the xml text asset containing all the strings in all languages.
A language change by user would redefine myDictionary to the selected language.

Then in OnGUI function I would use:

if(GUI.Button (new Rect(76,22,72,32), languageClass.myDictionary["myString"]) ...

So I would prefer to use the string keys, not id or index, in order to keep the scripts more transparent.

Is that a proper way to make a multilanguage GUI?

I guess it’s a good way to do it if you don’t want to use a plugin. You could use some improvements if you’re intending to have a lot of text, for example you could split you text on a per scene basis or any other relevant way of splitting text logically for your needs.

Another improvement would be to use enums instead of strings to identify your text, and even further you could divide the enum into logical sections using namespaces/classes like Tr.GUI.Buttons.Cancel or Tr.Dialogs.Chapter1.SomeCharacterName and have an editor that allows you to fill the blanks based on the enum within the “Tr” namespace/class (easy using reflexion).