2012-01-28 60 views
0

如何使用Google的功能使用戶能夠在我的網站的textarea的textarea中輸入孟加拉語,該功能可以自動將打印的英語單詞轉換爲正確的孟加拉語單詞?啓用其他語言鍵入

回答

1
*BEfore that signup for the API key http://code.google.com/apis/loader/signup.html* 
<pre> 
<html> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 
    <script type="text/javascript" src="https://www.google.com/jsapi?key=INSERT-YOUR-KEY"> 
    </script> 
    <script type="text/javascript"> 

     // Load the Google Transliterate API 
     google.load("elements", "1", { 
      packages: "transliteration" 
      }); 

     function onLoad() { 
     var options = { 
      sourceLanguage: 
       google.elements.transliteration.LanguageCode.ENGLISH, 
      destinationLanguage: 
       [google.elements.transliteration.LanguageCode.BENGALI], 
      shortcutKey: 'ctrl+g', 
      transliterationEnabled: true 
     }; 

     // Create an instance on TransliterationControl with the required 
     // options. 
     var control = 
      new google.elements.transliteration.TransliterationControl(options); 

     // Enable transliteration in the textbox with id 
     // 'transliterateTextarea'. 
     control.makeTransliteratable(['transliterateTextarea']); 
     } 
     google.setOnLoadCallback(onLoad); 
    </script> 
    </head> 
    <body> 
    Type in BENGALI (Press Ctrl+g to toggle between English and BENGALI)<br> 
    <textarea id="transliterateTextarea" style="width:600px;height:200px"></textarea> 
    </body> 
</html> 
</pre> 
1

你可以使用谷歌AJAX Language API服務 - 工具翻譯與語言檢測,使用此功能,

google.language.translate('Gato', 'es', 'en', function(result) { 
    alert(result.translation); 
}); 

的完整參考,請訪問:Google Ajax api

0
<script type="text/javascript"> 

    // Load the Google Transliterate API 
    google.load("elements", "1", { 
     packages: "transliteration" 
     }); 

    function onLoad() { 
    var options = { 
     sourceLanguage:'en', // from english 
     destinationLanguage:['or'], // to oriya 
     shortcutKey: 'ctrl+g', 
     transliterationEnabled: true 
    }; 

    // Create an instance on TransliterationControl with the required 
    // options. 
    var control = 
     new google.elements.transliteration.TransliterationControl(options); 

    // Enable transliteration in the textbox with id 
    // 'transliterateTextarea'. 
    control.makeTransliteratable(['TEXT_BOX_ID']); 
    } 
    google.setOnLoadCallback(onLoad); 
</script> 

請檢查這些細節到適當的文檔 https://developers.google.com/transliterate/v1/getting_started?hl=en