1+ # -*- coding: utf-8 -*-
12# Copyright 2019 Google LLC
23#
34# Licensed under the Apache License, Version 2.0 (the "License");
@@ -34,7 +35,7 @@ def translate_text(project_id, text):
3435 target_language_code = 'sr-Latn' )
3536
3637 for translation in response .translations :
37- print ('Translated Text: {}' .format (translation ))
38+ print (u 'Translated Text: {}' .format (translation ))
3839 # [END translate_translate_text_beta]
3940
4041
@@ -71,8 +72,8 @@ def batch_translate_text(project_id, input_uri, output_uri):
7172
7273 result = operation .result (90 )
7374
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 ))
7677 # [END translate_batch_translate_text_beta]
7778
7879
@@ -93,7 +94,7 @@ def detect_language(project_id, text):
9394 mime_type = 'text/plain' ) # mime types: text/plain, text/html
9495
9596 for language in response .languages :
96- print ('Language Code: {} (Confidence: {})' .format (
97+ print (u 'Language Code: {} (Confidence: {})' .format (
9798 language .language_code ,
9899 language .confidence ))
99100 # [END translate_detect_language_beta]
@@ -113,7 +114,7 @@ def list_languages(project_id):
113114
114115 print ('Supported Languages:' )
115116 for language in response .languages :
116- print ('Language Code: {}' .format (language .language_code ))
117+ print (u 'Language Code: {}' .format (language .language_code ))
117118 # [END translate_list_codes_beta]
118119
119120
@@ -134,8 +135,8 @@ def list_languages_with_target(project_id, display_language_code):
134135
135136 print ('Supported Languages:' )
136137 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 ))
139140 # [END translate_list_language_names_beta]
140141
141142
@@ -172,8 +173,8 @@ def create_glossary(project_id, glossary_id):
172173 operation = client .create_glossary (parent = parent , glossary = glossary )
173174
174175 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 ))
177178 # [END translate_create_glossary_beta]
178179
179180
@@ -188,12 +189,12 @@ def list_glossaries(project_id):
188189 parent = client .location_path (project_id , location )
189190
190191 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 (
194195 glossary .input_config .gcs_source .input_uri ))
195196 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 ))
197198 # [END translate_list_glossary_beta]
198199
199200
@@ -211,13 +212,13 @@ def get_glossary(project_id, glossary_id):
211212 glossary_id )
212213
213214 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 (
217218 response .language_pair .source_language_code ))
218- print ('\t Target Language Code: {}' .format (
219+ print (u '\t Target Language Code: {}' .format (
219220 response .language_pair .target_language_code ))
220- print ('Input Uri: {}' .format (
221+ print (u 'Input Uri: {}' .format (
221222 response .input_config .gcs_source .input_uri ))
222223 # [END translate_get_glossary_beta]
223224
@@ -237,7 +238,7 @@ def delete_glossary(project_id, glossary_id):
237238
238239 operation = client .delete_glossary (parent )
239240 result = operation .result (timeout = 90 )
240- print ('Deleted: {}' .format (result .name ))
241+ print (u 'Deleted: {}' .format (result .name ))
241242 # [END translate_delete_glossary_beta]
242243
243244
0 commit comments