允许输入其他语言

发布于 2024-12-29 08:28:04 字数 67 浏览 4 评论 0原文

我怎样才能让用户使用谷歌的功能在我网站的文本区域中输入孟加拉语,该功能可以自动将键入的英语单词翻译为正确的孟加拉语单词?

How can I enable user to type in Bengali in textarea in my website's textarea using Google's feature which can automatically translate typed English word to proper Bengali word ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

陪你到最终 2025-01-05 08:28:04
*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>
*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>
原来是傀儡 2025-01-05 08:28:04

您可以使用 Google AJAX Language API - Tools for Translation and Language Inspection,使用此功能,

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

完整参考请访问 Google Ajax API

you can use Google AJAX Language API - Tools for Translation and Language Detection, using this function,

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

for complete reference, visit Google Ajax api

我为君王 2025-01-05 08:28:04
<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

<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>

Please check these details to proper documentation
https://developers.google.com/transliterate/v1/getting_started?hl=en

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文