1
+ # -*- coding: utf-8 -*-
1
2
# Copyright 2019 Google LLC
2
3
#
3
4
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -34,7 +35,7 @@ def translate_text(project_id, text):
34
35
target_language_code = 'sr-Latn' )
35
36
36
37
for translation in response .translations :
37
- print ('Translated Text: {}' .format (translation ))
38
+ print (u 'Translated Text: {}' .format (translation ))
38
39
# [END translate_translate_text_beta]
39
40
40
41
@@ -71,8 +72,8 @@ def batch_translate_text(project_id, input_uri, output_uri):
71
72
72
73
result = operation .result (90 )
73
74
74
- print ('Total Characters: {}' .format (result .total_characters ))
75
- print ('Translated Characters: {}' .format (result .translated_characters ))
75
+ print (u 'Total Characters: {}' .format (result .total_characters ))
76
+ print (u 'Translated Characters: {}' .format (result .translated_characters ))
76
77
# [END translate_batch_translate_text_beta]
77
78
78
79
@@ -93,7 +94,7 @@ def detect_language(project_id, text):
93
94
mime_type = 'text/plain' ) # mime types: text/plain, text/html
94
95
95
96
for language in response .languages :
96
- print ('Language Code: {} (Confidence: {})' .format (
97
+ print (u 'Language Code: {} (Confidence: {})' .format (
97
98
language .language_code ,
98
99
language .confidence ))
99
100
# [END translate_detect_language_beta]
@@ -113,7 +114,7 @@ def list_languages(project_id):
113
114
114
115
print ('Supported Languages:' )
115
116
for language in response .languages :
116
- print ('Language Code: {}' .format (language .language_code ))
117
+ print (u 'Language Code: {}' .format (language .language_code ))
117
118
# [END translate_list_codes_beta]
118
119
119
120
@@ -134,8 +135,8 @@ def list_languages_with_target(project_id, display_language_code):
134
135
135
136
print ('Supported Languages:' )
136
137
for language in response .languages :
137
- print ('Language Code: {}' .format (language .language_code ))
138
- print ('Display Name: {}\n ' .format (language .display_name ))
138
+ print (u 'Language Code: {}' .format (language .language_code ))
139
+ print (u 'Display Name: {}\n ' .format (language .display_name ))
139
140
# [END translate_list_language_names_beta]
140
141
141
142
@@ -172,8 +173,8 @@ def create_glossary(project_id, glossary_id):
172
173
operation = client .create_glossary (parent = parent , glossary = glossary )
173
174
174
175
result = operation .result (timeout = 90 )
175
- print ('Created: {}' .format (result .name ))
176
- print ('Input Uri: {}' .format (result .input_config .gcs_source .input_uri ))
176
+ print (u 'Created: {}' .format (result .name ))
177
+ print (u 'Input Uri: {}' .format (result .input_config .gcs_source .input_uri ))
177
178
# [END translate_create_glossary_beta]
178
179
179
180
@@ -188,12 +189,12 @@ def list_glossaries(project_id):
188
189
parent = client .location_path (project_id , location )
189
190
190
191
for glossary in client .list_glossaries (parent ):
191
- print ('Name: {}' .format (glossary .name ))
192
- print ('Entry count: {}' .format (glossary .entry_count ))
193
- print ('Input uri: {}' .format (
192
+ print (u 'Name: {}' .format (glossary .name ))
193
+ print (u 'Entry count: {}' .format (glossary .entry_count ))
194
+ print (u 'Input uri: {}' .format (
194
195
glossary .input_config .gcs_source .input_uri ))
195
196
for language_code in glossary .language_codes_set .language_codes :
196
- print ('Language code: {}' .format (language_code ))
197
+ print (u 'Language code: {}' .format (language_code ))
197
198
# [END translate_list_glossary_beta]
198
199
199
200
@@ -211,13 +212,13 @@ def get_glossary(project_id, glossary_id):
211
212
glossary_id )
212
213
213
214
response = client .get_glossary (parent )
214
- print ('Name: {}' .format (response .name ))
215
- print ('Language Pair:' )
216
- print ('\t Source Language Code: {}' .format (
215
+ print (u 'Name: {}' .format (response .name ))
216
+ print (u 'Language Pair:' )
217
+ print (u '\t Source Language Code: {}' .format (
217
218
response .language_pair .source_language_code ))
218
- print ('\t Target Language Code: {}' .format (
219
+ print (u '\t Target Language Code: {}' .format (
219
220
response .language_pair .target_language_code ))
220
- print ('Input Uri: {}' .format (
221
+ print (u 'Input Uri: {}' .format (
221
222
response .input_config .gcs_source .input_uri ))
222
223
# [END translate_get_glossary_beta]
223
224
@@ -237,7 +238,7 @@ def delete_glossary(project_id, glossary_id):
237
238
238
239
operation = client .delete_glossary (parent )
239
240
result = operation .result (timeout = 90 )
240
- print ('Deleted: {}' .format (result .name ))
241
+ print (u 'Deleted: {}' .format (result .name ))
241
242
# [END translate_delete_glossary_beta]
242
243
243
244
0 commit comments