hujingshuang / mtrans Goto Github PK
View Code? Open in Web Editor NEWMulti-source Translation
Multi-source Translation
#title for chinese: jdk 1.8 下 GoogleTranslator 类 setFormData() 的 Map 选择问题
The formData in the setFormData() method is a HashMap, the HashMap does not support key duplication, and the google translation form submission requires a dt field, which has multiple values.
Solution: You can change the HashMap to IdentityHashMap in the AbstractHttpAttribute parent class, and then have the same key, formData.put(new String("key"), "value");
ps:
In order to support internationalization, first use English to play it again. Recently, the google translation API is not used.
setFormData() 方法中 formData 是一个 HashMap, HashMap 不支持 key 重复, 而 google 翻译表单提交时 需要 dt 字段, 该字段有多个值。
解决方案: 可以在 AbstractHttpAttribute 父类中将 HashMap 改为 IdentityHashMap, 然后有相同 key 时, formData.put(new String("key"), "value");
ps:
为了支持国际化, 先用英文打一遍, 用这个频繁调用翻译接口还是会超时,腾讯、google 他们应该有反爬虫机制。
搜狗的Translator失效,看目前的应该请求url变化了和增加一个叫s的参数,但是看他的js源码没有闹清楚这个s方法在哪里,在他的app.js里面
var F = s("" + L + O + B + "41ee21a5ab5a13f72687a270816d1bfd"), W = { "from": L, "to": O, "client": "pc", "fr": "browser_pc", "text": B, "pid": "sogou-dict-vr", "useDetect": "on", "useDetectResult": "auto" === L ? "on": "off", "needQc": _.need, "uuid": M, "oxford": "on", "isReturnSugg": "on", "s": F }
我看使用指南中,只导入maven的http相关的包 没有关于翻译的这块包, 那就得把源代码拷贝下来吗?
正在做一个chrome扩展,想提供发音功能
java.lang.IllegalStateException: Connection pool shut down
at org.apache.http.util.Asserts.check(Asserts.java:34)
at org.apache.http.pool.AbstractConnPool.lease(AbstractConnPool.java:191)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.requestConnection(PoolingHttpClientConnectionManager.java:267)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:176)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108)
at com.swjtu.trans.impl.GoogleTranslator.query(GoogleTranslator.java:73)
at com.swjtu.trans.AbstractTranslator.run(AbstractTranslator.java:42)
at com.swjtu.querier.Querier.execute(Querier.java:25)
我试了一下 类似于这种的文本不能翻译。 价格(%1$s) 谷歌抓包算出的tk为273850.173049 用js代码算出来的tk为54310.450642 楼主有没有什么解决办法
The BaiduTranslator worked last month.However when I used it today,its post didn't word ,which caused NullPointerException,while other translators works well.
I had tried other cookie,sign and token,to my disappointed the exception happened again.
I wonder how I can make it work correctly.
Thank you!
java.lang.NullPointerException at com.swjtu.trans.impl.BaiduTranslator.parses(BaiduTranslator.java:73) at com.swjtu.trans.AbstractTranslator.run(AbstractTranslator.java:42) at com.swjtu.querier.Querier.execute(Querier.java:24)
法语是French,应该不是Fra吧
可以参考chrome的语言双字母简写
https://src.chromium.org/viewvc/chrome/trunk/src/third_party/cld/languages/internal/languages.cc
StringBuilder saveFile = new StringBuilder();
saveFile.append("src\\main\\java\\\\com\\swjtu\\TTS_multimedia\\")
.append(this.getClass().getName())
.append("-")
.append(Util.md5(uri))
.append(".mp3");
rg.apache.http.conn.HttpHostConnectException: Connect to www.google.com:443 [www.google.com/127.0.0.1, www.google.com/2404:6800:4012:0:0:0:0:2004] failed: Connection timed out: connect
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:151)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:107)
at com.swjtu.trans.impl.GoogleTranslator.query(GoogleTranslator.java:74)
at com.swjtu.trans.AbstractTranslator.run(AbstractTranslator.java:42)
at com.swjtu.querier.Querier.execute(Querier.java:25)
您好,调用百度翻译接口报401,请问如何处理
作者您好:
在使用在项目中的 Google 翻译器时,在后续的翻译请求了出现了标题中所示的错误。猜测是因为太频繁导致被封禁了 IP?但是我用使用 Google 翻译是正常的。希望作者能改善或者指导我如何改善该问题。谢谢!
建议在源码内去除BDUSS
Cookie内有BDUSS 可用于非法登录百度帐号
BaiduTranslator.java, line 57
request.setHeader("Cookie", "BAIDUxxxx");
你好,我写了一个NodeJS版本的hexo标题自动翻译插件,里面也涉及了调用有关百度翻译,有道翻译,和Google翻译的接口,但是百度翻译接口自升级后,已经无法直接使用了,必须使用appid和appsecret的方式调用。
看到你的项目中对百度翻译接口中的sign和Cookie值是直接指定的,是什么原理呢?另外是否有动态设置的方式?谢谢
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.