示例#1
0
        public override void Initialize(IInitializationContext context)
        {
            _appId     = context.GetOrCreateSetting("Baidu", "BaiduAppId", "");
            _appSecret = context.GetOrCreateSetting("Baidu", "BaiduAppSecret", "");
            _delay     = context.GetOrCreateSetting("Baidu", "DelaySeconds", 1.0f);
            if (string.IsNullOrEmpty(_appId))
            {
                throw new EndpointInitializationException("The BaiduTranslate endpoint requires an App Id which has not been provided.");
            }
            if (string.IsNullOrEmpty(_appSecret))
            {
                throw new EndpointInitializationException("The BaiduTranslate endpoint requires an App Secret which has not been provided.");
            }

            context.DisableCertificateChecksFor("api.fanyi.baidu.com");

            if (!SupportedLanguages.ContainsKey(FixLanguage(context.SourceLanguage)))
            {
                throw new EndpointInitializationException($"The source language '{context.SourceLanguage}' is not supported.");
            }
            if (!SupportedLanguages.ContainsKey(FixLanguage(context.DestinationLanguage)))
            {
                throw new EndpointInitializationException($"The destination language '{context.DestinationLanguage}' is not supported.");
            }
        }
        public override void Initialize(IInitializationContext context)
        {
            var backendOverride = context.GetOrCreateSetting <string>("GoogleV2", "ServiceUrl");

            if (!backendOverride.IsNullOrWhiteSpace())
            {
                _selectedUserBackend = backendOverride;

                _httpsServicePointTranslateTemplateUrl = _selectedUserBackend + HttpsServicePointTranslateTemplateUrl;

                XuaLogger.AutoTranslator.Info("The default backend for google translate was overwritten.");
            }
            else
            {
                _selectedUserBackend = DefaultUserBackend;

                _httpsServicePointTranslateTemplateUrl = _selectedUserBackend + HttpsServicePointTranslateTemplateUrl;
            }

            _translateRpcId        = context.GetOrCreateSetting("GoogleV2", "RPCID", "MkEWBc");
            _version               = context.GetOrCreateSetting("GoogleV2", "VERSION", "boq_translate-webserver_20210323.10_p0");
            _useSimplestSuggestion = context.GetOrCreateSetting("GoogleV2", "UseSimplest", false);


            context.DisableCertificateChecksFor(new Uri(_selectedUserBackend).Host, new Uri(_selectedUserBackend).Host);

            if (!SupportedLanguages.Contains(FixLanguage(context.SourceLanguage)))
            {
                throw new EndpointInitializationException($"The source language '{context.SourceLanguage}' is not supported.");
            }
            if (!SupportedLanguages.Contains(FixLanguage(context.DestinationLanguage)))
            {
                throw new EndpointInitializationException($"The destination language '{context.DestinationLanguage}' is not supported.");
            }
        }
        public override void Initialize(IInitializationContext context)
        {
            context.DisableCertificateChecksFor("papago.naver.com");

            if (!SupportedLanguages.Contains(FixLanguage(context.DestinationLanguage)))
            {
                throw new EndpointInitializationException($"The language '{context.DestinationLanguage}' is not supported by Papago Translate.");
            }
        }
示例#4
0
        public override void Initialize(IInitializationContext context)
        {
            // Configure service points / service point manager
            context.DisableCertificateChecksFor("www.bing.com");

            if (!SupportedLanguages.Contains(context.SourceLanguage))
            {
                throw new Exception($"The source language '{context.SourceLanguage}' is not supported.");
            }
            if (!SupportedLanguages.Contains(context.DestinationLanguage))
            {
                throw new Exception($"The destination language '{context.DestinationLanguage}' is not supported.");
            }
        }
        public override void Initialize(IInitializationContext context)
        {
            _endpoint = context.GetOrCreateSetting("Custom", "Url", "");
            if (string.IsNullOrEmpty(_endpoint))
            {
                throw new EndpointInitializationException("The custom endpoint requires a url which has not been provided.");
            }

            var uri = new Uri(_endpoint);

            context.DisableCertificateChecksFor(uri.Host);

            _friendlyName += " (" + uri.Host + ")";
        }
示例#6
0
        public override void Initialize(IInitializationContext context)
        {
            _appId     = context.GetOrCreateSetting("Baidu", "BaiduAppId", "");
            _appSecret = context.GetOrCreateSetting("Baidu", "BaiduAppSecret", "");
            if (string.IsNullOrEmpty(_appId))
            {
                throw new ArgumentException("The BaiduTranslate endpoint requires an App Id which has not been provided.");
            }
            if (string.IsNullOrEmpty(_appSecret))
            {
                throw new ArgumentException("The BaiduTranslate endpoint requires an App Secret which has not been provided.");
            }

            context.DisableCertificateChecksFor("api.fanyi.baidu.com");

            // frankly, I have no idea what languages this does, or does not support...
        }
        public override void Initialize(IInitializationContext context)
        {
            context.DisableCertificateChecksFor("translate.google.com", "translate.googleapis.com");

            if (context.DestinationLanguage == "romaji")
            {
                _translationsPerRequest = 1;
            }

            if (!SupportedLanguages.Contains(context.SourceLanguage))
            {
                throw new EndpointInitializationException($"The source language '{context.SourceLanguage}' is not supported.");
            }
            if (!SupportedLanguages.Contains(context.DestinationLanguage))
            {
                throw new EndpointInitializationException($"The destination language '{context.DestinationLanguage}' is not supported.");
            }
        }
示例#8
0
        public override void Initialize(IInitializationContext context)
        {
            _key = context.GetOrCreateSetting("Yandex", "YandexAPIKey", "");
            context.DisableCertificateChecksFor("translate.yandex.net");

            // if the plugin cannot be enabled, simply throw so the user cannot select the plugin
            if (string.IsNullOrEmpty(_key))
            {
                throw new Exception("The YandexTranslate endpoint requires an API key which has not been provided.");
            }
            if (!SupportedLanguages.Contains(context.SourceLanguage))
            {
                throw new Exception($"The source language '{context.SourceLanguage}' is not supported.");
            }
            if (!SupportedLanguages.Contains(context.DestinationLanguage))
            {
                throw new Exception($"The destination language '{context.DestinationLanguage}' is not supported.");
            }
        }
        public override void Initialize(IInitializationContext context)
        {
            if (context.DestinationLanguage == "romaji")
            {
                _translationsPerRequest = 1;
            }

            _selectedApiBackend  = DefaultApiBackend;
            _selectedUserBackend = DefaultUserBackend;

            var backendOverride = context.GetOrCreateSetting <string>("Google", "ServiceUrl");

            if (!backendOverride.IsNullOrWhiteSpace())
            {
                _selectedApiBackend  = backendOverride;
                _selectedUserBackend = backendOverride;

                _httpsServicePointTranslateTemplateUrl = _selectedApiBackend + HttpsServicePointTranslateTemplateUrl;
                _httpsServicePointRomanizeTemplateUrl  = _selectedApiBackend + HttpsServicePointRomanizeTemplateUrl;

                XuaLogger.AutoTranslator.Info("The default backend for google translate was overwritten.");
            }
            else
            {
                _selectedApiBackend  = DefaultApiBackend;
                _selectedUserBackend = DefaultUserBackend;

                _httpsServicePointTranslateTemplateUrl = _selectedApiBackend + HttpsServicePointTranslateTemplateUrl;
                _httpsServicePointRomanizeTemplateUrl  = _selectedApiBackend + HttpsServicePointRomanizeTemplateUrl;
            }

            context.DisableCertificateChecksFor(new Uri(_selectedApiBackend).Host, new Uri(_selectedUserBackend).Host);

            if (!SupportedLanguages.Contains(FixLanguage(context.SourceLanguage)))
            {
                throw new EndpointInitializationException($"The source language '{context.SourceLanguage}' is not supported.");
            }
            if (!SupportedLanguages.Contains(FixLanguage(context.DestinationLanguage)))
            {
                throw new EndpointInitializationException($"The destination language '{context.DestinationLanguage}' is not supported.");
            }
        }
        public override void Initialize(IInitializationContext context)
        {
            _key = context.GetOrCreateSetting("BingLegitimate", "OcpApimSubscriptionKey", "");
            if (string.IsNullOrEmpty(_key))
            {
                throw new EndpointInitializationException("The BingTranslateLegitimate endpoint requires an API key which has not been provided.");
            }

            // Configure service points / service point manager
            context.DisableCertificateChecksFor("api.cognitive.microsofttranslator.com");

            if (!SupportedLanguages.Contains(context.SourceLanguage))
            {
                throw new EndpointInitializationException($"The source language '{context.SourceLanguage}' is not supported.");
            }
            if (!SupportedLanguages.Contains(context.DestinationLanguage))
            {
                throw new EndpointInitializationException($"The destination language '{context.DestinationLanguage}' is not supported.");
            }
        }
        public override void Initialize(IInitializationContext context)
        {
            _key = context.GetOrCreateSetting("GoogleLegitimate", "GoogleAPIKey", "");
            if (string.IsNullOrEmpty(_key))
            {
                throw new Exception("The GoogleTranslateLegitimate endpoint requires an API key which has not been provided.");
            }

            // Configure service points / service point manager
            context.DisableCertificateChecksFor("translation.googleapis.com");

            if (!SupportedLanguages.Contains(context.SourceLanguage))
            {
                throw new Exception($"The source language '{context.SourceLanguage}' is not supported.");
            }
            if (!SupportedLanguages.Contains(context.DestinationLanguage))
            {
                throw new Exception($"The destination language '{context.DestinationLanguage}' is not supported.");
            }
        }
示例#12
0
        public override void Initialize(IInitializationContext context)
        {
            context.DisableCertificateChecksFor("papago.naver.com");

            var fixedSourceLanguage      = FixLanguage(context.SourceLanguage);
            var fixedDestinationLanguage = FixLanguage(context.DestinationLanguage);

            _isSMT = SMTLanguages.Contains(fixedSourceLanguage) || SMTLanguages.Contains(fixedDestinationLanguage);

            if (!SupportedLanguages.Contains(fixedDestinationLanguage))
            {
                throw new EndpointInitializationException($"The language '{context.DestinationLanguage}' is not supported by Papago Translate.");
            }

            if (_isSMT)
            {
                // SMT can only be translated into English
                if (fixedSourceLanguage != "en" && fixedDestinationLanguage != "en")
                {
                    throw new EndpointInitializationException($"Translation from '{context.SourceLanguage}' to '{context.DestinationLanguage}' is not supported by Papago Translate.");
                }
            }
        }