少年幃禿的煩惱


心情也微微的...凸

最近的學習心得 都改放到 少年幃禿的煩惱@Google Sites

2008/07/02

Google AJAX Language API (3) - Examples

Language Translation
1. 翻譯 javascript string

google.language.translate("Hello world", "en", "es", function(result) { if (!result.error) { alert(result.translation); } });

Language Detection
2. 判斷 javascript string 語言 var text = "¿Dónde está el baño?"; google.language.detect(text, function(result) { if (!result.error) { var language = 'unknown'; for (l in google.language.Languages) { if (google.language.Languages[l] == result.language) { alert(l); break; } } } });

Source Detection during Translation
3. 這個例子跟基本的翻譯範例很像, 這是示範翻譯時不知道來源語言的情況. 只要來源語言指定一個空字串, 系統會在一次呼叫裡面偵測並且翻譯完畢 google.language.translate("Hello world", "", "es", function(result) { if (!result.error) { alert(result.translation); } });

Some Additional Samples
4. 顯示 confidence 與 reliability factors


Result here

5. 不同語言間的翻譯

>>
Result here