예제 #1
0
        private void buttonTranslate_Click(object sender, EventArgs e)
        {
            if (buttonTranslate.Text == Configuration.Settings.Language.General.Cancel)
            {
                buttonTranslate.Enabled = false;
                _breakTranslation       = true;
                buttonOK.Enabled        = true;
                buttonCancel.Enabled    = true;
                return;
            }

            _targetTwoLetterIsoLanguageName = ((ComboBoxItem)comboBoxTo.SelectedItem).Value;
            Configuration.Settings.Tools.GoogleTranslateLastTargetLanguage = _targetTwoLetterIsoLanguageName;
            var source = ((ComboBoxItem)comboBoxFrom.SelectedItem).Value;

            var language = Configuration.Settings.Language.GoogleTranslate;

            if (_googleTranslate && string.IsNullOrEmpty(Configuration.Settings.Tools.GoogleApiV2Key))
            {
                if (Configuration.Settings.Tools.GoogleApiV2KeyInfoShow)
                {
                    using (var form = new DialogDoNotShowAgain("Subtitle Edit", language.GoogleApiKeyNeeded))
                    {
                        form.ShowDialog(this);
                        Configuration.Settings.Tools.GoogleApiV2KeyInfoShow = !form.DoNoDisplayAgain;
                    }
                }

                if (Configuration.Settings.Tools.GoogleTranslateNoKeyWarningShow)
                {
                    using (var form = new DialogDoNotShowAgain("Subtitle Edit", language.GoogleNoApiKeyWarning))
                    {
                        form.ShowDialog(this);
                        Configuration.Settings.Tools.GoogleTranslateNoKeyWarningShow = !form.DoNoDisplayAgain;
                    }
                }

                labelApiKeyNotFound.Left = linkLabelPoweredByGoogleTranslate.Left + linkLabelPoweredByGoogleTranslate.Width + 20;
                labelApiKeyNotFound.Text = language.GoogleNoApiKeyWarning;

                Translate(source, _targetTwoLetterIsoLanguageName, new GoogleTranslator1(), Configuration.Settings.Tools.GoogleApiV1ChunkSize);
                return;
            }

            if (!_googleTranslate && string.IsNullOrEmpty(Configuration.Settings.Tools.MicrosoftTranslatorApiKey))
            {
                MessageBox.Show(language.MsClientSecretNeeded);
                return;
            }


            if (_googleTranslate)
            {
                Translate(source, _targetTwoLetterIsoLanguageName, new GoogleTranslator2(Configuration.Settings.Tools.GoogleApiV2Key), 1000);
            }
            else
            {
                Translate(source, _targetTwoLetterIsoLanguageName, new MicrosoftTranslator(Configuration.Settings.Tools.MicrosoftTranslatorApiKey, Configuration.Settings.Tools.MicrosoftTranslatorTokenEndpoint, Configuration.Settings.Tools.MicrosoftTranslatorCategory), 1000, MicrosoftTranslator.MaximumRequestArrayLength);
            }
        }
예제 #2
0
 private void ShowEndStatusMessage(string completedMessage)
 {
     LanguageStructure.Main mainLanguage = Configuration.Settings.Language.Main;
     if (_noOfChangedWords > 0 || _noOfAddedWords > 0 || _noOfSkippedWords > 0 || completedMessage == Configuration.Settings.Language.SpellCheck.SpellCheckCompleted)
     {
         Hide();
         if (Configuration.Settings.Tools.SpellCheckShowCompletedMessage)
         {
             var form = new DialogDoNotShowAgain(_mainWindow.Title + " - " + mainLanguage.SpellCheck,
                                                 completedMessage + Environment.NewLine +
                                                 Environment.NewLine +
                                                 string.Format(mainLanguage.NumberOfCorrectedWords, _noOfChangedWords) + Environment.NewLine +
                                                 string.Format(mainLanguage.NumberOfSkippedWords, _noOfSkippedWords) + Environment.NewLine +
                                                 string.Format(mainLanguage.NumberOfCorrectWords, _noOfCorrectWords) + Environment.NewLine +
                                                 string.Format(mainLanguage.NumberOfWordsAddedToDictionary, _noOfAddedWords) + Environment.NewLine +
                                                 string.Format(mainLanguage.NumberOfNameHits, _noOfNamesEtc));
             form.ShowDialog(_mainWindow);
             Configuration.Settings.Tools.SpellCheckShowCompletedMessage = !form.DoNoDisplayAgain;
             form.Dispose();
         }
         else
         {
             if (_noOfChangedWords > 0)
             {
                 _mainWindow.ShowStatus(completedMessage + "  " + string.Format(mainLanguage.NumberOfCorrectedWords, _noOfChangedWords));
             }
             else
             {
                 _mainWindow.ShowStatus(completedMessage);
             }
         }
     }
 }
예제 #3
0
        private void buttonTranslate_Click(object sender, EventArgs e)
        {
            if (buttonTranslate.Text == LanguageSettings.Current.General.Cancel)
            {
                buttonTranslate.Enabled = false;
                _breakTranslation       = true;
                buttonOK.Enabled        = true;
                buttonCancel.Enabled    = true;
                return;
            }

            var translationService = (ITranslationService)comboBoxTranslationServices.SelectedItem;

            if (translationService is GoogleTranslationService &&
                Configuration.Settings.Tools.GoogleTranslateNoKeyWarningShow &&
                string.IsNullOrEmpty(Configuration.Settings.Tools.GoogleApiV2Key))
            {
                using (var form = new DialogDoNotShowAgain("Subtitle Edit", LanguageSettings.Current.GoogleTranslate.GoogleNoApiKeyWarning))
                {
                    form.ShowDialog(this);
                    Configuration.Settings.Tools.GoogleTranslateNoKeyWarningShow = !form.DoNoDisplayAgain;
                }
            }

            ReadLanguageSettings();
            Translate();
        }
예제 #4
0
 private void ShowEndStatusMessage(string completedMessage)
 {
     LanguageStructure.Main mainLanguage = Configuration.Settings.Language.Main;
     if (_noOfChangedWords > 0 || _noOfAddedWords > 0 || _noOfSkippedWords > 0 || completedMessage == Configuration.Settings.Language.SpellCheck.SpellCheckCompleted)
     {
         this.Hide();
         if (Configuration.Settings.Tools.SpellCheckShowCompletedMessage)
         {
             var form = new DialogDoNotShowAgain(_mainWindow.Title + " - " + mainLanguage.SpellCheck,
                             completedMessage + Environment.NewLine +
                             Environment.NewLine +
                             string.Format(mainLanguage.NumberOfCorrectedWords, _noOfChangedWords) + Environment.NewLine +
                             string.Format(mainLanguage.NumberOfSkippedWords, _noOfSkippedWords) + Environment.NewLine +
                             string.Format(mainLanguage.NumberOfCorrectWords, _noOfCorrectWords) + Environment.NewLine +
                             string.Format(mainLanguage.NumberOfWordsAddedToDictionary, _noOfAddedWords) + Environment.NewLine +
                             string.Format(mainLanguage.NumberOfNameHits, _noOfNamesEtc));
             form.ShowDialog(_mainWindow);
             Configuration.Settings.Tools.SpellCheckShowCompletedMessage = !form.DoNoDisplayAgain;
         }
         else
         {
             if (_noOfChangedWords > 0)
                 _mainWindow.ShowStatus(completedMessage + "  " + string.Format(mainLanguage.NumberOfCorrectedWords, _noOfChangedWords));
             else
                 _mainWindow.ShowStatus(completedMessage);
         }
     }
 }