A simple way to translate strings in a project
A more detailed description can be found on my blog: https://www.anton.website/a-simple-localization-system/ and https://www.anton.website/upgrading-the-localization-system/. These posts are describing earlier versions of this system.
- Open Localization window from the Localization -> Show Localization menu.
- Click to Load localization file button a) If exists, Localization.csv file will be loaded from StreamingAssets folder b) If not a default localization data will be loaded
- Add StringLocalizer.cs script to a game object with TMPro.TextMeshProUGI component attached
- Set the relevant string id
- Add DropdownLocalizer.cs script to a game object with TMPro.TMP_Dropdown component attached
- Set the "Label" field with the label of the dropdown object
- Set the relevant ids for each option
- Use
Localizer.Get(Translation id)
method to get a translation for the current language - Use
Localizer.Get(string language, Translation id)
method to get a translation for a specific language - Use
Localizer.CurrentLanguage
to get or set the current language a)Localizer.languageChanged
action is fired whenever current language is changed - Use
Localizer.Languages
to get a list of all languages
You are free to use semicolon (;) in the custom editor UI. The asset can handle it. However, if you want to edit the Localization.csv with an external editor add backslash () before the semicolon. If you need to have the backslash at the end of a string, add another one before it.
escapeCharacterExample_1;To add semicolon write it like this \; <-. It will work;Noktalı virgü bu şekilde eklenebilir \; <-.
escapeCharacterExample_2;To add the escape character to the end of a string do this: \\;İşaretini satırın sonunda şu şekilde kullanabilirsiniz: \\