Google 科尔多瓦翻译器 Api

Google Translator Api in Cordova

我正在为我的网站使用 Google 翻译器 API。对于 cordova 中的移动应用程序,google api 支持吗?不行不行我不知道是什么问题?

您可能想尝试使用 JavaScript 客户端库进行客户端翻译,以下示例向您展示了如何操作:

<html>
<head>
<script>
var apiKey = 'YOUR_API_KEY'; // get from https://console.cloud.google.com

</script>
</head>
<body>
<script>
function doTranslate() {
  gapi.client.language.translations.list({
      q:document.getElementById('from').value,
      target:'es'}).then(function(r) {
          document.getElementById('to').value =
              r.result.data.translations[0].translatedText; })
}
</script>
<textarea id="from"></textarea>
<textarea disable id="to"></textarea>
<script src="https://apis.google.com/js/client:api.js?onload=initGapi"></script>
<button onclick="doTranslate()">Translate</button>
</body>
</html>

关键是翻译功能,它使用 JavaScript 客户端库将翻译文本发送到翻译 API。

他们有一个非常容易使用的 RESTful API。更多细节: https://cloud.google.com/translate/docs/getting-started#REST