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

Function main

translate/quickstart.js:17–47  ·  view source on GitHub ↗
(
  projectId = 'YOUR_PROJECT_ID' // Your GCP Project Id
)

Source from the content-addressed store, hash-verified

15'use strict';
16
17function main(
18 projectId = 'YOUR_PROJECT_ID' // Your GCP Project Id
19) {
20 // [START translate_quickstart]
21 /**
22 * TODO(developer): Uncomment the following line before running the sample.
23 */
24 // const projectId = 'YOUR_PROJECT_ID';
25
26 // Imports the Google Cloud client library
27 const {Translate} = require('@google-cloud/translate').v2;
28
29 // Instantiates a client
30 const translate = new Translate({projectId});
31
32 async function quickStart() {
33 // The text to translate
34 const text = 'Hello, world!';
35
36 // The target language
37 const target = 'ru';
38
39 // Translates some text into Russian
40 const [translation] = await translate.translate(text, target);
41 console.log(`Text: ${text}`);
42 console.log(`Translation: ${translation}`);
43 }
44
45 quickStart();
46 // [END translate_quickstart]
47}
48
49main(...process.argv.slice(2));

Callers 1

quickstart.jsFile · 0.70

Calls 1

quickStartFunction · 0.70

Tested by

no test coverage detected