MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / detectLanguage

Function detectLanguage

translate/translate.js:33–40  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

31 // a single piece of text, or an array of strings for detecting the languages
32 // of multiple texts.
33 async function detectLanguage() {
34 let [detections] = await translate.detect(text);
35 detections = Array.isArray(detections) ? detections : [detections];
36 console.log('Detections:');
37 detections.forEach(detection => {
38 console.log(`${detection.input} => ${detection.language}`);
39 });
40 }
41
42 detectLanguage();
43 // [END translate_detect_language]

Callers 1

detectLanguageSampleFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected