Search code examples
node.jsgoogle-apigoogle-translate

different meaning of words google translate api


I have question. I use google translate api and some words e.g. "table" have different meaning. If I translate this world to russian language (using api), I got translate only for one meaning. How I can get several translate for several meaning?

My code:

const Translate = require('@google-cloud/translate');
const translate = new Translate({
    keyFilename: 'token.json',
});
const text = 'table';
const target = 'ru';
translate
  .translate(text, target)
  .then(results => {
    console.log(`Text: ${text}`);
    console.log(`Translation: ${JSON.stringify(results)}`);
  })
  .catch(err => {
    console.error('ERROR:', err);
  });

My output:

Text: table
Translation: ["Таблица",{"data":{"translations":[{"translatedText":"Таблица","detectedSourceLanguage":"en"}]}}]

except the word "Таблица", should be the word "Стол"

Sorry for my english.


Solution

  • As stated in the Cloud Translation API's FAQ:

    Is it possible to get multiple translations of a word?

    • No. This feature is only available via the web interface at translate.google.com

    So this feature is only available through the web interface at translate.google.com, and therefore there is no way to have multiple translations of the same content using Cloud Translation API.