MTrans
MTrans copied to clipboard
Map selection problem under the GoogleTranslator class setFormData() under jdk 1.8
#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 他们应该有反爬虫机制。
@water-law 兄台,可以提个 PR,我 review 合一下。 Hi, Boy. You can open a pull request, I will merge it after code review.