File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -27,12 +27,18 @@ function main(
2727 // const location = 'global';
2828 // const text = 'text to translate';
2929
30+ // [START translate_v3_translate_text_0]
3031 // Imports the Google Cloud Translation library
3132 const { TranslationServiceClient} = require ( '@google-cloud/translate' ) ;
33+ // [END translate_v3_translate_text_0]
3234
35+ // [START translate_v3_translate_text_1]
3336 // Instantiates a client
3437 const translationClient = new TranslationServiceClient ( ) ;
38+ // [END translate_v3_translate_text_1]
39+
3540 async function translateText ( ) {
41+ // [START translate_v3_translate_text_2]
3642 // Construct request
3743 const request = {
3844 parent : `projects/${ projectId } /locations/${ location } ` ,
@@ -41,13 +47,16 @@ function main(
4147 sourceLanguageCode : 'en' ,
4248 targetLanguageCode : 'sr-Latn' ,
4349 } ;
50+ // [END translate_v3_translate_text_2]
4451
52+ // [START translate_v3_translate_text_3]
4553 // Run request
4654 const [ response ] = await translationClient . translateText ( request ) ;
4755
4856 for ( const translation of response . translations ) {
4957 console . log ( `Translation: ${ translation . translatedText } ` ) ;
5058 }
59+ // [END translate_v3_translate_text_3]
5160 }
5261
5362 translateText ( ) ;
You can’t perform that action at this time.
0 commit comments