static TermData AddTerm(string Term, bool AutoSelect = true, eTermType termType = eTermType.Text)
        {
            if (Term == "-" || string.IsNullOrEmpty(Term))
            {
                return(null);
            }

            Term = I2Utils.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
 public static void ValidateFullTerm(ref string Term)
 {
     Term = Term.Replace('\\', '/');
     Term = Term.Trim();
     if (Term.StartsWith(EmptyCategory, StringComparison.Ordinal))
     {
         if (Term.Length > EmptyCategory.Length && Term[EmptyCategory.Length] == '/')
         {
             Term = Term.Substring(EmptyCategory.Length + 1);
         }
     }
     Term = I2Utils.RemoveNonASCII(Term, true);
 }
예제 #3
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 (!FindTarget())
            {
                return;
            }


            // if either the primary or secondary term is missing, get them. (e.g. from the label's text and font name)
            if (mLocalizeTarget != null)
            {
                mLocalizeTarget.GetFinalTerms(this, mTerm, mTermSecondary, out primaryTerm, out secondaryTerm);
                primaryTerm = I2Utils.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();
            }
        }
예제 #4
0
 public void SetFinalTerms(string Main, string Secondary, out string primaryTerm, out string secondaryTerm, bool RemoveNonASCII)
 {
     primaryTerm   = RemoveNonASCII ? I2Utils.RemoveNonASCII(Main) : Main;
     secondaryTerm = Secondary;
 }