Skip to content

Instantly share code, notes, and snippets.

@AleksandraZuchewicz
Last active June 27, 2023 09:00
Show Gist options
  • Save AleksandraZuchewicz/d375ebc629dff48c5ae202032e192e69 to your computer and use it in GitHub Desktop.
Save AleksandraZuchewicz/d375ebc629dff48c5ae202032e192e69 to your computer and use it in GitHub Desktop.
Basic Google Cloud Translation API - detectLanguage
const translate = new Translate();
const text = ["这是一个非常好的API", "to jest bardzo dobre API"];
async function detectLanguage() {
let [detections] = await translate.detect(text);
detections = Array.isArray(detections) ? detections : [detections];
console.log("Detections:");
detections.forEach((detection) => {
console.log(detection);
});
}
detectLanguage();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment