Beispiel #1
0
        public DeepLSamplerTranslationProvider(DeepLSamplerTranslationOptions options)
        {
            Options = options;

            OpenConnection();

            //DeepLSamplerProviderConfDialog.textBox3.Text = Path.GetTempPath();

            if (log == null)
            {
                // log gets saved in "C:\Users\garchik2\AppData\Local\Temp" by default
                log = new Logger(Path.GetTempPath() + log_filename);
                log.WriteFileHeader();
                log.WriteLine("DeepLSamplerTranslationProvider instantiated", true);
                //log.Close();
            }
        }
        //public static DeepLSpider deepL = null;

        public DeepLSamplerProviderConfDialog(DeepLSamplerTranslationOptions options)
        {
            Options = options;
            InitializeComponent();
            UpdateDialog(); // initialize form here!

            // attempt to open connection to DeepL if not yet established --> connection should already be opened in DeepLSamplerTranslationProvider
            DeepLSamplerTranslationProvider.OpenConnection();

            if (DeepLSamplerTranslationProvider.log != null)
            {
                DeepLSamplerTranslationProvider.log.WriteLine("DeepLSamplerProviderConfDialog instantiated", true);
            }

            // this code could go into UpdateDialog() or be deleted?
            string source_lang = "EN";
            string target_lang = "IT";

            DeepLSamplerTranslationProvider.deepL.setLanguages(source_lang, target_lang);

            textBox1.Text = "i think i hit the jackpot today";
            textBox2.Text = DeepLSamplerTranslationProvider.deepL.translateText("i think i hit the jackpot today");
        }
Beispiel #3
0
        public DeepLSamplerTranslationProviderLanguageDirection(DeepLSamplerTranslationProvider provider, LanguagePair languages)
        {
            // this gets instantiated hundreds of times
            // DeepLSamplerTranslationProvider.log.WriteLine("DeepLSamplerTranslationProviderLanguageDirection instantiated", true);

            _provider          = provider;
            _languageDirection = languages;
            _options           = _provider.Options;
            _visitor           = new DeepLSamplerTranslationProviderElementVisitor(_options);
            //_listOfTranslations = new Dictionary<string, string>();

            // examples
            //_languageDirection.SourceCultureName = "en-US";
            //_languageDirection.TargetCultureName = "de-DE";
            string _source_lang = _languageDirection.SourceCultureName.Substring(0, 2).ToUpper();
            string _target_lang = _languageDirection.TargetCultureName.Substring(0, 2).ToUpper();

            // TRY / CATCH !!!!
            // without the if statement, this was repeated many times!
            if (DeepLSamplerTranslationProvider.deepL.SrcLang != _source_lang || DeepLSamplerTranslationProvider.deepL.TgtLang != _target_lang)
            {
                DeepLSamplerTranslationProvider.deepL.setLanguages(_source_lang, _target_lang);
            }
        }
Beispiel #4
0
 public DeepLSamplerTranslationProviderElementVisitor(DeepLSamplerTranslationOptions options)
 {
     _options = options;
 }