( projectId = 'YOUR_PROJECT_ID' // Your GCP Project Id )
| 15 | 'use strict'; |
| 16 | |
| 17 | function 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 | |
| 49 | main(...process.argv.slice(2)); |
no test coverage detected