Exemple #1
0
        public ITranslationProvider CreateTranslationProvider(Uri translationProviderUri, string translationProviderState, ITranslationProviderCredentialStore credentialStore)
        {
            var uri     = new Uri("deeplprovider:///");
            var options = new MyMtTranslationOptions();

            if (credentialStore.GetCredential(uri) != null)
            {
                var credentials = credentialStore.GetCredential(uri);
                options.ApiKey = credentials.Credential;
            }
            return(new MyMtTranslationProvider(options));
        }
Exemple #2
0
        public ITranslationProvider[] Browse(IWin32Window owner, LanguagePair[] languagePairs, ITranslationProviderCredentialStore credentialStore)
        {
            var options = new MyMtTranslationOptions();

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

            if (dialog.ShowDialog(owner) == DialogResult.OK)
            {
                var provider = new MyMtTranslationProvider(options);
                var apiKey   = dialog.Options.ApiKey;
                SetDeeplCredentials(credentialStore, apiKey, true);
                return(new ITranslationProvider[] { provider });
            }
            return(null);
        }
Exemple #3
0
        public MyMtDialog(MyMtTranslationOptions 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.deepLResized.png"))
            {
                if (imgStream != null)
                {
                    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 MyMtTranslationProvider(MyMtTranslationOptions options)
 {
     Options = options;
 }
 public MyMtTranslationProviderLanguageDirection(MyMtTranslationProvider deepLMtTranslationProvider, LanguagePair languageDirection)
 {
     _deepLMtTranslationProvider = deepLMtTranslationProvider;
     _languageDirection          = languageDirection;
     _options = deepLMtTranslationProvider.Options;
 }