Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 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>();
 }
Exemplo n.º 5
0
        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);
        }