Signed-off-by: lilium-saber <WR364999428@hotmail.com>
GDN
lilium-saber 1 year ago
parent eb7517e2a7
commit 20abb91db7

@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace testRjgc.transToNet
{
/*
internal class GrapeToJsonTrans : GrapeToJson
{
public List<string> GrapeRequestJson()
{
List<string> re = new List<string>();
return re;
}
public List<string> GrapeRequestJsonBaiDu()
{
List<string> re = new List<string>();
return re;
}
public List<string> GrapeRequestJsonLanguageChange()
{
List<string> re = new List<string>();
return re;
}
}
*/
}

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace testRjgc.transToNet
{
interface StrToJson
{
public abstract string RequestJsonPrivate(string input, string srcl, string dstl, string aid, string kkey);
public abstract string RequestJsonLanguageChange(string input, string srcl, string dstl);
public abstract string RequestJsonBaiDu(string input);
}
/*
interface GrapeToJson
{
public abstract List<string> GrapeRequestJson();
public abstract List<string> GrapeRequestJsonLanguageChange();
public abstract List<string> GrapeRequestJsonBaiDu();
}
*/
}

@ -14,20 +14,20 @@ using System.Text;
using System.Threading.Tasks;
using System.Web;
namespace WpfApp1.translationKey
namespace testRjgc.transToNet
{
internal class jsonNet
internal class jsonNet : StrToJson
{
static string https = "http://api.fanyi.baidu.com/api/trans/vip/translate?";
static string appid = "20230925001829663";//20230925001829663,20230923001827495
static Random rd = new Random();
static string salt = rd.Next(100000).ToString();
static string key = "f7ZHpw28izQ1VU_ixoY5";//f7ZHpw28izQ1VU_ixoY5,yjvMNY33Qc1TYSBjTQYQ
//static HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http://api.fanyi.baidu.com/api/trans/vip/translate?q=apple&from=en&to=zh&appid=20230925001829663&salt=1435660288&sign=c963bc2275c0fd1ed30da014c1ef1933");
/*
private static HttpClient HttpRe = new HttpClient()
{
@ -45,7 +45,7 @@ namespace WpfApp1.translationKey
Console.WriteLine($"{jsonResponse}\n");
}
*/
public static string EncryptString(string str)//百度MD5加密计算方式
{
MD5 md5 = MD5.Create();
@ -63,8 +63,33 @@ namespace WpfApp1.translationKey
// 返回加密的字符串
return sb.ToString();
}
public string RequestJsonLanguageChange(string input, string srcl, string dstl)
public string RequestJsonPrivate(string input, string srcl, string dstl, string aid, string kkey)//自定义idkey以及源语言和目标语言
{
string sign = EncryptString(aid + input + salt + kkey);
string temp = "q=" + HttpUtility.UrlEncode(input) + "&from=" + srcl + "&to=" + dstl + "&appid=" + aid + "&salt=" + salt + "&sign=" + sign;
Console.WriteLine(https + temp);
//Task t = GetAsync(HttpRe); t.Wait();
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(https + temp);
request.Method = "GET";
request.ContentType = "text/html;charset=UTF-8";
request.UserAgent = null;
request.Timeout = 6000;
var response = request.GetResponse();
var myResponseStream = response.GetResponseStream();
var myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
string retString = myStreamReader.ReadToEnd();
tempC2 temp1 = JsonConvert.DeserializeObject<tempC2>(retString);
Trans_result result = temp1.trans_result[0];
string s = result.dst;
return s;
}
public string RequestJsonLanguageChange(string input, string srcl, string dstl)//可以自定义源语言与目标语言
{
string sign = EncryptString(appid + input + salt + key);
@ -89,10 +114,10 @@ namespace WpfApp1.translationKey
return s;
}
public string RequestJsonBaiDu(string input)
public string RequestJsonBaiDu(string input)//默认
{
string sign = EncryptString(appid + input + salt + key);
string temp = "q=" + HttpUtility.UrlEncode(input) + "&from=jp&to=zh&appid=" + appid + "&salt=" + salt + "&sign=" + sign;
Console.WriteLine(https + temp);
//Task t = GetAsync(HttpRe); t.Wait();
@ -112,8 +137,8 @@ namespace WpfApp1.translationKey
Trans_result result = temp1.trans_result[0];
string s = result.dst;
return s;
}
}
}
public class Trans_result

@ -5,9 +5,9 @@ namespace WpfApp1.ScnToJson
internal class TranslationScnToJson
{
private string spath;//scn路径
private string dpath;//json路径
private string cmdHandle = "cd E:\\programingg\\vsprogam\\testRjgc\\VNT\\VNTextPatch";//cmd命令字符串
private string voice = ".\\VNTextPatch extractlocal E:\\programingg\\vsprogam\\testRjgc\\VNT\\p1 E:\\programingg\\vsprogam\\testRjgc\\VNT\\p2";//VNTextPatch extractlocal <folder containing original game files> <folder to receive .json files>
private string dpath;//json
private string cmdHandle = "cd " + Directory.GetCurrentDirectory() + "\\VNT\\VNTextPatch";
private string voice = ".\\VNTextPatch extractlocal " + Directory.GetCurrentDirectory() + "\\VNT\\p1 " + Directory.GetCurrentDirectory() + "\\VNT\\p2";
public void StartTrans()
{
@ -27,6 +27,25 @@ namespace WpfApp1.ScnToJson
}
public void StopTrans(string spa, string dps)
{
string tempVoice = ".\\VNTextPatch extractlocal " + spa + dps;
var p = new Process
{
StartInfo =
{
FileName = "PowerShell.exe",
Arguments = "/c " + cmdHandle + "\n" + tempVoice,
UseShellExecute = false,
CreateNoWindow = false,
}
};
p.Start();
p.WaitForExit();
p.Close();
}

@ -1,4 +1,5 @@
using System;
using Stripe;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@ -9,13 +10,20 @@ namespace WpfApp1.translationKey
{
class TranslationPrivateIn
{
private string pathTemp = "E:\\programingg\\vsprogam\\testRjgc\\translationResource";
private string txtPath = "E:\\programingg\\vsprogam\\testRjgc\\translationResource\\ListPrivate.txt";
private static string pathTemp = Directory.GetCurrentDirectory() + "\\translationResource";
private static string txtPath = Directory.GetCurrentDirectory() + "\\translationResource\\ListPrivate.txt";
public TranslationPrivateIn() { }
public void InputTranslationPrivate(string name, string id, string key)
{
pathTemp = pathTemp + "\\" + name + ".txt";
StreamWriter sw = new StreamWriter(pathTemp);
if(!Directory.Exists(pathTemp))
{
Directory.CreateDirectory(pathTemp);
}
string temppathTemp = pathTemp + "\\" + name + ".txt";
StreamWriter sw = new StreamWriter(temppathTemp);
StreamWriter sw2 = new StreamWriter(txtPath);
InputTranslationId(id,sw);

@ -9,9 +9,8 @@ namespace WpfApp1.translationKey
{
class translationPrivateOut : TranslationApiStr
{
private string name;
private string path = "E:\\programingg\\vsprogam\\testRjgc\\translationResource\\";
private string txtPath = "E:\\programingg\\vsprogam\\testRjgc\\translationResource\\ListPrivate.txt";
private static string path = Directory.GetCurrentDirectory() + "\\translationResource";
private static string txtPath = Directory.GetCurrentDirectory() + "\\translationResource\\ListPrivate.txt";
private String getTranslationPrivateApi(StreamReader sr)
{
@ -45,12 +44,18 @@ namespace WpfApp1.translationKey
public List<string> OutputTranslationS(string id)
{
this.name = id;
this.path = this.path + this.name + ".txt";
StreamReader sr = new StreamReader(this.path);
string temppath = path + "\\" + id + ".txt";
var temp = new List<string> { };
if (!Directory.Exists(temppath))
{
temp.Add("ERROR");
return temp;
}
StreamReader sr = new StreamReader(temppath);
temp.Add(this.getTranslationPrivateApi(sr));
temp.Add(this.getTranslationPrivateKey(sr));
@ -61,8 +66,15 @@ namespace WpfApp1.translationKey
public List<string> OutputTranslationNameList()
{
List<string> temp = new List<string> { };
string temptxtpath = txtPath;
if(!Directory.Exists(temptxtpath))
{
temp.Add("ERROR");
return temp;
}
StreamReader sr = new StreamReader(this.txtPath);
StreamReader sr = new StreamReader(temptxtpath);
string temp2 = sr.ReadLine();
if (temp2 == null)
{

Loading…
Cancel
Save