File tree Expand file tree Collapse file tree 1 file changed +2
-6
lines changed
Filter options
Expand file tree Collapse file tree 1 file changed +2
-6
lines changed
Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env python
2
- # -*- coding: iso-8859-15 -*-
3
-
4
2
5
3
# Copyright 2016 Google, Inc.
6
4
#
27
25
28
26
29
27
from google .cloud import translate
30
- from six import python_2_unicode_compatible
31
28
32
29
33
30
def detect_language (text ):
@@ -80,7 +77,7 @@ def translate_text_with_model(target, text, model=translate.NMT):
80
77
# Text can also be a sequence of strings, in which case this method
81
78
# will return a sequence of results for each text.
82
79
result = translate_client .translate (
83
- text ,
80
+ text . decode ( 'utf-8' ) ,
84
81
target_language = target ,
85
82
model = model )
86
83
@@ -90,7 +87,6 @@ def translate_text_with_model(target, text, model=translate.NMT):
90
87
result ['detectedSourceLanguage' ]))
91
88
92
89
93
- @python_2_unicode_compatible
94
90
def translate_text (target , text ):
95
91
"""Translates text into the target language.
96
92
@@ -102,7 +98,7 @@ def translate_text(target, text):
102
98
# Text can also be a sequence of strings, in which case this method
103
99
# will return a sequence of results for each text.
104
100
result = translate_client .translate (
105
- unicode ( text , 'utf8 ' ),
101
+ text . decode ( 'utf-8 ' ),
106
102
target_language = target )
107
103
108
104
print (u'Text: {}' .format (result ['input' ]))
You can’t perform that action at this time.
0 commit comments