コード例 #1
0
        /// <summary>
        /// Determines the language direction of the delimited list file by
        /// reading the first line. Based upon this information it is determined
        /// whether the plug-in supports the language pair that was selected by
        /// the user.
        /// </summary>
        #region "SupportsLanguageDirection"
        public bool SupportsLanguageDirection(LanguagePair languageDirection)
        {
            if (Options.SelectedProvider == MtTranslationOptions.ProviderType.MicrosoftTranslator)
            {
                if (mstConnect == null) //construct ApiConnecter if necessary
                {
                    mstConnect = new MstTranslateConnect.ApiConnecter(Options);
                }
                else
                {
                    mstConnect.resetCrd(Options.ClientID, Options.ClientSecret); //reset in case changed since last time the class was constructed
                }

                return(mstConnect.isSupportedLangPair(languageDirection.SourceCulture.Name, languageDirection.TargetCulture.Name));
            }
            else if (Options.SelectedProvider == MtTranslationOptions.ProviderType.GoogleTranslate)
            {
                if (gtConnect == null) //instantiate GtApiConnecter if necessary
                {
                    gtConnect = new MtTranslationProviderGTApiConnecter(Options.apiKey);
                }
                else
                {
                    gtConnect.ApiKey = Options.apiKey; //reset in case it has been changed since last time GtApiConnecter was instantiated
                }
                return(gtConnect.isSupportedLangPair(languageDirection.SourceCulture, languageDirection.TargetCulture));
            }

            //not likely to get here but...
            return(true);
        }
コード例 #2
0
        private string LookupGT(string sourcetext, MtTranslationOptions options, string format)
        {
            //instantiate GtApiConnecter if necessary
            if (gtConnect == null)
            {
                // need to get and insert key
                gtConnect = new MtTranslationProviderGTApiConnecter(options.apiKey); //needs key
            }
            else
            {
                gtConnect.ApiKey = options.apiKey; //reset key in case it has been changed in dialog since GtApiConnecter was instantiated
            }

            string translatedText = gtConnect.Translate(_languageDirection, sourcetext, format);

            return(translatedText);
        }
        private string LookupGT(string sourcetext, MtTranslationOptions options, string format)
        {
            //instantiate GtApiConnecter if necessary
            if (gtConnect == null)
            {
                // need to get and insert key
                gtConnect = new MtTranslationProviderGTApiConnecter(options.apiKey); //needs key
            }
            else
            {
                gtConnect.ApiKey = options.apiKey; //reset key in case it has been changed in dialog since GtApiConnecter was instantiated
            }

            string translatedText = gtConnect.Translate(_languageDirection, sourcetext, format);

            return translatedText;
        }
コード例 #4
0
        public bool SupportsLanguageDirection(LanguagePair languageDirection)
        {
            if (Options.SelectedProvider == MtTranslationOptions.ProviderType.MicrosoftTranslator)
            {
                if (mstConnect == null) //construct ApiConnecter if necessary
                {
                    mstConnect = new MstTranslateConnect.ApiConnecter(Options);
                }
                else
                {
                    mstConnect.resetCrd(Options.ClientID, Options.ClientSecret); //reset in case changed since last time the class was constructed
                }

                return mstConnect.isSupportedLangPair(languageDirection.SourceCulture.Name, languageDirection.TargetCulture.Name);
            }
            else if (Options.SelectedProvider == MtTranslationOptions.ProviderType.GoogleTranslate)
            {
                if (gtConnect == null) //instantiate GtApiConnecter if necessary
                {
                    gtConnect = new MtTranslationProviderGTApiConnecter(Options.apiKey);
                }
                else
                {
                    gtConnect.ApiKey = Options.apiKey; //reset in case it has been changed since last time GtApiConnecter was instantiated
                }
                return gtConnect.isSupportedLangPair(languageDirection.SourceCulture, languageDirection.TargetCulture);
            }

            //not likely to get here but...
            return true;
        }