Skip to content

Commit fef998b

Browse files
telpirionbusunkim96
authored andcommitted
fix: changes fields printed in list glossary sample; some minor fixes (#2746)
1 parent 7fa03ea commit fef998b

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

translate/cloud-client/translate_v3_create_glossary.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def sample_create_glossary(project_id, input_uri, glossary_id):
3434
# TODO(developer): Uncomment and set the following variables
3535
# project_id = 'YOUR_PROJECT_ID'
3636
# glossary_id = 'your-glossary-display-name'
37-
# input_uri = 'gs://cloud-samples-data/translation/glossary.csv'
37+
# input_uri = 'gs://cloud-samples-data/translation/glossary_ja.csv'
3838
location = 'us-central1' # The location of the glossary
3939

4040
name = client.glossary_path(
@@ -50,6 +50,10 @@ def sample_create_glossary(project_id, input_uri, glossary_id):
5050
input_config = translate.types.GlossaryInputConfig(
5151
gcs_source=gcs_source)
5252

53+
# Note: You can create a glossary using one of two modes:
54+
# language_code_set or language_pair. When listing the information for
55+
# a glossary, you can only get information for the mode you used
56+
# when creating the glossary.
5357
glossary = translate.types.Glossary(
5458
name=name,
5559
language_codes_set=language_codes_set,

translate/cloud-client/translate_v3_list_glossary.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,23 @@ def sample_list_glossaries(project_id):
3434

3535
# TODO(developer): Uncomment and set the following variables
3636
# project_id = '[Google Cloud Project ID]'
37-
parent = client.location_path(project_id, "us-central1")
37+
location = 'us-central1'
38+
parent = client.location_path(project_id, location)
3839

3940
# Iterate over all results
4041
for glossary in client.list_glossaries(parent):
4142
print('Name: {}'.format(glossary.name))
4243
print('Entry count: {}'.format(glossary.entry_count))
4344
print('Input uri: {}'.format(
4445
glossary.input_config.gcs_source.input_uri))
46+
47+
# Note: You can create a glossary using one of two modes:
48+
# language_code_set or language_pair. When listing the information for
49+
# a glossary, you can only get information for the mode you used
50+
# when creating the glossary.
4551
for language_code in glossary.language_codes_set.language_codes:
4652
print('Language code: {}'.format(language_code))
47-
if glossary.language_pair:
48-
print(glossary.language_pair.source_language_code)
49-
print(glossary.language_pair.target_language_code)
53+
5054

5155
# [END translate_v3_list_glossary]
5256

0 commit comments

Comments
 (0)