private void TransTestBtn_Click(object sender, RoutedEventArgs e)
        {
            ITranslator Trans = new TencentOldTranslator();

            Trans.TranslatorInit(Common.appSettings.TXOSecretId, Common.appSettings.TXOSecretKey);
            string res = Trans.Translate(TestSrcText.Text, TestDstLang.Text, TestSrcLang.Text);

            if (res != null)
            {
                HandyControl.Controls.MessageBox.Show(res, Application.Current.Resources["MessageBox_Result"].ToString());
            }
            else
            {
                HandyControl.Controls.Growl.Error($"腾讯私人{Application.Current.Resources["APITest_Error_Hint"]}\n{Trans.GetLastError()}");
            }
        }
        private void AuthTestBtn_Click(object sender, RoutedEventArgs e)
        {
            Common.appSettings.TXOSecretId  = TransAppIDBox.Text;
            Common.appSettings.TXOSecretKey = TransSecretKeyBox.Text;
            ITranslator Trans = new TencentOldTranslator();

            Trans.TranslatorInit(TransAppIDBox.Text, TransSecretKeyBox.Text);
            if (Trans.Translate("apple", "zh", "en") != null)
            {
                HandyControl.Controls.Growl.Success($"腾讯私人{Application.Current.Resources["APITest_Success_Hint"]}");
            }
            else
            {
                HandyControl.Controls.Growl.Error($"腾讯私人{Application.Current.Resources["APITest_Error_Hint"]}\n{Trans.GetLastError()}");
            }
        }
Esempio n. 3
0
        private void TransTestBtn_Click(object sender, RoutedEventArgs e)
        {
            ITranslator Trans = new TencentOldTranslator();

            Trans.TranslatorInit(Common.appSettings.TXOSecretId, Common.appSettings.TXOSecretKey);
            string res = Trans.Translate(TestSrcText.Text, TestDstLang.Text, TestSrcLang.Text);

            if (res != null)
            {
                HandyControl.Controls.MessageBox.Show(res, "翻译结果");
            }
            else
            {
                HandyControl.Controls.Growl.Error("腾讯私人翻译API工作异常\n" + Trans.GetLastError());
            }
        }
Esempio n. 4
0
        private void AuthTestBtn_Click(object sender, RoutedEventArgs e)
        {
            Common.appSettings.TXOSecretId  = TransAppIDBox.Text;
            Common.appSettings.TXOSecretKey = TransSecretKeyBox.Text;
            ITranslator Trans = new TencentOldTranslator();

            Trans.TranslatorInit(TransAppIDBox.Text, TransSecretKeyBox.Text);
            if (Trans.Translate("apple", "zh", "en") != null)
            {
                HandyControl.Controls.Growl.Success("腾讯私人API工作正常!");
            }
            else
            {
                HandyControl.Controls.Growl.Error("腾讯私人API工作异常\n" + Trans.GetLastError());
            }
        }
 /// <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 "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 "YoudaoTranslator":
                YoudaoTranslator yd = new YoudaoTranslator();
                yd.TranslatorInit();
                return(yd);

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

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

            default:
                return(null);
            }
        }
Esempio n. 7
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 "XiaoniuTranslator":
                XiaoniuTranslator xt = new XiaoniuTranslator();
                xt.TranslatorInit(Common.appSettings.xiaoniuApiKey);
                return(xt);

            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 "ArtificialTranslator":
                ArtificialTranslator at = new ArtificialTranslator();
                at.TranslatorInit(Common.appSettings.ArtificialPatchPath);
                return(at);

            default:
                return(null);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// 根据翻译器名称自动返回翻译器类实例(包括初始化)
        /// </summary>
        /// <param name="translator"></param>
        /// <returns></returns>
        public static ITranslator TranslatorAuto(string translator)
        {
            try
            {
                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 "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 "ArtificialTranslator":
                    ArtificialTranslator ltr = new ArtificialTranslator();
                    SQLHelper            sql = new SQLHelper();
                    var _path = sql.ExecuteReader_OneLine(
                        $"SELECT patchPath FROM game_library WHERE gameid = '{Common.GameID}';", 1);
                    var path = (_path == null || _path.Count < 1) ? Common.appSettings.LocalTransPatch : _path[0];
                    ltr.TranslatorInit(path, Common.appSettings.LocalTransMode);
                    Common.ATPermission = ltr.getPatchPermission();
                    return(ltr);

                default:
                    return(null);
                }
            }
            catch (Exception e)
            {
                System.Windows.MessageBox.Show(String.Format("翻译器{0}初始化失败:{1}", translator, e.ToString()));
                throw e;
            }
        }