public override string ToString() { string translation = LocalizationManager.GetTermTranslation(mTerm, !mRTL_IgnoreArabicFix, mRTL_MaxLineLength, !mRTL_ConvertNumbers); LocalizationManager.ApplyLocalizationParams(ref translation, null); return(translation); }
public void OnModifyLocalization() { if (!string.IsNullOrEmpty(Localize.MainTranslation)) { string termTranslation = LocalizationManager.GetTermTranslation("Color/Red"); Localize.MainTranslation = Localize.MainTranslation.Replace("{PLAYER_COLOR}", termTranslation); } }
public void OnModifyLocalization() { if (string.IsNullOrEmpty(Localize.MainTranslation)) { return; } string PlayerColor = LocalizationManager.GetTermTranslation("Color/Red"); Localize.MainTranslation = Localize.MainTranslation.Replace("{PLAYER_COLOR}", PlayerColor); }
public void UpdateLocalization() { Dropdown component = GetComponent <Dropdown>(); if (!(component == null)) { component.options.Clear(); foreach (string term in _Terms) { string termTranslation = LocalizationManager.GetTermTranslation(term); component.options.Add(new Dropdown.OptionData(termTranslation)); } component.RefreshShownValue(); } }
public void UpdateLocalization() { var _Dropdown = GetComponent <Dropdown>(); if (_Dropdown == null) { return; } _Dropdown.options.Clear(); foreach (var term in _Terms) { var translation = LocalizationManager.GetTermTranslation(term); _Dropdown.options.Add(new Dropdown.OptionData(translation)); } _Dropdown.RefreshShownValue(); }
public void OnLocalize(bool Force = false) { if (!string.IsNullOrEmpty(mTerm) && !(mTarget == null) && (Force || (base.enabled && !(base.gameObject == null) && base.gameObject.activeInHierarchy)) && !string.IsNullOrEmpty(LocalizationManager.CurrentLanguage) && (Force || !(LastLocalizedLanguage == LocalizationManager.CurrentLanguage))) { LastLocalizedLanguage = LocalizationManager.CurrentLanguage; TMP_Text tMP_Text = mTarget as TextMeshProUGUI; if (tMP_Text == null) { tMP_Text = (mTarget as TextMeshPro); } string termTranslation = LocalizationManager.GetTermTranslation(mTerm); if ((bool)tMP_Text) { tMP_Text.text = termTranslation; } else { Debug.Log("text box wrong type: " + base.name + " " + mTerm); } } }
public void OnLocalize(bool Force = false) { if (!Force && (!enabled || gameObject == null || !gameObject.activeInHierarchy)) { return; } if (string.IsNullOrEmpty(LocalizationManager.CurrentLanguage)) { return; } if (!AlwaysForceLocalize && !Force && !LocalizeCallBack.HasCallback() && LastLocalizedLanguage == LocalizationManager.CurrentLanguage) { return; } LastLocalizedLanguage = LocalizationManager.CurrentLanguage; if (!HasTargetCache()) { FindTarget(); } if (!HasTargetCache()) { return; } // These are the terms actually used (will be mTerm/mSecondaryTerm or will get them from the objects if those are missing. e.g. Labels' text and font name) if (string.IsNullOrEmpty(FinalTerm) || string.IsNullOrEmpty(FinalSecondaryTerm)) { GetFinalTerms(out FinalTerm, out FinalSecondaryTerm); } bool hasCallback = Application.isPlaying && LocalizeCallBack.HasCallback(); if (!hasCallback && string.IsNullOrEmpty(FinalTerm) && string.IsNullOrEmpty(FinalSecondaryTerm)) { return; } CallBackTerm = FinalTerm; CallBackSecondaryTerm = FinalSecondaryTerm; MainTranslation = string.IsNullOrEmpty(FinalTerm) || FinalTerm == "-" ? null : LocalizationManager.GetTermTranslation(FinalTerm, false); SecondaryTranslation = string.IsNullOrEmpty(FinalSecondaryTerm) || FinalSecondaryTerm == "-" ? null : LocalizationManager.GetTermTranslation(FinalSecondaryTerm, false); if (!hasCallback && /*string.IsNullOrEmpty (MainTranslation)*/ string.IsNullOrEmpty(FinalTerm) && string.IsNullOrEmpty(SecondaryTranslation)) { return; } CurrentLocalizeComponent = this; if (Application.isPlaying) { LocalizeCallBack.Execute(this); // This allows scripts to modify the translations : e.g. "Player {0} wins" -> "Player Red wins" LocalizationManager.ApplyLocalizationParams(ref MainTranslation, gameObject); } bool applyRTL = LocalizationManager.IsRight2Left && !IgnoreRTL; if (applyRTL) { if (AllowMainTermToBeRTL && !string.IsNullOrEmpty(MainTranslation)) { MainTranslation = LocalizationManager.ApplyRTLfix(MainTranslation, MaxCharactersInRTL, IgnoreNumbersInRTL); } if (AllowSecondTermToBeRTL && !string.IsNullOrEmpty(SecondaryTranslation)) { SecondaryTranslation = LocalizationManager.ApplyRTLfix(SecondaryTranslation); } } if (PrimaryTermModifier != TermModification.DontModify) { MainTranslation = MainTranslation ?? string.Empty; } switch (PrimaryTermModifier) { case TermModification.ToUpper: MainTranslation = MainTranslation.ToUpper(); break; case TermModification.ToLower: MainTranslation = MainTranslation.ToLower(); break; case TermModification.ToUpperFirst: MainTranslation = GoogleTranslation.UppercaseFirst(MainTranslation); break; case TermModification.ToTitle: MainTranslation = GoogleTranslation.TitleCase(MainTranslation); break; } if (SecondaryTermModifier != TermModification.DontModify) { SecondaryTranslation = SecondaryTranslation ?? string.Empty; } switch (SecondaryTermModifier) { case TermModification.ToUpper: SecondaryTranslation = SecondaryTranslation.ToUpper(); break; case TermModification.ToLower: SecondaryTranslation = SecondaryTranslation.ToLower(); break; case TermModification.ToUpperFirst: SecondaryTranslation = GoogleTranslation.UppercaseFirst(SecondaryTranslation); break; case TermModification.ToTitle: SecondaryTranslation = GoogleTranslation.TitleCase(SecondaryTranslation); break; } if (!string.IsNullOrEmpty(TermPrefix)) { MainTranslation = applyRTL ? MainTranslation + TermPrefix : TermPrefix + MainTranslation; } if (!string.IsNullOrEmpty(TermSuffix)) { MainTranslation = applyRTL ? TermSuffix + MainTranslation : MainTranslation + TermSuffix; } EventDoLocalize(MainTranslation, SecondaryTranslation); CurrentLocalizeComponent = null; }
public void OnLocalize(bool Force = false) { if (!Force && (!enabled || gameObject == null || !gameObject.activeInHierarchy)) { return; } if (string.IsNullOrEmpty(LocalizationManager.CurrentLanguage)) { return; } if (!Force && LastLocalizedLanguage == LocalizationManager.CurrentLanguage) { return; } LastLocalizedLanguage = LocalizationManager.CurrentLanguage; if (!HasTargetCache()) { FindTarget(); } if (!HasTargetCache()) { return; } // This are the terms actually used (will be mTerm/mSecondaryTerm or will get them from the objects if those are missing. e.g. Labels' text and font name) if (string.IsNullOrEmpty(FinalTerm) || string.IsNullOrEmpty(FinalSecondaryTerm)) { GetFinalTerms(out FinalTerm, out FinalSecondaryTerm); } if (string.IsNullOrEmpty(FinalTerm) && string.IsNullOrEmpty(FinalSecondaryTerm)) { return; } CallBackTerm = FinalTerm; CallBackSecondaryTerm = FinalSecondaryTerm; MainTranslation = LocalizationManager.GetTermTranslation(FinalTerm); SecondaryTranslation = LocalizationManager.GetTermTranslation(FinalSecondaryTerm); if (string.IsNullOrEmpty(MainTranslation) && string.IsNullOrEmpty(SecondaryTranslation)) { return; } CurrentLocalizeComponent = this; LocalizeCallBack.Execute(this); // This allows scripts to modify the translations : e.g. "Player {0} wins" -> "Player Red wins" if (LocalizationManager.IsRight2Left && !IgnoreRTL) { if (AllowMainTermToBeRTL && !string.IsNullOrEmpty(MainTranslation)) { MainTranslation = LocalizationManager.ApplyRTLfix(MainTranslation, MaxCharactersInRTL); } if (AllowSecondTermToBeRTL && !string.IsNullOrEmpty(SecondaryTranslation)) { SecondaryTranslation = LocalizationManager.ApplyRTLfix(SecondaryTranslation); } } switch (PrimaryTermModifier) { case TermModification.ToUpper: MainTranslation = MainTranslation.ToUpper(); break; case TermModification.ToLower: MainTranslation = MainTranslation.ToLower(); break; case TermModification.ToUpperFirst: MainTranslation = GoogleTranslation.UppercaseFirst(MainTranslation); break; case TermModification.ToTitle: MainTranslation = GoogleTranslation.TitleCase(MainTranslation); break; } switch (SecondaryTermModifier) { case TermModification.ToUpper: SecondaryTranslation = SecondaryTranslation.ToUpper(); break; case TermModification.ToLower: SecondaryTranslation = SecondaryTranslation.ToLower(); break; case TermModification.ToUpperFirst: SecondaryTranslation = GoogleTranslation.UppercaseFirst(SecondaryTranslation); break; case TermModification.ToTitle: SecondaryTranslation = GoogleTranslation.TitleCase(SecondaryTranslation); break; } EventDoLocalize(MainTranslation, SecondaryTranslation); CurrentLocalizeComponent = null; }
public static string Get(string Term, bool FixForRTL, int maxLineLengthForRTL) { return(LocalizationManager.GetTermTranslation(Term, FixForRTL, maxLineLengthForRTL)); }
public static string Get(string Term) { return(LocalizationManager.GetTermTranslation(Term, LocalizationManager.IsRight2Left, 0, false)); }
public static string Get(string Term, bool FixForRTL) { return(LocalizationManager.GetTermTranslation(Term, FixForRTL, 0, false)); }
public void OnLocalize(bool Force = false) { if ((!Force && (!base.enabled || base.gameObject == null || !base.gameObject.activeInHierarchy)) || string.IsNullOrEmpty(LocalizationManager.CurrentLanguage) || (!AlwaysForceLocalize && !Force && !LocalizeCallBack.HasCallback() && LastLocalizedLanguage == LocalizationManager.CurrentLanguage)) { return; } LastLocalizedLanguage = LocalizationManager.CurrentLanguage; if (!HasTargetCache()) { FindTarget(); } if (!HasTargetCache()) { return; } if (string.IsNullOrEmpty(FinalTerm) || string.IsNullOrEmpty(FinalSecondaryTerm)) { GetFinalTerms(out FinalTerm, out FinalSecondaryTerm); } bool flag = Application.isPlaying && LocalizeCallBack.HasCallback(); if (!flag && string.IsNullOrEmpty(FinalTerm) && string.IsNullOrEmpty(FinalSecondaryTerm)) { return; } CallBackTerm = FinalTerm; CallBackSecondaryTerm = FinalSecondaryTerm; MainTranslation = ((string.IsNullOrEmpty(FinalTerm) || FinalTerm == "-") ? null : LocalizationManager.GetTermTranslation(FinalTerm, FixForRTL: false)); SecondaryTranslation = ((string.IsNullOrEmpty(FinalSecondaryTerm) || FinalSecondaryTerm == "-") ? null : LocalizationManager.GetTermTranslation(FinalSecondaryTerm, FixForRTL: false)); if (!flag && string.IsNullOrEmpty(FinalTerm) && string.IsNullOrEmpty(SecondaryTranslation)) { return; } CurrentLocalizeComponent = this; if (Application.isPlaying) { LocalizeCallBack.Execute(this); LocalizationManager.ApplyLocalizationParams(ref MainTranslation, base.gameObject); } bool flag2 = LocalizationManager.IsRight2Left && !IgnoreRTL; if (flag2) { if (AllowMainTermToBeRTL && !string.IsNullOrEmpty(MainTranslation)) { MainTranslation = LocalizationManager.ApplyRTLfix(MainTranslation, MaxCharactersInRTL, IgnoreNumbersInRTL); } if (AllowSecondTermToBeRTL && !string.IsNullOrEmpty(SecondaryTranslation)) { SecondaryTranslation = LocalizationManager.ApplyRTLfix(SecondaryTranslation); } } if (PrimaryTermModifier != 0) { MainTranslation = (MainTranslation ?? string.Empty); } switch (PrimaryTermModifier) { case TermModification.ToUpper: MainTranslation = MainTranslation.ToUpper(); break; case TermModification.ToLower: MainTranslation = MainTranslation.ToLower(); break; case TermModification.ToUpperFirst: MainTranslation = GoogleTranslation.UppercaseFirst(MainTranslation); break; case TermModification.ToTitle: MainTranslation = GoogleTranslation.TitleCase(MainTranslation); break; } if (SecondaryTermModifier != 0) { SecondaryTranslation = (SecondaryTranslation ?? string.Empty); } switch (SecondaryTermModifier) { case TermModification.ToUpper: SecondaryTranslation = SecondaryTranslation.ToUpper(); break; case TermModification.ToLower: SecondaryTranslation = SecondaryTranslation.ToLower(); break; case TermModification.ToUpperFirst: SecondaryTranslation = GoogleTranslation.UppercaseFirst(SecondaryTranslation); break; case TermModification.ToTitle: SecondaryTranslation = GoogleTranslation.TitleCase(SecondaryTranslation); break; } if (!string.IsNullOrEmpty(TermPrefix)) { MainTranslation = (flag2 ? (MainTranslation + TermPrefix) : (TermPrefix + MainTranslation)); } if (!string.IsNullOrEmpty(TermSuffix)) { MainTranslation = (flag2 ? (TermSuffix + MainTranslation) : (MainTranslation + TermSuffix)); } EventDoLocalize(MainTranslation, SecondaryTranslation); CurrentLocalizeComponent = null; }