Skip to content

Commit d4a30c2

Browse files
abbycardandhlee
authored andcommitted
docs(samples): Add Cloud Code tags for API Explorer pilot (#282)
This adds region tags in order to support the Cloud Code API Explorer pilot
1 parent 8940a05 commit d4a30c2

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

translation/samples/snippets/translate_v3_translate_text.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,14 @@
1313
# limitations under the License.
1414

1515
# [START translate_v3_translate_text]
16+
# [START translate_v3_translate_text_0]
17+
# Imports the Google Cloud Translation library
1618
from google.cloud import translate
19+
# [END translate_v3_translate_text_0]
1720

1821

22+
# [START translate_v3_translate_text_1]
23+
# Initialize Translation client
1924
def translate_text(text="YOUR_TEXT_TO_TRANSLATE", project_id="YOUR_PROJECT_ID"):
2025
"""Translating Text."""
2126

@@ -24,7 +29,10 @@ def translate_text(text="YOUR_TEXT_TO_TRANSLATE", project_id="YOUR_PROJECT_ID"):
2429
location = "global"
2530

2631
parent = f"projects/{project_id}/locations/{location}"
32+
# [END translate_v3_translate_text_1]
2733

34+
# [START translate_v3_translate_text_2]
35+
# Translate text from English to French
2836
# Detail on supported types can be found here:
2937
# https://cloud.google.com/translate/docs/supported-formats
3038
response = client.translate_text(
@@ -40,6 +48,7 @@ def translate_text(text="YOUR_TEXT_TO_TRANSLATE", project_id="YOUR_PROJECT_ID"):
4048
# Display the translation for each input text provided
4149
for translation in response.translations:
4250
print("Translated text: {}".format(translation.translated_text))
51+
# [END translate_v3_translate_text_2]
4352

4453

4554
# [END translate_v3_translate_text]

0 commit comments

Comments
 (0)