示例#1
0
        /// <summary>
        /// 根据翻译器名称自动返回翻译器类实例(包括初始化)
        /// </summary>
        /// <param name="translator"></param>
        /// <returns></returns>
        public static ITranslator TranslatorAuto(string translator)
        {
            switch (translator)
            {
            case "BaiduTranslator":
                BaiduTranslator bd = new BaiduTranslator();
                bd.TranslatorInit(Common.appSettings.BDappID, Common.appSettings.BDsecretKey);
                return(bd);

            case "TencentFYJTranslator":
                TencentFYJTranslator tx = new TencentFYJTranslator();
                tx.TranslatorInit(Common.appSettings.TXappID, Common.appSettings.TXappKey);
                return(tx);

            case "TencentOldTranslator":
                TencentOldTranslator txo = new TencentOldTranslator();
                txo.TranslatorInit(Common.appSettings.TXOSecretId, Common.appSettings.TXOSecretKey);
                return(txo);

            case "CaiyunTranslator":
                CaiyunTranslator cy = new CaiyunTranslator();
                cy.TranslatorInit(Common.appSettings.CaiyunToken);
                return(cy);

            case "YoudaoTranslator":
                YoudaoTranslator yd = new YoudaoTranslator();
                yd.TranslatorInit();
                return(yd);

            case "AlapiTranslator":
                AlapiTranslator al = new AlapiTranslator();
                al.TranslatorInit();
                return(al);

            case "GoogleCNTranslator":
                GoogleCNTranslator gct = new GoogleCNTranslator();
                gct.TranslatorInit();
                return(gct);

            case "JBeijingTranslator":
                JBeijingTranslator bj = new JBeijingTranslator();
                bj.TranslatorInit(Common.appSettings.JBJCTDllPath);
                return(bj);

            case "KingsoftFastAITTranslator":
                KingsoftFastAITTranslator kfat = new KingsoftFastAITTranslator();
                kfat.TranslatorInit(Common.appSettings.KingsoftFastAITPath);
                return(kfat);

            case "Dreye":
                DreyeTranslator drt = new DreyeTranslator();
                drt.TranslatorInit(Common.appSettings.DreyePath);
                return(drt);

            default:
                return(null);
            }
        }
        /// <summary>
        /// 根据翻译器名称自动返回翻译器类实例(包括初始化)
        /// </summary>
        /// <param name="translator"></param>
        /// <returns></returns>
        public static ITranslator TranslatorAuto(string translator)
        {
            switch (translator)
            {
            case "BaiduTranslator":
                BaiduTranslator bd = new BaiduTranslator();
                bd.TranslatorInit(Common.appSettings.BDappID, Common.appSettings.BDsecretKey);
                return(bd);

            case "TencentFYJTranslator":
                TencentFYJTranslator tx = new TencentFYJTranslator();
                tx.TranslatorInit(Common.appSettings.TXappID, Common.appSettings.TXappKey);
                return(tx);

            case "TencentOldTranslator":
                TencentOldTranslator txo = new TencentOldTranslator();
                txo.TranslatorInit(Common.appSettings.TXOSecretId, Common.appSettings.TXOSecretKey);
                return(txo);

            case "CaiyunTranslator":
                CaiyunTranslator cy = new CaiyunTranslator();
                cy.TranslatorInit(Common.appSettings.CaiyunToken);
                return(cy);

            case "XiaoniuTranslator":
                XiaoniuTranslator xt = new XiaoniuTranslator();
                xt.TranslatorInit(Common.appSettings.xiaoniuApiKey);
                return(xt);

            case "IBMTranslator":
                IBMTranslator it = new IBMTranslator();
                it.TranslatorInit(Common.appSettings.IBMApiKey, Common.appSettings.IBMURL);
                return(it);

            case "YandexTranslator":
                YandexTranslator yt = new YandexTranslator();
                yt.TranslatorInit(Common.appSettings.YandexApiKey);
                return(yt);

            case "YoudaoTranslator":
                YoudaoTranslator yd = new YoudaoTranslator();
                yd.TranslatorInit();
                return(yd);

            case "AlapiTranslator":
                AlapiTranslator al = new AlapiTranslator();
                al.TranslatorInit();
                return(al);

            case "GoogleCNTranslator":
                GoogleCNTranslator gct = new GoogleCNTranslator();
                gct.TranslatorInit();
                return(gct);

            case "JBeijingTranslator":
                JBeijingTranslator bj = new JBeijingTranslator();
                bj.TranslatorInit(Common.appSettings.JBJCTDllPath);
                return(bj);

            case "KingsoftFastAITTranslator":
                KingsoftFastAITTranslator kfat = new KingsoftFastAITTranslator();
                kfat.TranslatorInit(Common.appSettings.KingsoftFastAITPath);
                return(kfat);

            case "Dreye":
                DreyeTranslator drt = new DreyeTranslator();
                drt.TranslatorInit(Common.appSettings.DreyePath);
                return(drt);

            case "DeepLTranslator":
                DeepLTranslator deepl = new DeepLTranslator();
                deepl.TranslatorInit(Common.appSettings.DeepLsecretKey, Common.appSettings.DeepLsecretKey);
                return(deepl);

            case "ArtificialTranslator":
                ArtificialTranslator at = new ArtificialTranslator();
                at.TranslatorInit(Common.appSettings.ArtificialPatchPath);
                return(at);

            default:
                return(null);
            }
        }