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 11#!/usr/bin/env python
2+ # -*- coding: iso-8859-15 -*-
3+
24
35# Copyright 2016 Google, Inc.
46#
2224"""
2325
2426import argparse
27+ import os
28+ import sys
2529
2630from google .cloud import translate
2731
@@ -97,7 +101,7 @@ def translate_text(target, text):
97101 # Text can also be a sequence of strings, in which case this method
98102 # will return a sequence of results for each text.
99103 result = translate_client .translate (
100- text ,
104+ unicode ( text , 'utf8' ) ,
101105 target_language = target )
102106
103107 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):
4040 snippets .translate_text ('is' , 'Hello world' )
4141 out , _ = capsys .readouterr ()
4242 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