Last active
June 27, 2023 09:00
-
-
Save AleksandraZuchewicz/d375ebc629dff48c5ae202032e192e69 to your computer and use it in GitHub Desktop.
Basic Google Cloud Translation API - detectLanguage
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 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