public WebTranslator(ILog logger) { _Logger = logger; if (!Helper.LoadStaticFromJson(typeof(GlobalTranslationSettings), _TransaltionSettingsPath)) { Helper.SaveStaticToJson(typeof(GlobalTranslationSettings), _TransaltionSettingsPath); Helper.LoadStaticFromJson(typeof(GlobalTranslationSettings), _TransaltionSettingsPath); } transaltionCache = new List <KeyValuePair <TranslationRequest, string> >(GlobalTranslationSettings.TranslationCacheSize); _MultillectTranslator = new MultillectTranslator(_Logger); _GoogleTranslator = new GoogleTranslator(_Logger); _YandexTranslator = new YandexTranslator(_Logger); _DeepLTranslator = new DeepLTranslator(_Logger); _PapagoTranslator = new PapagoTranslator(_Logger); _BaiduTranslator = new BaiduTranslater(_Logger); _LanguageDetector = new LanguageDetector(GlobalTranslationSettings.MaxSameLanguagePercent, GlobalTranslationSettings.NTextCatLanguageModelsPath, _Logger); }
private async Task SetTranslator() { if (Downloader == null) { Debug.Assert(false); return; } if (Config.TranslatorType == TranslatorType.GSheet) { var translator = new GSheetsTranslator(); await translator.InitializeService().ConfigureAwait(false); Translator = translator; } else if (Config.TranslatorType == TranslatorType.Google) { var translator = new GoogleTranslator(); Translator = translator; } else if (Config.TranslatorType == TranslatorType.Papago) { var translator = new PapagoTranslator(); Translator = translator; } else if (Config.TranslatorType == TranslatorType.EZTrans) { var translator = new EZTranslator(); Translator = translator; } else if (Config.TranslatorType == TranslatorType.Bing) { var translator = new BingTranslator(); Translator = translator; } else { Translator = null; } Downloader.SetTranslator(Translator); }