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);
        }
예제 #2
0
        // 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();
            }
        }
예제 #3
0
 public void SetFinalTerms(string Main, string Secondary, out string primaryTerm, out string secondaryTerm, bool RemoveNonASCII)
 {
     primaryTerm   = RemoveNonASCII ? LocalizationManager.RemoveNonASCII(Main) : Main;
     secondaryTerm = Secondary;
 }