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,9 +14,9 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web; 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 https = "http://api.fanyi.baidu.com/api/trans/vip/translate?";
@ -64,7 +64,32 @@ namespace WpfApp1.translationKey
return sb.ToString(); 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); string sign = EncryptString(appid + input + salt + key);
@ -89,7 +114,7 @@ namespace WpfApp1.translationKey
return s; return s;
} }
public string RequestJsonBaiDu(string input) public string RequestJsonBaiDu(string input)//默认
{ {
string sign = EncryptString(appid + input + salt + key); string sign = EncryptString(appid + input + salt + key);

@ -5,9 +5,9 @@ namespace WpfApp1.ScnToJson
internal class TranslationScnToJson internal class TranslationScnToJson
{ {
private string spath;//scn路径 private string spath;//scn路径
private string dpath;//json路径 private string dpath;//json
private string cmdHandle = "cd E:\\programingg\\vsprogam\\testRjgc\\VNT\\VNTextPatch";//cmd命令字符串 private string cmdHandle = "cd " + Directory.GetCurrentDirectory() + "\\VNT\\VNTextPatch";
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 voice = ".\\VNTextPatch extractlocal " + Directory.GetCurrentDirectory() + "\\VNT\\p1 " + Directory.GetCurrentDirectory() + "\\VNT\\p2";
public void StartTrans() 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.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@ -9,13 +10,20 @@ namespace WpfApp1.translationKey
{ {
class TranslationPrivateIn class TranslationPrivateIn
{ {
private string pathTemp = "E:\\programingg\\vsprogam\\testRjgc\\translationResource"; private static string pathTemp = Directory.GetCurrentDirectory() + "\\translationResource";
private string txtPath = "E:\\programingg\\vsprogam\\testRjgc\\translationResource\\ListPrivate.txt"; private static string txtPath = Directory.GetCurrentDirectory() + "\\translationResource\\ListPrivate.txt";
public TranslationPrivateIn() { }
public void InputTranslationPrivate(string name, string id, string key) public void InputTranslationPrivate(string name, string id, string key)
{ {
pathTemp = pathTemp + "\\" + name + ".txt"; if(!Directory.Exists(pathTemp))
StreamWriter sw = new StreamWriter(pathTemp); {
Directory.CreateDirectory(pathTemp);
}
string temppathTemp = pathTemp + "\\" + name + ".txt";
StreamWriter sw = new StreamWriter(temppathTemp);
StreamWriter sw2 = new StreamWriter(txtPath); StreamWriter sw2 = new StreamWriter(txtPath);
InputTranslationId(id,sw); InputTranslationId(id,sw);

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

Loading…
Cancel
Save