Get Chinese Romanization from Google Translate API(从 Google Translate API 获取中文罗马拼音)
问题描述
Google 语言翻译 API 可以干净利落地翻译成中文:
The Google language translate API works cleanly to translate into Chinese:
<script type="text/javascript" src="aHR0cDovL3d3dy5nb29nbGUuY29tL2pzYXBp"></script>
<script>
google.load('language','1');
function googletrans(text) {
google.language.translate(text,'en','zh',function(result) {
alert(result.translation);
});
}
</script>
<input onchange="googletrans(this.value);">
Example input: "Hello"
Result: "你好"
我的问题是我无法获得罗马拼音(使用英文字母的发音).这是一个已知问题.
My problem is I can't get the Romanization (pronunciation using English letters). This is a known issue.
现在数据就在 translate.google.com 上(示例输入:Hello" 结果:Nǐ hǎo"),我什至可以通过将浏览器指向:
Now the data is right there on translate.google.com (Example input: "Hello" Result: "Nǐ hǎo") and I can even see it by pointing my browser to:
http://translate.google.com/translate_a/t?client=t&text=hello&hl=en&sl=en&tl=zh-CN&otf=2&pc=0
Result:
{"sentences":[{"trans":"你好","orig":"hello","translit":"Nǐ hǎo"}],
"dict":[{"pos":"interjection","terms":["喂"]}],"src":"en"}
但不知何故,当我尝试使用 ajax 获取此 URL 时,它失败了(XMLHttpRequest 异常 101).有没有办法用 ajax 检索这个罗马化数据?
But somehow when I try to get this URL with ajax it fails (XMLHttpRequest Exception 101). Is there any way to retrieve this Romanization data with ajax?
推荐答案
今天看来不可能,但 Google Translate API 上存在未解决的问题来解决这个问题.如果我们能够围绕这个问题召集足够多的人,也许 Google 会提高其优先级:
It doesn't appear possible today, but there are open issues on the Google Translate API to address this. If we can rally enough people around the issue, perhaps Google will raise its priority:
1) http://code.google.com/p/google-ajax-apis/issues/detail?id=478&q=label%3AAPIType-Language&sort=-stars&colspec=ID%20Type%20Stars%20Status%20Modified%20Summary%20APIType%20Opened
2) http://code.google.com/p/google-ajax-apis/issues/detail?id=381&q=label%3AAPIType-Language&sort=-stars&colspec=ID%20Type%20Stars%20Status%20Modified%20Summary%20APIType%20Opened
这篇关于从 Google Translate API 获取中文罗马拼音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:从 Google Translate API 获取中文罗马拼音


- 400或500级别的HTTP响应 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- Fetch API 如何获取响应体? 2022-01-01
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- 失败的 Canvas 360 jquery 插件 2022-01-01
- Flexslider 箭头未正确显示 2022-01-01
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- addEventListener 在 IE 11 中不起作用 2022-01-01