static TermData AddTerm(string Term, bool AutoSelect = true, eTermType termType = eTermType.Text) { if (Term == "-" || string.IsNullOrEmpty(Term)) { return(null); } Term = LocalizationManager.RemoveNonASCII(Term, true); TermData data = mLanguageSource.AddTerm(Term, termType); GetParsedTerm(Term); string sCategory = LanguageSource.GetCategoryFromFullTerm(Term); mParsedCategories.Add(sCategory); if (AutoSelect) { if (!mSelectedKeys.Contains(Term)) { mSelectedKeys.Add(Term); } if (!mSelectedCategories.Contains(sCategory)) { mSelectedCategories.Add(sCategory); } } ScheduleUpdateTermsToShowInList(); EditorUtility.SetDirty(mLanguageSource); return(data); }
// Returns the term that will actually be translated // its either the Term value in this class or the text of the label if there is no term public void GetFinalTerms(out string primaryTerm, out string secondaryTerm) { primaryTerm = string.Empty; secondaryTerm = string.Empty; if (!HasTargetCache() && !FindTarget()) { return; } // if either the primary or secondary term is missing, get them. (e.g. from the label's text and font name) if (mTarget != null && (string.IsNullOrEmpty(mTerm) || string.IsNullOrEmpty(mTermSecondary))) { if (mLocalizeTarget != null) { mLocalizeTarget.GetFinalTerms(this, mTerm, mTermSecondary, out primaryTerm, out secondaryTerm); primaryTerm = LocalizationManager.RemoveNonASCII(primaryTerm, false); } } // If there are values already set, go with those if (!string.IsNullOrEmpty(mTerm)) { primaryTerm = mTerm; } if (!string.IsNullOrEmpty(mTermSecondary)) { secondaryTerm = mTermSecondary; } if (primaryTerm != null) { primaryTerm = primaryTerm.Trim(); } if (secondaryTerm != null) { secondaryTerm = secondaryTerm.Trim(); } }
public void SetFinalTerms(string Main, string Secondary, out string primaryTerm, out string secondaryTerm, bool RemoveNonASCII) { primaryTerm = RemoveNonASCII ? LocalizationManager.RemoveNonASCII(Main) : Main; secondaryTerm = Secondary; }