如何使用 html 表单检测输入中插入的语言以翻译成其他语言? 使用希伯来语(iwrit)-英语。
<form action="http://translate.google.com/translate_t" target="_blank">
<input type="text" name="text">
<input type="hidden" value="hp" name="prev">
<input type="hidden" value="iw" name="hl">
<input type="hidden" value="y" name="js">
<input type="hidden" value="" name="file">
<input type="hidden" value="iw" name="sl">
<input type="hidden" value="en" name="tl">
<input type="hidden" value="#" name="history_state0">
<input type="submit" value="Translate">
</form>
最佳答案
假设您需要它实时更新而不是在提交表单时,您需要在要翻译的文本框更改时发出某种请求 ( http://api.jquery.com/change/ ),然后对指示语言的表单进行适当的更改。
至于功能本身,Google 有一个用于翻译的 API (https://developers.google.com/translate/v2/libraries)。在那里您会找到一个 JavaScript 接口(interface),它应该可以为您处理所有繁重的工作。
希望对您有所帮助。
关于javascript - 谷歌翻译参数表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12525856/