【问题标题】:Getting error in Google Transliterate API in javascript在 javascript 中的 Google Transliterate API 中出现错误
【发布时间】:2020-10-03 04:18:19
【问题描述】:

我在我的项目中使用 Google Transliterate API 将英文文本翻译成古吉拉特语。它工作正常,但是我现在在 google-jsapi 中遇到问题。

这是我的代码:

<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>

错误:

  • 不支持使用 jsapi 加载器加载 inputtools 以外的元素。 ec@loader.js:90

  • 未捕获的错误:必须在 google.charts.setOnLoadCallback 之前调用 google.charts.load 在 Object.E.M [as setOnLoadCallback] (loader.js:87) 在 test.html:32

我已经查看了 Google 的 API 开发人员指南 .. 但这也会导致同样的问题。

来源:https://developers.google.com/transliterate/v1/getting_started

请帮我解决这个问题。

【问题讨论】:

  • 有同样的问题。你解决了吗?
  • @user1090751 我发现这个库已经被弃用了。因此,为它寻找替代方案。

标签: javascript google-translation-api


【解决方案1】:

它发生在网络上。所以我使用了旧版本的 jsapi,它可以在我的网站上运行 http://vaani.neechalkaran.com/ 脚本是 http://vaani.neechalkaran.com/Scripts/google_jsapi.js

【讨论】:

  • control.showControl("translControl") 未显示。
  • 效果很好。谢谢。
猜你喜欢
  • 2019-03-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-03-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-11-11
相关资源
最近更新 更多