Localized Strings
The LocalizedString class is a replacement of the regular string that automatically translates its content to the current Language.
When assigning a value to a LocalizedString it uses a Term name, and when getting a value it returns the Term's translation.
LocalizedString locString = "Term2"; LocalizationManager.CurrentLanguage = "English"; string translation = locString; // returns the translation of Term2 to English (e.g. 'This is an example') LocalizationManager.CurrentLanguage = "Spanish"; string translation = locString; // returns the translation of Term2 to Spanish (e.g. 'Este es un ejemplo') |
If a LocalizedString variable is exposed in the inspector, it will show a custom inspector to allow selecting a term and modifying the localization modifiers.
public class Example_LocalizedString : MonoBehaviour { // This string sets a Term in the inspector, but returns its translation public LocalizedString _MyLocalizedString; // This is regular string, it shows the standard TextField inspector public string _NormalString; [TermsPopup] public string _StringWithTermPopup; // Example of making a normal string // showing a custom term's inspector } |
LocalizedString also have properties to control how the Right-To-Left is handled:
LocalizedString customString = "Term3"; customString.mRTL_IgnoreArabicFix = false; customString.mRTL_ConvertNumbers = true; customString.mRTL_MaxLineLength = 20; Debug.Log(customString); |
For more examples on how to use LocalizedString, see the Example scene "I2/Localization/Examples/Scenes/I2Localization features LocalizedString"
That scene uses the script "Assets\I2\Localization\Examples\Common\Scripts\Example_LocalizedString.cs" to showcase how to use this class.
Created with the Personal Edition of HelpNDoc: Qt Help documentation made easy