Getting error in Google Transliterate API in javascript

时光怂恿深爱的人放手 提交于 2020-07-18 16:16:42

问题


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.


回答1:


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




回答2:


http://vaani.neechalkaran.com/Scripts/google_jsapi.js its working only for hindi translate control.showControl("translControl"); not showing



来源:https://stackoverflow.com/questions/62359665/getting-error-in-google-transliterate-api-in-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!