[Answer for 676] Translate text to many languages

node v8.17.0
version: 1.0.0
endpointsharetweet
const { promisify } = require("util"); const translator = require("google-translator"); const translate = (...args) => new Promise(resolve => translator(...args, resolve)); const inputText = "whisper"; const inputLang = 'en' // translate the inputText to each language const languages = translator.languages; // get all languages for (const lang in languages) { console.log(lang + " " + (await translate(inputLang, lang, inputText)).text); }
Created from: https://npm.runkit.com/google-translator
Loading…

no comments

    sign in to comment