void BOkClick(object sender, EventArgs e)
        {
            LanguageCollection checkedFromLanguages = new LanguageCollection();
            LanguageCollection checkedToLanguages   = new LanguageCollection();

            foreach (LanguageDataContainer ldc in lbFrom.CheckedItems)
            {
                if (ldc.Language != Language.Any)
                {
                    checkedFromLanguages.Add(ldc.Language);
                }
            }

            foreach (LanguageDataContainer ldc in lbTo.CheckedItems)
            {
                if (ldc.Language != Language.Any)
                {
                    checkedToLanguages.Add(ldc.Language);
                }
            }

            if (checkedFromLanguages.Count == 0)
            {
                MessageBox.Show(FindForm(),
                                TranslateString("Please select at least one source language"),
                                Constants.AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                DialogResult = DialogResult.None;
                return;
            }

            if (checkedToLanguages.Count == 0)
            {
                MessageBox.Show(FindForm(),
                                TranslateString("Please select at least one target language"),
                                Constants.AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                DialogResult = DialogResult.None;
                return;
            }

            profile.DisabledSourceLanguages.Clear();
            foreach (LanguageDataContainer ldc in lbFrom.Items)
            {
                if (ldc.Language != Language.Any && !checkedFromLanguages.Contains(ldc.Language))
                {
                    profile.DisabledSourceLanguages.Add(ldc.Language);
                }
            }



            profile.DisabledTargetLanguages.Clear();
            foreach (LanguageDataContainer ldc in lbTo.Items)
            {
                if (ldc.Language != Language.Any && !checkedToLanguages.Contains(ldc.Language))
                {
                    profile.DisabledTargetLanguages.Add(ldc.Language);
                }
            }
        }
예제 #2
0
        public LiveTranslator()
        {
            CharsLimit = 15000;
            WordsLimit = 500;
            Name       = "_translator";

            AddSupportedSubject(SubjectConstants.Common);

            LanguageCollection tmp       = new LanguageCollection();
            LanguageCollection languages = new LanguageCollection();

            foreach (KeyValuePair <Language, string> kvp in langToKey)
            {
                if (kvp.Key != Language.English_GB && kvp.Key != Language.English_US)
                {
                    tmp.Add(kvp.Key);
                    languages.Add(kvp.Key);
                }
            }

            foreach (Language from in languages)
            {
                foreach (Language to in tmp)
                {
                    if (from != to && to != Language.Autodetect)
                    {
                        if (from == Language.English)
                        {
                            AddSupportedTranslationFromEnglish(to);
                        }
                        else if (to == Language.English)
                        {
                            AddSupportedTranslationToEnglish(from);
                        }
                        else
                        {
                            AddSupportedTranslation(from, to);
                        }
                    }
                }
            }
        }
        void LoadLanguages()
        {
            SuspendLayout();
            lbFrom.Items.Clear();
            lbTo.Items.Clear();

            LanguageCollection fromLangs = new LanguageCollection();
            LanguageCollection toLangs   = new LanguageCollection();

            foreach (LanguagePair lp in Manager.LanguagePairServiceItems.Keys)
            {
                if (!fromLangs.Contains(lp.From))
                {
                    fromLangs.Add(lp.From);
                }

                if (!toLangs.Contains(lp.To))
                {
                    toLangs.Add(lp.To);
                }
            }

            fromLangs.Sort();

            string val = "";
            int    idx;

            val = "+" + TranslateString("Toggle all");
            lbFrom.Items.Add(new LanguageDataContainer(Language.Any, val));

            foreach (Language l in fromLangs)
            {
                val = LangPack.TranslateLanguage(l);
                idx = lbFrom.Items.Add(new LanguageDataContainer(l, val));
                lbFrom.SetItemChecked(idx, !profile.DisabledSourceLanguages.Contains(l));
            }

            lbFrom.SetItemChecked(0, lbFrom.CheckedItems.Count == fromLangs.Count);

            if (lbFrom.Items.Count > 0)
            {
                lbFrom.SelectedIndex = 0;
            }

            toLangs.Sort();

            val = "+" + TranslateString("Toggle all");
            lbTo.Items.Add(new LanguageDataContainer(Language.Any, val));

            foreach (Language l in toLangs)
            {
                val = LangPack.TranslateLanguage(l);
                idx = lbTo.Items.Add(new LanguageDataContainer(l, val));
                lbTo.SetItemChecked(idx, !profile.DisabledTargetLanguages.Contains(l));
            }

            lbTo.SetItemChecked(0, lbTo.CheckedItems.Count == toLangs.Count);

            if (lbTo.Items.Count > 0)
            {
                lbTo.SelectedIndex = 0;
            }

            ResumeLayout(true);
        }
예제 #4
0
 protected internal void AddSupportedLanguage(Language language)
 {
     supportedLanguages.Add(language);
 }
예제 #5
0
        static GoogleTranslator()
        {
            languages = new LanguageCollection();
            languages.Add(Language.Autodetect);
            languages.Add(Language.Arabic);
            languages.Add(Language.Bulgarian);
            languages.Add(Language.Catalan);
            languages.Add(Language.Chinese);
            languages.Add(Language.Chinese_CN);
            languages.Add(Language.Chinese_TW);
            languages.Add(Language.Croatian);
            languages.Add(Language.Czech);
            languages.Add(Language.Danish);
            languages.Add(Language.Dutch);
            languages.Add(Language.English);
            languages.Add(Language.Filipino);
            languages.Add(Language.Finnish);
            languages.Add(Language.French);
            languages.Add(Language.German);
            languages.Add(Language.Greek);
            languages.Add(Language.Hebrew);
            languages.Add(Language.Hindi);
            languages.Add(Language.Indonesian);
            languages.Add(Language.Italian);
            languages.Add(Language.Japanese);
            languages.Add(Language.Korean);
            languages.Add(Language.Latvian);
            languages.Add(Language.Lithuanian);
            languages.Add(Language.Norwegian);
            languages.Add(Language.Polish);
            languages.Add(Language.Portuguese);
            languages.Add(Language.Romanian);
            languages.Add(Language.Russian);
            languages.Add(Language.Serbian);
            languages.Add(Language.Slovak);
            languages.Add(Language.Slovenian);
            languages.Add(Language.Spanish);
            languages.Add(Language.Swedish);
            languages.Add(Language.Ukrainian);
            languages.Add(Language.Vietnamese);

            char[] delimiterChars = { ',', '.', ';', '\n', '!', '?' };

            delimiterCharsList = new List <char>(delimiterChars);
            delimiterCharsList.Sort();
        }