Last active
May 11, 2020 15:01
-
-
Save AleksandraZuchewicz/5a30efecb3e9083bcb32284a1dda7615 to your computer and use it in GitHub Desktop.
Basic Google Cloud Translation API - translate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const text = [ | |
"这是一个非常好的API", | |
"to jest bardzo dobre API", | |
"это очень хороший API", | |
]; | |
const target = "en"; | |
async function translateText() { | |
let [translations] = await translate.translate(text, target); | |
translations = Array.isArray(translations) ? translations : [translations]; | |
console.log("Translations:"); | |
translations.forEach((translation, i) => { | |
console.log(`${text[i]} => (${target}) ${translation}`); | |
}); | |
} | |
translateText(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment