Skip to content

Instantly share code, notes, and snippets.

@AleksandraZuchewicz
Last active May 11, 2020 15:01
Show Gist options
  • Save AleksandraZuchewicz/5a30efecb3e9083bcb32284a1dda7615 to your computer and use it in GitHub Desktop.
Save AleksandraZuchewicz/5a30efecb3e9083bcb32284a1dda7615 to your computer and use it in GitHub Desktop.
Basic Google Cloud Translation API - translate
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