Advanced: Localization
Translate text tooltips!
Localization system basis
The system involves:
The InputStringsScriptableObject object (TSR > TipTextData)
A CSV table with translations (TSR > TipTextData > CSVFile)
The texts from here are embedded in the tutorial steps and separate text objects

Adding translations
To translate, you need to have text hints available in at least one language. To add translations:
Open TSR > TipTextData. This is where all text hints for all scenes and tutorials are stored.
Press "Export current strings to CSV" button.
Edit CSV. Copies of your current strings were created in the "Default" column. Pass them through a translator and insert the translations into the corresponding language columns.
Done. Now, when switching between languages in runtime or edit mode, the strings change according to the translations. The string and its translations are searched by matching text, not tied to specific indices.
Switching language (4 ways)
Changing the language seamlessly updates all text hints both at runtime and in edit mode.
Starting from ATM version 3.0.2, the selected language is saved and loaded between sessions at runtime. If no saved data exists, the Default Language is set initially (English, can be changed).
In inspector: change the language via TSR > TipTextData by simply selecting a different value from the dropdown list.
Via script (recommended): call TSR > TipTextData >
inputTextSettings.ChangeLanguage()method. Specify any language and call the translation directly from the storage, without requiring a reference to the ATM on the scene.

Via script: call TSR > TranslateAllTutorial() method. Use one of the existing languages from the dropdown list for it.
sceneReferences.TranslateAllTutorial(InputStringsScriptableObject.Language.Italian);Via script: call TSR > TranslateAllTutorialByString() method. Specify any language declared in the first row of the CSV file, even one that is not listed in the dropdown menu.
sceneReferences.TranslateAllTutorialByString("Polish");
Adding new language
Open CSV file and fill any empty column with translations
Make sure line 0 in column is named after used language, f.e. "Romanian"
Done. Calling this language for translation is possible via TSR > TranslateAllTutorialByString("Romanian") method or inputTextSettings.ChangeLanguage("Romanian). Link it to a flag button, for example.
Open InputStringsScriptableObject.cs
Find "public enum Language" > "AddCustomLanguage = 11" and replace it with your language, f.e. "Romanian = 11"
Open CSV file and fill 11th column (L) with Romanian translations
Done. To create new languages, use the indices of unused columns, f.e. "CustomLanguage = 16"
Assigning the special fonts
Use the Language Special Fonts list so that when switching to a special language, the text object changes its font - for example, this is relevant for Chinese and Japanese.

Add an entry to the Language Special Fonts list, specify the column name for the language, and assign the corresponding Font.
Also assign the Default Font, which the text will revert to when switching from a special language back to the default.
Set Initial Font = true, so that even the basic ATM tooltips will initially use either the default or the specialized font. Otherwise, they will spawn as-is and only change font when translating, switching to a special language, and back.
Using additional localizable texts
In addition to the tooltips managed by ATM, you can create additional text objects for tooltip prefabs or other purposes. They can also pull translations from the CSV. For this, use the public methods to access it from the ScriptableObject.

Check out the LocalizedTooltip component, which can get a value by row number or string key. It is used in the Graphic Popup Skip Tutorial prefab and in the Tutorial Skipper object on the demo scene - see it as an example.
InitializeLocalizator()
Initializes the translation system. It is recommended to call it at startup for subsequent processing of all translations.
inputTextSettings.InitializeLocalizator();
ChangeLanguage()
Translates the language of all texts associated with the TipTextData.
inputTextSettings.ChangeLanguage("English");
GetCurrentFont()
Gets the current font suitable for the language, if it needs to be applied to a specific text.
objectText.font = inputTextSettings.GetCurrentFont();
GetStringText(int rowIndex)
Gets the text from the table row by number according to the current language.
objectText.text = inputStrings.GetStringText(3) + "...";
GetStringTextByKey(string key)
Gets the text from the table row using a string key from column 0 according to the current language.
objectText.text = inputStrings.GetStringTextByKey("main_menu_play");
FillTextObject(int rowIndex, TMP_Text textToFill)
Fills the text object with the text found in the table. Caches the text to enable automatic translation later without manual triggering.
inputTextSettings.FillTextObject(connectedTableRow, objectText);
FillTextObjectByKey(string key, TMP_Text textToFill)
Fills the text object with the text found in the table. Caches the text to enable automatic translation later without manual triggering.
inputStrings.FillTextObjectByKey("settings_title", settingsText);
ReplacePlaceholders(int rowIndex, params object[] values)
Gets the text containing {} placeholders and replace them with actual variables.
inputStrings.ReplacePlaceholders(2, userName, coins);
FillTextObjectWithPlaceholders(int tableRow, TMP_Text textToFill, params object[] values)
Gets the text containing {} placeholders and replace them with actual variables. Also caches the text to enable automatic translation later without manual triggering.
inputStrings.FillTextObjectWithPlaceholders(5, myTextComponent, "John", 100);
Last updated