public ITranslationProvider CreateTranslationProvider(Uri translationProviderUri, string translationProviderState, ITranslationProviderCredentialStore credentialStore) { AppItializer.EnsureInitializer(); var originalUri = new Uri("sdlmachinetranslationcloudprovider:///"); var options = new BeGlobalTranslationOptions(translationProviderUri); if (credentialStore.GetCredential(originalUri) != null) { var credentials = credentialStore.GetCredential(originalUri); if (options.BeGlobalService == null) { var messageBoxService = new MessageBoxService(); options.BeGlobalService = new BeGlobalV4Translator(options, messageBoxService, credentials); } } else { credentialStore.AddCredential(originalUri, new TranslationProviderCredential(originalUri.ToString(), true)); } var accountId = options.BeGlobalService?.GetUserInformation(); var subscriptionInfo = options.BeGlobalService?.GetLanguagePairs(accountId.ToString()); options.SubscriptionInfo = subscriptionInfo; return(new BeGlobalTranslationProvider(options)); }
public ITranslationProvider[] Browse(IWin32Window owner, LanguagePair[] languagePairs, ITranslationProviderCredentialStore credentialStore) { var options = new BeGlobalTranslationOptions(); var credentials = GetCredentials(credentialStore, "beglobaltranslationprovider:///"); var beGlobalWindow = new BeGlobalWindow(); var beGlobalVm = new BeGlobalWindowViewModel(beGlobalWindow, options, credentials); beGlobalWindow.DataContext = beGlobalVm; beGlobalWindow.ShowDialog(); if (beGlobalWindow.DialogResult.HasValue && beGlobalWindow.DialogResult.Value) { var provider = new BeGlobalTranslationProvider(options) { Options = beGlobalVm.Options }; var clientId = beGlobalVm.Options.ClientId; var clientSecret = beGlobalVm.Options.ClientSecret; SetBeGlobalCredentials(credentialStore, clientId, clientSecret, true); return(new ITranslationProvider[] { provider }); } return(null); }
public ITranslationProvider[] Browse(IWin32Window owner, LanguagePair[] languagePairs, ITranslationProviderCredentialStore credentialStore) { try { var options = new BeGlobalTranslationOptions(); var token = string.Empty; var credentials = GetCredentials(credentialStore, "sdlmachinetranslationcloudprovider:///"); var beGlobalVm = new BeGlobalWindowViewModel(options, languagePairs, credentials); beGlobalVm.BeGlobalWindow.DataContext = beGlobalVm; beGlobalVm.BeGlobalWindow.ShowDialog(); if (beGlobalVm.BeGlobalWindow.DialogResult.HasValue && beGlobalVm.BeGlobalWindow.DialogResult.Value) { var messageBoxService = new MessageBoxService(); beGlobalVm.Options.ClientId = beGlobalVm.BeGlobalWindow.ClientIdBox?.Password.TrimEnd(); beGlobalVm.Options.ClientSecret = beGlobalVm.BeGlobalWindow.ClientSecretBox?.Password.TrimEnd(); var beGlobalService = new BeGlobalV4Translator(beGlobalVm.Options, messageBoxService, credentials); beGlobalVm.Options.BeGlobalService = beGlobalService; var provider = new BeGlobalTranslationProvider(options) { Options = beGlobalVm.Options }; SetCredentials(credentialStore, beGlobalVm.Options.ClientId, beGlobalVm.Options.ClientSecret, true); return(new ITranslationProvider[] { provider }); } } catch (Exception e) { Log.Logger.Error($"{Constants.Browse} {e.Message}\n {e.StackTrace}"); } return(null); }
public ITranslationProvider CreateTranslationProvider(Uri translationProviderUri, string translationProviderState, ITranslationProviderCredentialStore credentialStore) { AppItializer.EnsureInitializer(); var options = new BeGlobalTranslationOptions(translationProviderUri); if (options.BeGlobalService == null) { options.BeGlobalService = new BeGlobalV4Translator(options.Model); } try { var accountId = options.BeGlobalService.GetUserInformation(); var subscriptionInfo = options.BeGlobalService.GetLanguagePairs(accountId.ToString()); options.SubscriptionInfo = subscriptionInfo; } catch (Exception e) { Log.Logger.Error(e, "Error on CreateTranslationProvider"); } return(new BeGlobalTranslationProvider(options)); }
public BeGlobalLanguageDirection(BeGlobalTranslationProvider beGlobalTranslationProvider, LanguagePair languageDirection) { _beGlobalTranslationProvider = beGlobalTranslationProvider; _languageDirection = languageDirection; _options = beGlobalTranslationProvider.Options; _normalizeSourceTextHelper = new NormalizeSourceTextHelper(); _preTranslateHelp = new PreTranslateTempFile(); }
public BeGlobalLanguageDirection(BeGlobalTranslationProvider beGlobalTranslationProvider, LanguagePair languageDirection) { _beGlobalTranslationProvider = beGlobalTranslationProvider; _languageDirection = languageDirection; _options = beGlobalTranslationProvider.Options; _normalizeSourceTextHelper = new NormalizeSourceTextHelper(); _translationUnits = new List <TranslationUnit>(); }
public ITranslationProvider CreateTranslationProvider(Uri translationProviderUri, string translationProviderState, ITranslationProviderCredentialStore credentialStore) { var originalUri = new Uri("sdlmachinetranslationcloudprovider:///"); var options = new BeGlobalTranslationOptions(translationProviderUri); if (credentialStore.GetCredential(originalUri) != null) { var credentials = credentialStore.GetCredential(originalUri); var splitedCredentials = credentials.Credential.Split('#'); options.ClientId = StringExtensions.Base64Decode(splitedCredentials[0]); options.ClientSecret = StringExtensions.Base64Decode(splitedCredentials[1]); if (options.BeGlobalService == null) { options.BeGlobalService = new BeGlobalV4Translator(_url, options); } } else { credentialStore.AddCredential(originalUri, new TranslationProviderCredential(originalUri.ToString(), true)); } int accountId; if (options.UseClientAuthentication) { accountId = options.BeGlobalService.GetClientInformation(); } else { accountId = options.BeGlobalService.GetUserInformation(); } var subscriptionInfo = options.BeGlobalService.GetLanguagePairs(accountId.ToString()); options.SubscriptionInfo = subscriptionInfo; return(new BeGlobalTranslationProvider(options)); }
public ITranslationProvider[] Browse(IWin32Window owner, LanguagePair[] languagePairs, ITranslationProviderCredentialStore credentialStore) { try { AppItializer.EnsureInitializer(); var options = new BeGlobalTranslationOptions(); var token = string.Empty; Application.Current?.Dispatcher?.Invoke(() => { token = _studioCredentials.GetToken(); }); if (!string.IsNullOrEmpty(token)) { var beGlobalWindow = new BeGlobalWindow(); var beGlobalVm = new BeGlobalWindowViewModel(beGlobalWindow, options, languagePairs); beGlobalWindow.DataContext = beGlobalVm; beGlobalWindow.ShowDialog(); if (beGlobalWindow.DialogResult.HasValue && beGlobalWindow.DialogResult.Value) { var beGlobalService = new BeGlobalV4Translator(beGlobalVm.Options.Model); beGlobalVm.Options.BeGlobalService = beGlobalService; var provider = new BeGlobalTranslationProvider(options) { Options = beGlobalVm.Options }; return(new ITranslationProvider[] { provider }); } } } catch (Exception e) { Log.Logger.Error($"Browse: {e.Message}\n {e.StackTrace}"); } return(null); }
public ITranslationProvider CreateTranslationProvider(Uri translationProviderUri, string translationProviderState, ITranslationProviderCredentialStore credentialStore) { var originalUri = new Uri("beglobaltranslationprovider:///"); var options = new BeGlobalTranslationOptions(translationProviderUri); if (credentialStore.GetCredential(originalUri) != null) { var credentials = credentialStore.GetCredential(originalUri); var splitedCredentials = credentials.Credential.Split('#'); options.ClientId = splitedCredentials[0]; options.ClientSecret = splitedCredentials[1]; } else { credentialStore.AddCredential(originalUri, new TranslationProviderCredential(originalUri.ToString(), true)); } var beGlobalTranslator = new BeGlobalV4Translator("https://translate-api.sdlbeglobal.com", options.ClientId, options.ClientSecret, string.Empty, string.Empty, options.Model, options.UseClientAuthentication); int accountId; if (options.UseClientAuthentication) { accountId = beGlobalTranslator.GetClientInformation(); } else { accountId = beGlobalTranslator.GetUserInformation(); } var subscriptionInfo = beGlobalTranslator.GetLanguagePairs(accountId.ToString()); options.SubscriptionInfo = subscriptionInfo; return(new BeGlobalTranslationProvider(options)); }
public BeGlobalTranslationProvider(BeGlobalTranslationOptions options) { Options = options; _normalizeSourceTextHelper = new NormalizeSourceTextHelper(); }
public BeGlobalTranslationProvider(BeGlobalTranslationOptions options) { Options = options; }
public void LoadState(string translationProviderState) { Options = JsonConvert.DeserializeObject <BeGlobalTranslationOptions>(translationProviderState); }