Localization¶
We let you import/export and work with all your localization in the Balancy.
When you create a new parameter, instead of selecting type String, make it Localized String. Whenever you try to access this parameter in the code, it'll instantly give you an already localized value.
Let's say you have a pair "Key": "LocalizedValue":
- You create a new parameter with the type Localized String.
- In the document, you create a new key or choose existing one.
- When you access your parameter from the code, you will get LocalizedValue instead of Key.
- Add new strings and their translations on a separate page.
Section for programmers¶
If you need to request all available Localizations, use GetAllAvailableLanguages
. It returns the dictionaries with keys: en, fr, ru, zh-CN, ...
var allLocs = Balancy.Localization.Manager.GetAllAvailableLanguages();
If you are using our plugin as is, you will get localized string of the Key when trying to get it.
Otherwise, if you are using some other solution to store all the keys, to make everything work, you need to override Balancy method of getting localized values:
Balancy.Localization.Manager.OverloadLocalizationRequests((key)=>{
return YOUR_DICTIONARY[key];
});
To change localization, use ChangeLocalization
method. As the parameter, you must pass one of the keys from the allLocs dictionary.
var allLocs = Balancy.Localization.Manager.ChangeLocalization(localizationCode);
To read the active localization code:
var activeLocale = Balancy.Localization.Manager.ActiveLocaleCode;
To get localized value for the key, use the following method. If the key doesn't exist, we'll return the key as a value.
var localizedValue = Balancy.Localization.Manager.Get("GROUP/KEY");
Export and import into spreadsheets¶
You can export and import all strings into spreadsheets from the localization strings page. We use the same format as I2Localization plugin for Unity.
Column naming
Column name should include language code braced with []
, e. g. English [en].
To make it works, you need the following:
- Open your spreadsheet and share editing access with google-sheets-api@balancy-334816.iam.gserviceaccount.com account.
- Copy spreadsheet id.
- Open the settings localization page. Set the spreadsheet id on the settings page.
UI¶
Suppose you are using a lot of UnityEngine.UI.Text with static text, you'll find accommodating our Components LocalizationText.cs and LocalizationUI.cs. Add it to your GameObject and set the parameter Localization Key value as your Group/Key. It'll automatically put Localized value as Text when you launch the game.
We have the same Component for Text Mesh Pro. You can download it from here