public DeepLWindow(DeepLTranslationOptions options, bool tellMeAction) { InitializeComponent(); _tellMeAction = tellMeAction; Options = options; IsEnabled = false; }
public DeepLWindow(DeepLTranslationOptions options, TranslationProviderCredential credentialStore = null, LanguagePair[] languagePairs = null, bool isTellMeAction = false) { InitializeComponent(); _isTellMeAction = isTellMeAction; var currentLanguagePairs = isTellMeAction ? options?.LanguagesSupported?.Keys.Select(key => new CultureInfo(key)).ToList() : languagePairs?.Select(lp => new CultureInfo(lp.TargetCultureName)).ToList(); NotCompatibleBlock.Visibility = Helpers.AreLanguagesCompatibleWithFormalityParameter(currentLanguagePairs) ? Visibility.Collapsed : Visibility.Visible; Formality.SelectedIndex = (int)options.Formality; PlainText.IsChecked = options.SendPlainText; Options = options; if (isTellMeAction) { ApiKeyBox.IsEnabled = false; } else { if (credentialStore != null) { ApiKeyBox.Password = credentialStore.Credential; } } }
public DeepLMtTranslationProviderLanguageDirection(DeepLMtTranslationProvider deepLMtTranslationProvider, LanguagePair languageDirection, DeepLTranslationProviderConnecter connecter) { _deepLMtTranslationProvider = deepLMtTranslationProvider; _languageDirection = languageDirection; _options = deepLMtTranslationProvider.Options; _connecter = connecter; }
public DeepLMtTranslationProvider(DeepLTranslationOptions options, DeepLTranslationProviderConnecter deepLTranslationProviderConnecter, LanguagePair[] languagePairs = null) { DeepLTranslationProviderConnecter = deepLTranslationProviderConnecter; Options = options; if (languagePairs != null) { GetSupportedTargetLanguages(languagePairs); } }
public DeepLWindow(DeepLTranslationOptions options, bool tellMeAction) { InitializeComponent(); _tellMeAction = tellMeAction; Options = options; if (options != null) { SettingsTab.Resend.IsChecked = options.ResendDrafts; } DeepLTabControl.SelectedIndex = 1; LoginTab.IsEnabled = false; }
public DeepLWindow(DeepLTranslationOptions options, TranslationProviderCredential credentialStore) { InitializeComponent(); Options = options; if (credentialStore != null) { LoginTab.ApiKeyBox.Password = credentialStore.Credential; } if (options != null) { SettingsTab.Resend.IsChecked = options.ResendDrafts; } }
public DeepLWindow(DeepLTranslationOptions options, TranslationProviderCredential credentialStore, LanguagePair[] languagePairs) { _languagePairs = languagePairs; InitializeComponent(); Options = options; if (credentialStore != null) { ApiKeyBox.Password = credentialStore.Credential; } PlainText.IsChecked = Options.SendPlainText; GetSupportedTargetLanguages(); }
public DeepLWindow(DeepLTranslationOptions options, TranslationProviderCredential credentialStore = null, LanguagePair[] languagePairs = null, bool isTellMeAction = false) { InitializeComponent(); _languagePairs = languagePairs; _isTellMeAction = isTellMeAction; Formality.SelectedIndex = (int)options.Formality; PlainText.IsChecked = options.SendPlainText; Options = options; PasswordChangedTimer.Elapsed += OnPasswordChanged; SetSettingsOnWindow(credentialStore, isTellMeAction); }
public DeepLWindow(DeepLTranslationOptions options, TranslationProviderCredential credentialStore, LanguagePair[] languagePairs) { _languagePairs = languagePairs; InitializeComponent(); Options = options; if (credentialStore != null) { LoginTab.ApiKeyBox.Password = credentialStore.Credential; } if (options != null) { SettingsTab.Resend.IsChecked = options.ResendDrafts; } GetSupportedTargetLanguages(); }
public override void Execute() { var currentProject = SdlTradosStudio.Application.GetController <ProjectsController>().CurrentProject; if (currentProject == null) { MessageBox.Show(@"No project is set as active"); } else { var settings = currentProject.GetTranslationProviderConfiguration(); if (!settings.Entries.Any(entry => entry.MainTranslationProvider.Uri.OriginalString.Contains("deepltranslationprovider"))) { MessageBox.Show( @"DeepL is not set on this project\nPlease set it in project settings before using TellMe to access it"); } else { var translationProvider = settings.Entries.FirstOrDefault(entry => entry.MainTranslationProvider.Uri.OriginalString.Contains("deepltranslationprovider")); if (translationProvider != null) { var uri = translationProvider.MainTranslationProvider.Uri; var options = new DeepLTranslationOptions(uri); var dialog = new DeepLWindow(options, true); dialog.ShowDialog(); if (dialog.DialogResult.HasValue && dialog.DialogResult.Value) { settings.Entries .Find(entry => entry.MainTranslationProvider.Uri.OriginalString.Contains( "deepltranslationprovider")) .MainTranslationProvider.Uri = options.Uri; currentProject.UpdateTranslationProviderConfiguration(settings); } } } } }
public ITranslationProvider CreateTranslationProvider(Uri translationProviderUri, string translationProviderState, ITranslationProviderCredentialStore credentialStore) { var originalUri = new Uri(PluginResources.DeeplTranslationProviderScheme); var options = new DeepLTranslationOptions(translationProviderUri, translationProviderState); if (credentialStore.GetCredential(originalUri) != null) { var credentials = credentialStore.GetCredential(originalUri); options.ApiKey = credentials.Credential; } else { credentialStore.AddCredential(originalUri, new TranslationProviderCredential(Guid.NewGuid().ToString(), true)); } if (credentialStore.GetCredential(originalUri) != null) { var credentials = credentialStore.GetCredential(originalUri); options.Identifier = credentials.Credential; } return(new DeepLMtTranslationProvider(options, new DeepLTranslationProviderConnecter(options.ApiKey, options.Formality))); }
public ITranslationProvider[] Browse(IWin32Window owner, LanguagePair[] languagePairs, ITranslationProviderCredentialStore credentialStore) { var options = new DeepLTranslationOptions(); //get credentials var credentials = GetCredentials(credentialStore, PluginResources.DeeplTranslationProviderScheme); var dialog = new DeepLWindow(options, credentials, languagePairs); ElementHost.EnableModelessKeyboardInterop(dialog); dialog.ShowDialog(); if (dialog.DialogResult.HasValue && dialog.DialogResult.Value) { var provider = new DeepLMtTranslationProvider(options, new DeepLTranslationProviderConnecter(options.ApiKey, options.Formality), languagePairs) { Options = dialog.Options }; var apiKey = dialog.Options.ApiKey; SetDeeplCredentials(credentialStore, apiKey, true); return(new ITranslationProvider[] { provider }); } return(null); }