How to convert english to hindi language?

dmo  picture dmo · Dec 30, 2014 · Viewed 7.9k times · Source

I am trying to convert language Hindi to English which I am able to achieve this but when I type word in English I have to press space key to convert that letter from English to Hindi after every word. I want to convert them without pressing space key as well as when i paste any text.

Here is my code

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <script type="text/javascript" src="http://www.google.com/jsapi"></script>
    <link href="http://www.google.com/uds/modules/elements/transliteration/api.css"
      type="text/css" rel="stylesheet"/>
    <script type="text/javascript">
      // Load the Google Transliteration API
      google.load("elements", "1", {
            packages: "transliteration"
          });
      function onLoad() {
        var options = {
            sourceLanguage:
                google.elements.transliteration.LanguageCode.ENGLISH,
            destinationLanguage:
                google.elements.transliteration.LanguageCode.HINDI,
            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 Hindi (Press Ctrl+g to toggle between English and Hindi)<br>
    <a href="#" onclick="document.getElementById('Wrapper').style.display = 'block'; return false;">show textarea</a>
    <div id="Wrapper" style="display:none"> <h2> Textarea </h2>
    <textarea id="transliterateTextarea" style="width:600px;height:200px"></textarea>
    </div>
  </body>
</html>

How can I achieve my desired output

Answer