public DeepLMtTranslationProviderLanguageDirection(DeepLMtTranslationProvider deepLMtTranslationProvider, LanguagePair languageDirection)
 {
     _deepLMtTranslationProvider = deepLMtTranslationProvider;
     _languageDirection          = languageDirection;
     _options = deepLMtTranslationProvider.Options;
     _normalizeSourceTextHelper = new NormalizeSourceTextHelper();
 }
Ejemplo n.º 2
0
 public DeepLMtTranslationProviderLanguageDirection(DeepLMtTranslationProvider deepLMtTranslationProvider, LanguagePair languageDirection, DeepLTranslationProviderConnecter connecter)
 {
     _deepLMtTranslationProvider = deepLMtTranslationProvider;
     _languageDirection          = languageDirection;
     _options   = deepLMtTranslationProvider.Options;
     _connecter = connecter;
 }
Ejemplo n.º 3
0
        public DeepLMtDialog(DeepLTranslationOptions options, ITranslationProviderCredentialStore credentialStore)
        {
            InitializeComponent();
            mainTableLayout.CellPaint  += MainTableLayout_CellPaint;
            _credentialStore            = credentialStore;
            contentInformationLabl.Text = "DeepL API is a paid automated translation service. To use this service, set up a DeepL account and create a API Key.";

            //programatically merge columns
            foreach (Control control in contentLayoutPanel.Controls)
            {
                var index = mainTableLayout.GetRow(control);
                if (index != 1)
                {
                    mainTableLayout.SetColumnSpan(control, 2);
                }
            }


            //read logo from resource and add it to image box
            using (var imgStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Sdl.Community.DeepLMTProvider.Resources.DeepL.png"))
            {
                var image = new Bitmap(imgStream);
                logoPicture.Image  = image;
                logoPicture.Height = image.Height;
                logoPicture.Width  = image.Width;
            }

            Options = options;
            if (options != null)
            {
                apiKey.Text = options.ApiKey;
            }
        }
        public DeepLMtTranslationProvider(DeepLTranslationOptions options, DeepLTranslationProviderConnecter deepLTranslationProviderConnecter, LanguagePair[] languagePairs = null)
        {
            DeepLTranslationProviderConnecter = deepLTranslationProviderConnecter;
            Options = options;

            if (languagePairs != null)
            {
                GetSupportedTargetLanguages(languagePairs);
            }
        }
        public ITranslationProvider CreateTranslationProvider(Uri translationProviderUri, string translationProviderState, ITranslationProviderCredentialStore credentialStore)
        {
            var uri     = new Uri("deeplprovider:///");
            var options = new DeepLTranslationOptions();

            if (credentialStore.GetCredential(uri) != null)
            {
                var credentials = credentialStore.GetCredential(uri);
                options.ApiKey = credentials.Credential;
            }
            return(new DeepLMtTranslationProvider(options));
        }
        public ITranslationProvider[] Browse(IWin32Window owner, LanguagePair[] languagePairs, ITranslationProviderCredentialStore credentialStore)
        {
            var options = new DeepLTranslationOptions();

            //get credentials
            var getCredGt = GetCredentials(credentialStore, "deeplprovider:///");
            var dialog    = new DeepLMtDialog(options, credentialStore);

            if (dialog.ShowDialog(owner) == DialogResult.OK)
            {
                var provider = new DeepLMtTranslationProvider(options);
                var apiKey   = dialog.Options.ApiKey;
                SetDeeplCredentials(credentialStore, apiKey, true);
                return(new ITranslationProvider[] { provider });
            }
            return(null);
        }
        public ITranslationProvider CreateTranslationProvider(Uri translationProviderUri, string translationProviderState, ITranslationProviderCredentialStore credentialStore)
        {
            var originalUri = new Uri(Helpers.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)));
        }
Ejemplo n.º 8
0
        public ITranslationProvider[] Browse(IWin32Window owner, LanguagePair[] languagePairs, ITranslationProviderCredentialStore credentialStore)
        {
            var options = new DeepLTranslationOptions();

            //get credentials
            var credentials = GetCredentials(credentialStore, "deeplprovider:///");

            var dialog = new DeepLWindow(options, credentials, languagePairs);

            ElementHost.EnableModelessKeyboardInterop(dialog);
            dialog.ShowDialog();
            if (dialog.DialogResult.HasValue && dialog.DialogResult.Value)
            {
                var provider = new DeepLMtTranslationProvider(options)
                {
                    Options = dialog.Options
                };
                var apiKey = dialog.Options.ApiKey;
                SetDeeplCredentials(credentialStore, apiKey, true);
                return(new ITranslationProvider[] { provider });
            }
            return(null);
        }
        public ITranslationProvider CreateTranslationProvider(Uri translationProviderUri, string translationProviderState, ITranslationProviderCredentialStore credentialStore)
        {
            var originalUri = new Uri("deeplprovider:///");
            var options     = new DeepLTranslationOptions(translationProviderUri, translationProviderState);

            if (credentialStore.GetCredential(originalUri) != null)
            {
                var credentials = credentialStore.GetCredential(originalUri);
                options.ApiKey = credentials.Credential;
            }

            // create identifier on first use and save as a credential
            originalUri = new Uri("deeplproviderIdentifier:///");
            if (credentialStore.GetCredential(originalUri) == null)
            {
                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)));
        }
Ejemplo n.º 10
0
 public DeepLMtTranslationProviderLanguageDirection(DeepLMtTranslationProvider deepLMtTranslationProvider, LanguagePair languageDirection)
 {
     _deepLMtTranslationProvider = deepLMtTranslationProvider;
     _languageDirection          = languageDirection;
     _options = deepLMtTranslationProvider.Options;
 }
 public void LoadState(string translationProviderState)
 {
     Options = JsonConvert.DeserializeObject <DeepLTranslationOptions>(translationProviderState);
 }
 public DeepLMtTranslationProvider(DeepLTranslationOptions options)
 {
     Options = options;
 }