問題描述
Google 語言翻譯 A??PI 可以干凈利落地翻譯成中文:
The Google language translate API works cleanly to translate into Chinese:
<script type="text/javascript" src="http://www.google.com/jsapi"></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: "你好"
我的問題是我無法獲得羅馬拼音(使用英文字母的發(fā)音).這是一個(gè)已知問題.
My problem is I can't get the Romanization (pronunciation using English letters). This is a known issue.
現(xiàn)在數(shù)據(jù)就在 translate.google.com 上(示例輸入:Hello" 結(jié)果: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"}
但不知何故,當(dāng)我嘗試使用 ajax 獲取此 URL 時(shí),它失敗了(XMLHttpRequest 異常 101).有沒有辦法用 ajax 檢索這個(gè)羅馬化數(shù)據(jù)?
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 上存在未解決的問題來解決這個(gè)問題.如果我們能夠圍繞這個(gè)問題召集足夠多的人,也許 Google 會(huì)提高其優(yōu)先級(jí):
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
這篇關(guān)于從 Google Translate API 獲取中文羅馬拼音的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!