Getting error in Google Transliterate API in javascript
Asked Answered
R

1

11

I am using Google Transliterate API in my project to translate English text to Gujarati. It was working fine, however I am facing issue in google-jsapi now.

Here's my code:

<script type="text/javascript" src="http://www.google.com/jsapi"></script>

<script>
google.load("elements", "1", {
    packages: "transliteration"
});

function onLoad() {

    var options = {
        sourceLanguage: 'en',
        destinationLanguage: ['gu'],
        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 textfields with the given ids.

    var ids = [ "cus_name", "address"];
    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>

Errors:

  • Loading elements other than inputtools with the jsapi loader is unsupported. Ec @ loader.js:90

  • Uncaught Error: Must call google.charts.load before google.charts.setOnLoadCallback at Object.E.M [as setOnLoadCallback] (loader.js:87) at test.html:32

I have checked with Google's API Developer guide .. but that also results in same problem.

Source: https://developers.google.com/transliterate/v1/getting_started

Please help me with this issue.

Refutation answered 13/6, 2020 at 12:21 Comment(2)
having the same problem. Did you solved it?Theologue
@Theologue I have found that this library is already deprecated. So finding an alternative for it.Refutation
B
11

It happens all around the web. so I have used older version of jsapi and it works at my site http://vaani.neechalkaran.com/ script is http://vaani.neechalkaran.com/Scripts/google_jsapi.js

Bookbindery answered 19/6, 2020 at 6:2 Comment(2)
control.showControl("translControl") not showing.Arlaarlan
It works great. Thank you.Actinochemistry

© 2022 - 2024 — McMap. All rights reserved.