Here's the code I did for integrating SmartLocalization into my UFE game.
First, install SmartLocalization and set up the primary and at least a secondary language. For my case, I used Japanese as my secondary. Then add a new language to the Global UFE Config asset with the same name of the language.
Second, open up UFE.cs and at the top, add the following using statement:
Third, inside the Public Instance Properties region, add a static call to a new LanguageManager object, I called mine 'Localization':
#region public instance properties
public GlobalInfo UFE_Config;
public static LanguageManager Localization;
public string[] Languages;
public int UsingLanguage;
#endregion
Fourth, scroll down the class sheet to find the moment the Awake() calls 'SetLanguage()'. Then add the code to instantiate the Localization object and update the current language to whatever is the language option in the Global UFE Config asset file.
SetLanguage();
UFE.Localization = LanguageManager.Instance;
switch(UFE.config.selectedLanguage.languageName) {
case "Japanese":
Localization.ChangeLanguage(new SmartCultureInfo("ja-JP", "Japanese", "Japanese", false));
break;
default:
Localization.ChangeLanguage(new SmartCultureInfo("en-US", "English", "English", false));
break;
}
Fifth, create a new C# script, I used 'KeyValueForLocalization' as the class name. In it, you want to have a public string variable set up so that you can tell the object the "Key" value to find the current language's translation.
using UnityEngine;
using UnityEngine.UI;
public class KeyValueForLocalization : MonoBehaviour {
public string Key;
private Text parentGuiText;
void Awake() {
parentGuiText = gameObject.GetComponent<Text>();
parentGuiText.text = UFE.Localization.GetTextValue(Key);
}
}
Now, you can attach this script to any UI element that has a Text component like the Menu options. You state the Key that element represents and it will update the text value to be whatever is that Language's value.
From there it's just a matter of creating a UI element in the Options menu that calls Localization.ChangeLanguage() to whatever language option you want.