Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4a68883

Browse filesBrowse files
committed
Changes encoding style.
1 parent ca3796b commit 4a68883
Copy full SHA for 4a68883

File tree

Expand file treeCollapse file tree

1 file changed

+2
-6
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+2
-6
lines changed

‎translate/cloud-client/snippets.py

Copy file name to clipboardExpand all lines: translate/cloud-client/snippets.py
+2-6Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#!/usr/bin/env python
2-
# -*- coding: iso-8859-15 -*-
3-
42

53
# Copyright 2016 Google, Inc.
64
#
@@ -27,7 +25,6 @@
2725

2826

2927
from google.cloud import translate
30-
from six import python_2_unicode_compatible
3128

3229

3330
def detect_language(text):
@@ -80,7 +77,7 @@ def translate_text_with_model(target, text, model=translate.NMT):
8077
# Text can also be a sequence of strings, in which case this method
8178
# will return a sequence of results for each text.
8279
result = translate_client.translate(
83-
text,
80+
text.decode('utf-8'),
8481
target_language=target,
8582
model=model)
8683

@@ -90,7 +87,6 @@ def translate_text_with_model(target, text, model=translate.NMT):
9087
result['detectedSourceLanguage']))
9188

9289

93-
@python_2_unicode_compatible
9490
def translate_text(target, text):
9591
"""Translates text into the target language.
9692
@@ -102,7 +98,7 @@ def translate_text(target, text):
10298
# Text can also be a sequence of strings, in which case this method
10399
# will return a sequence of results for each text.
104100
result = translate_client.translate(
105-
unicode(text, 'utf8'),
101+
text.decode('utf-8'),
106102
target_language=target)
107103

108104
print(u'Text: {}'.format(result['input']))

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.