|
| 1 | +# Copyright 2020 Google LLC |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +# [START translate_v3_list_glossary] |
| 16 | +from google.cloud import translate |
| 17 | + |
| 18 | + |
| 19 | +def sample_list_glossaries(project_id="YOUR_PROJECT_ID"): |
| 20 | + """List Glossaries.""" |
| 21 | + |
| 22 | + client = translate.TranslationServiceClient() |
| 23 | + |
| 24 | + parent = client.location_path(project_id, "us-central1") |
| 25 | + |
| 26 | + # Iterate over all results |
| 27 | + for glossary in client.list_glossaries(parent): |
| 28 | + print("Name: {}".format(glossary.name)) |
| 29 | + print("Entry count: {}".format(glossary.entry_count)) |
| 30 | + print("Input uri: {}".format(glossary.input_config.gcs_source.input_uri)) |
| 31 | + |
| 32 | + # Note: You can create a glossary using one of two modes: |
| 33 | + # language_code_set or language_pair. When listing the information for |
| 34 | + # a glossary, you can only get information for the mode you used |
| 35 | + # when creating the glossary. |
| 36 | + for language_code in glossary.language_codes_set.language_codes: |
| 37 | + print("Language code: {}".format(language_code)) |
| 38 | + |
| 39 | + |
| 40 | +# [END translate_v3_list_glossary] |
0 commit comments