public string Export_I2CSV(string Category, char Separator = ',')
        {
            StringBuilder Builder = new StringBuilder();

            //--[ Header ]----------------------------------
            Builder.Append("Key[*]Type[*]Desc");
            foreach (LanguageData langData in mLanguages)
            {
                Builder.Append("[*]");
                Builder.Append(GoogleLanguages.GetCodedLanguage(langData.Name, langData.Code));
            }
            Builder.Append("[ln]");

            int  nLanguages = (mLanguages.Count);
            bool firstLine  = true;

            foreach (TermData termData in mTerms)
            {
                string Term;

                if (string.IsNullOrEmpty(Category) || (Category == EmptyCategory && termData.Term.IndexOfAny(CategorySeparators) < 0))
                {
                    Term = termData.Term;
                }
                else
                if (termData.Term.StartsWith(Category + @"/") && Category != termData.Term)
                {
                    Term = termData.Term.Substring(Category.Length + 1);
                }
                else
                {
                    continue;                       // Term doesn't belong to this category
                }
                if (!firstLine)
                {
                    Builder.Append("[ln]");
                }
                else
                {
                    firstLine = false;
                }

                AppendI2Term(Builder, nLanguages, Term, termData, string.Empty, termData.Languages, termData.Languages_Touch, Separator, (byte)TranslationFlag.AutoTranslated_Normal, (byte)TranslationFlag.AutoTranslated_Touch);

                if (termData.HasTouchTranslations())
                {
                    if (!firstLine)
                    {
                        Builder.Append("[ln]");
                    }
                    else
                    {
                        firstLine = false;
                    }
                    AppendI2Term(Builder, nLanguages, Term, termData, "[touch]", termData.Languages_Touch, null, Separator, (byte)TranslationFlag.AutoTranslated_Touch, (byte)TranslationFlag.AutoTranslated_Normal);
                }
            }
            return(Builder.ToString());
        }
예제 #2
0
        public string Export_I2CSV(string Category, char Separator = ',')
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("Key[*]Type[*]Desc");
            foreach (LanguageData mLanguage in mLanguages)
            {
                stringBuilder.Append("[*]");
                if (!mLanguage.IsEnabled())
                {
                    stringBuilder.Append('$');
                }
                stringBuilder.Append(GoogleLanguages.GetCodedLanguage(mLanguage.Name, mLanguage.Code));
            }
            stringBuilder.Append("[ln]");
            int  count = mLanguages.Count;
            bool flag  = true;

            foreach (TermData mTerm in mTerms)
            {
                string term;
                if (string.IsNullOrEmpty(Category) || (Category == EmptyCategory && mTerm.Term.IndexOfAny(CategorySeparators) < 0))
                {
                    term = mTerm.Term;
                }
                else
                {
                    if (!mTerm.Term.StartsWith(Category + "/") || !(Category != mTerm.Term))
                    {
                        continue;
                    }
                    term = mTerm.Term.Substring(Category.Length + 1);
                }
                if (!flag)
                {
                    stringBuilder.Append("[ln]");
                }
                else
                {
                    flag = false;
                }
                AppendI2Term(stringBuilder, count, term, mTerm, string.Empty, mTerm.Languages, mTerm.Languages_Touch, Separator, 1, 2);
                if (mTerm.HasTouchTranslations())
                {
                    if (!flag)
                    {
                        stringBuilder.Append("[ln]");
                    }
                    else
                    {
                        flag = false;
                    }
                    AppendI2Term(stringBuilder, count, term, mTerm, "[touch]", mTerm.Languages_Touch, null, Separator, 2, 1);
                }
            }
            return(stringBuilder.ToString());
        }
        public string Export_CSV(string Category, char Separator = ',', bool specializationsAsRows = true)
        {
            StringBuilder Builder = new StringBuilder();

            int nLanguages = (mLanguages.Count);

            Builder.AppendFormat("Key{0}Type{0}Desc", Separator);

            foreach (LanguageData langData in mLanguages)
            {
                Builder.Append(Separator);
                if (!langData.IsEnabled())
                {
                    Builder.Append('$');
                }
                AppendString(Builder, GoogleLanguages.GetCodedLanguage(langData.Name, langData.Code), Separator);
            }
            Builder.Append("\n");


            mTerms.Sort((a, b) => string.CompareOrdinal(a.Term, b.Term));

            foreach (TermData termData in mTerms)
            {
                string Term;

                if (string.IsNullOrEmpty(Category) || (Category == EmptyCategory && termData.Term.IndexOfAny(CategorySeparators) < 0))
                {
                    Term = termData.Term;
                }
                else
                if (termData.Term.StartsWith(Category + @"/") && Category != termData.Term)
                {
                    Term = termData.Term.Substring(Category.Length + 1);
                }
                else
                {
                    continue;                       // Term doesn't belong to this category
                }
                if (specializationsAsRows)
                {
                    foreach (var specialization in termData.GetAllSpecializations())
                    {
                        AppendTerm(Builder, nLanguages, Term, termData, specialization, Separator);
                    }
                }
                else
                {
                    AppendTerm(Builder, nLanguages, Term, termData, null, Separator);
                }
            }
            return(Builder.ToString());
        }
예제 #4
0
        public string Export_CSV(string Category, char Separator = ',')
        {
            StringBuilder stringBuilder = new StringBuilder();
            int           count         = mLanguages.Count;

            stringBuilder.AppendFormat("Key{0}Type{0}Desc", Separator);
            foreach (LanguageData mLanguage in mLanguages)
            {
                stringBuilder.Append(Separator);
                if (!mLanguage.IsEnabled())
                {
                    stringBuilder.Append('$');
                }
                AppendString(stringBuilder, GoogleLanguages.GetCodedLanguage(mLanguage.Name, mLanguage.Code), Separator);
            }
            stringBuilder.Append("\n");
            for (int i = 0; i < mTerms.Count - 1; i++)
            {
                for (int j = i + 1; j < mTerms.Count; j++)
                {
                    if (string.CompareOrdinal(mTerms[i].Term, mTerms[j].Term) > 0)
                    {
                        TermData value = mTerms[i];
                        mTerms[i] = mTerms[j];
                        mTerms[j] = value;
                    }
                }
            }
            foreach (TermData mTerm in mTerms)
            {
                string term;
                if (string.IsNullOrEmpty(Category) || (Category == EmptyCategory && mTerm.Term.IndexOfAny(CategorySeparators) < 0))
                {
                    term = mTerm.Term;
                }
                else
                {
                    if (!mTerm.Term.StartsWith(Category + "/") || !(Category != mTerm.Term))
                    {
                        continue;
                    }
                    term = mTerm.Term.Substring(Category.Length + 1);
                }
                AppendTerm(stringBuilder, count, term, mTerm, null, mTerm.Languages, mTerm.Languages_Touch, Separator, 1, 2);
                if (mTerm.HasTouchTranslations())
                {
                    AppendTerm(stringBuilder, count, term, mTerm, "[touch]", mTerm.Languages_Touch, null, Separator, 2, 1);
                }
            }
            return(stringBuilder.ToString());
        }
예제 #5
0
        public string Export_CSV(string Category, char Separator = ',')
        {
            StringBuilder Builder = new StringBuilder();

            int nLanguages = (mLanguages.Count);

            Builder.AppendFormat("Key{0}Type{0}Desc", Separator);

            foreach (LanguageData langData in mLanguages)
            {
                Builder.Append(Separator);
                if (!langData.IsEnabled())
                {
                    Builder.Append('$');
                }
                AppendString(Builder, GoogleLanguages.GetCodedLanguage(langData.Name, langData.Code), Separator);
            }
            Builder.Append("\n");

            mTerms = mTerms.OrderBy(x => x.Term).ToList();
            foreach (TermData termData in mTerms)
            {
                string Term;

                if (string.IsNullOrEmpty(Category) || (Category == EmptyCategory && termData.Term.IndexOfAny(CategorySeparators) < 0))
                {
                    Term = termData.Term;
                }
                else
                if (termData.Term.StartsWith(Category + @"/") && Category != termData.Term)
                {
                    Term = termData.Term.Substring(Category.Length + 1);
                }
                else
                {
                    continue;                           // Term doesn't belong to this category
                }
                AppendTerm(Builder, nLanguages, Term, termData, null, termData.Languages, termData.Languages_Touch, Separator, (byte)TranslationFlag.AutoTranslated_Normal, (byte)TranslationFlag.AutoTranslated_Touch);

                if (termData.HasTouchTranslations())
                {
                    AppendTerm(Builder, nLanguages, Term, termData, "[touch]", termData.Languages_Touch, null, Separator, (byte)TranslationFlag.AutoTranslated_Touch, (byte)TranslationFlag.AutoTranslated_Normal);
                }
            }
            return(Builder.ToString());
        }
        public string Export_I2CSV(string Category, char Separator = ',', bool specializationsAsRows = true)
        {
            StringBuilder Builder = new StringBuilder();

            //--[ Header ]----------------------------------
            Builder.Append("Key[*]Type[*]Desc");
            foreach (LanguageData langData in mLanguages)
            {
                Builder.Append("[*]");
                if (!langData.IsEnabled())
                {
                    Builder.Append('$');
                }
                Builder.Append(GoogleLanguages.GetCodedLanguage(langData.Name, langData.Code));
            }
            Builder.Append("[ln]");

            mTerms.Sort((a, b) => string.CompareOrdinal(a.Term, b.Term));

            int  nLanguages = (mLanguages.Count);
            bool firstLine  = true;

            foreach (TermData termData in mTerms)
            {
                string Term;

                if (string.IsNullOrEmpty(Category) || (Category == EmptyCategory && termData.Term.IndexOfAny(CategorySeparators) < 0))
                {
                    Term = termData.Term;
                }
                else
                if (termData.Term.StartsWith(Category + @"/") && Category != termData.Term)
                {
                    Term = termData.Term.Substring(Category.Length + 1);
                }
                else
                {
                    continue;                       // Term doesn't belong to this category
                }
                if (!firstLine)
                {
                    Builder.Append("[ln]");
                }
                firstLine = false;

                if (!specializationsAsRows)
                {
                    AppendI2Term(Builder, nLanguages, Term, termData, Separator, null);
                }
                else
                {
                    var allSpecializations = termData.GetAllSpecializations();
                    for (int i = 0; i < allSpecializations.Count; ++i)
                    {
                        if (i != 0)
                        {
                            Builder.Append("[ln]");
                        }
                        var specialization = allSpecializations[i];
                        AppendI2Term(Builder, nLanguages, Term, termData, Separator, specialization);
                    }
                }
            }
            return(Builder.ToString());
        }