private string LookupGt(string sourcetext, IMtTranslationOptions options, string format) { if (options.SelectedGoogleVersion == Enums.GoogleApiVersion.V2) { //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 } var translatedText = _gtConnect.Translate(_languageDirection, sourcetext, format); return(translatedText); } _googleV3Connecter = new GoogleV3Connecter(options); var v3TranslatedText = _googleV3Connecter.TranslateText(_languageDirection.SourceCulture, _languageDirection.TargetCulture, sourcetext); return(v3TranslatedText); }
/// <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> public bool SupportsLanguageDirection(LanguagePair languageDirection) { if (Options.SelectedProvider == MtTranslationOptions.ProviderType.MicrosoftTranslator) { if (_mstConnect == null) //construct ApiConnecter if necessary { _mstConnect = new ApiConnecter(Options.ClientId, Options.Region); } else { _mstConnect.ResetCrd(Options.ClientId, Options.Region); //reset in case changed since last time the class was constructed } return(_mstConnect.IsSupportedLangPair(languageDirection.SourceCulture.Name, languageDirection.TargetCulture.Name)); } if (Options.SelectedGoogleVersion == Enums.GoogleApiVersion.V2) { 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)); } _googleV3Connecter = new GoogleV3Connecter(Options); return(_googleV3Connecter.IsSupportedLanguage(languageDirection.SourceCulture, languageDirection.TargetCulture)); }