Skip to content

Commit

Permalink
Adding BASE and NMT constants for translation.
Browse files Browse the repository at this point in the history
  • Loading branch information
dhermes committed Nov 14, 2016
1 parent c50484e commit 8f446aa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion system_tests/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_translate(self):
values = ['hvala ti', 'dankon',
'Me llamo Jeff', 'My name is Jeff']
translations = Config.CLIENT.translate(
values, target_language='de', model='nmt')
values, target_language='de', model=translate.NMT)
self.assertEqual(len(values), len(translations))

self.assertEqual(
Expand Down
2 changes: 2 additions & 0 deletions translate/google/cloud/translate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@

"""Google Cloud Translate API wrapper."""

from google.cloud.translate.client import BASE
from google.cloud.translate.client import Client
from google.cloud.translate.client import NMT
from google.cloud.translate.connection import Connection
8 changes: 7 additions & 1 deletion translate/google/cloud/translate/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
ENGLISH_ISO_639 = 'en'
"""ISO 639-1 language code for English."""

BASE = 'base'
"""Base translation model."""

NMT = 'nmt'
"""Neural Machine Translation model."""


class Client(BaseClient):
"""Client to bundle configuration needed for API requests.
Expand Down Expand Up @@ -194,7 +200,7 @@ def translate(self, values, target_language=None, format_=None,
:type model: str
:param model: (Optional) The model used to translate the text. The
only accepted values are ``base`` and ``nmt``.
only accepted values are :attr:`BASE` and :attr:`NMT`.
:rtype: str or list
:returns: A list of dictionaries for each queried value. Each
Expand Down

0 comments on commit 8f446aa

Please sign in to comment.