How to Use Google Input Tools in Website

后端 未结 2 1507
面向向阳花
面向向阳花 2020-12-24 15:16

Can you please let me know if it is possible to use Google Input Tools in a website using client side scripting like jquery or pure javascript? Is there any API available fo

相关标签:
2条回答
  • 2020-12-24 15:41

    Pravathy's answer worked for me as well. Just adding following google docs url if someone looks more details.

    Google Docs

    0 讨论(0)
  • 2020-12-24 15:56

    If you want to add google input tools you can use below code to add it

        
          // Load the Google Transliteration API
          google.load("elements", "1", {
            packages: "transliteration"
          });
        
          function onLoad() {
            var options = {
              sourceLanguage: 'en',
              destinationLanguage: ['gu', 'ml', 'hi', 'kn', 'ta', 'te'],
              shortcutKey: 'ctrl+m',
              transliterationEnabled: true
            }
        
            // Create an instance on TransliterationControl with the required options.
            var control = new google.elements.transliteration.TransliterationControl(options);
        
            // Enable transliteration in the textfields with the given ids.
            var ids = ["language"];
            control.makeTransliteratable(ids);
        
            // Show the transliteration control which can be used to toggle between English and Hindi and also choose other destination language.
            control.showControl('translControl');
          }
        
          google.setOnLoadCallback(onLoad);
        
    
     
        
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script type="text/javascript" src="http://www.google.com/jsapi"></script>
      
    <textarea name="hi"  rows="6"  id="language" cols="6" style="width:600px;height:70px" ></textarea>
    
    <div id='translControl'></div>

    0 讨论(0)
提交回复
热议问题