File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env python
2
+ # -*- coding: iso-8859-15 -*-
3
+
2
4
3
5
# Copyright 2016 Google, Inc.
4
6
#
22
24
"""
23
25
24
26
import argparse
27
+ import os
28
+ import sys
25
29
26
30
from google .cloud import translate
27
31
@@ -97,7 +101,7 @@ def translate_text(target, text):
97
101
# Text can also be a sequence of strings, in which case this method
98
102
# will return a sequence of results for each text.
99
103
result = translate_client .translate (
100
- text ,
104
+ unicode ( text , 'utf8' ) ,
101
105
target_language = target )
102
106
103
107
print (u'Text: {}' .format (result ['input' ]))
Original file line number Diff line number Diff line change @@ -40,3 +40,7 @@ def test_translate_text(capsys):
40
40
snippets .translate_text ('is' , 'Hello world' )
41
41
out , _ = capsys .readouterr ()
42
42
assert u'Halló heimur' in out
43
+
44
+ def test_translate_utf8 (capsys ):
45
+ text = '나는 파인애플을 좋아한다.'
46
+ snippets .translate_text ('en' , text )
You can’t perform that action at this time.
0 commit comments