4

I am using google transliteration in my project. I tried the code snippet provided on Google Transliterate API Developer's Guide. However, less documentation is available and I have very less idea about this.

The code works in a way that it converts words into the target language only when you press space. It gives suggestions after you press backspace. I need that to work in a way that it will convert the words as an when you type characters and give suggestions simultaneously.

Following is the snippet I tried from the site:

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <script type="text/javascript" src="https://www.google.com/jsapi"></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.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>
        <textarea id="transliterateTextarea" style="width:600px;height:200px"></textarea>
    </body>
</html>
Shri
  • 834
  • 1
  • 12
  • 36
  • This code works.It converts words into the target language only when you press space. It gives suggestions after you press backspace.But i need the suggestion while typing the characters.Help me to sort out. – Sriram S Oct 04 '18 at 13:28
  • The Google Transliterate API has been officially deprecated as of May 26, 2011. Please refer this url for new apis https://cloud.google.com/translate/docs/quickstart – paranjothi Oct 08 '18 at 09:26

1 Answers1

1

I think Google doesn't allow to change that. It just takes control of your text area and executes it's own script which we don't have much control on.

Prakash
  • 75
  • 6
  • do you have any suggestions? i'm using google inputtools API now. but that too is tricky. have to handle too many things explicitly. – Shri Feb 11 '16 at 10:48