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

            Term = I2Utils.GetValidTermName(Term, true);

            TermData data = mLanguageSource.AddTerm(Term, termType);

            GetParsedTerm(Term);
            string sCategory = LanguageSourceData.GetCategoryFromFullTerm(Term);

            mParsedCategories.Add(sCategory);

            if (AutoSelect)
            {
                if (!mSelectedKeys.Contains(Term))
                {
                    mSelectedKeys.Add(Term);
                }

                if (!mSelectedCategories.Contains(sCategory))
                {
                    mSelectedCategories.Add(sCategory);
                }
            }
            ScheduleUpdateTermsToShowInList();
            mLanguageSource.Editor_SetDirty();
            return(data);
        }
Example #2
0
        string ScriptTool_AdjustTerm(string Term, bool allowFullLength = false)
        {
            Term = I2Utils.GetValidTermName(Term);

            // C# IDs can't start with a number
            if (I2Utils.NumberChars.IndexOf(Term[0]) >= 0)
            {
                Term = "_" + Term;
            }

            if (!allowFullLength && Term.Length > Script_Tool_MaxVariableLength)
            {
                Term = Term.Substring(0, Script_Tool_MaxVariableLength);
            }

            // Remove invalid characters
            char[] chars = Term.ToCharArray();
            for (int i = 0, imax = chars.Length; i < imax; ++i)
            {
                if (I2Utils.ValidChars.IndexOf(chars[i]) < 0)
                {
                    chars[i] = '_';
                }
            }
            return(new string(chars));
        }
 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.GetValidTermName(Term, true);
 }
Example #4
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.GetValidTermName(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();
            }
        }
Example #5
0
 public void SetFinalTerms(string Main, string Secondary, out string primaryTerm, out string secondaryTerm, bool RemoveNonASCII)
 {
     primaryTerm   = RemoveNonASCII ? I2Utils.GetValidTermName(Main) : Main;
     secondaryTerm = Secondary;
 }