Skip to content

Commit 1fd695d

Browse files
abbycarAce Nassri
authored and
Ace Nassri
committed
Add Cloud Code tags for API Explorer pilot (#712)
1 parent b98f023 commit 1fd695d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

translate/v3/translate_translate_text.js

+9
Original file line numberDiff line numberDiff 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();

0 commit comments

Comments
 (0)