diff --git a/samples/snippets/quickstart.py b/samples/snippets/quickstart.py index c84ea892..888b6691 100644 --- a/samples/snippets/quickstart.py +++ b/samples/snippets/quickstart.py @@ -18,7 +18,7 @@ def run_quickstart(): # [START translate_quickstart] # Imports the Google Cloud client library - from google.cloud import translate + from google.cloud import translate_v2 as translate # Instantiates a client translate_client = translate.Client() diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt index a8bc353f..f8a1e7fe 100644 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -1,2 +1,2 @@ -google-cloud-translate==1.6.0 +google-cloud-translate==2.0.0 google-cloud-storage==1.19.1 diff --git a/samples/snippets/snippets.py b/samples/snippets/snippets.py index b5719d23..2d5232e6 100644 --- a/samples/snippets/snippets.py +++ b/samples/snippets/snippets.py @@ -23,13 +23,13 @@ import argparse -from google.cloud import translate import six def detect_language(text): # [START translate_detect_language] """Detects the text's language.""" + from google.cloud import translate_v2 as translate translate_client = translate.Client() # Text can also be a sequence of strings, in which case this method @@ -45,6 +45,7 @@ def detect_language(text): def list_languages(): # [START translate_list_codes] """Lists all available languages.""" + from google.cloud import translate_v2 as translate translate_client = translate.Client() results = translate_client.get_languages() @@ -61,6 +62,7 @@ def list_languages_with_target(target): Target must be an ISO 639-1 language code. See https://g.co/cloud/translate/v2/translate-reference#supported_languages """ + from google.cloud import translate_v2 as translate translate_client = translate.Client() results = translate_client.get_languages(target_language=target) @@ -70,7 +72,7 @@ def list_languages_with_target(target): # [END translate_list_language_names] -def translate_text_with_model(target, text, model=translate.NMT): +def translate_text_with_model(target, text, model='nmt'): # [START translate_text_with_model] """Translates text into the target language. @@ -79,6 +81,7 @@ def translate_text_with_model(target, text, model=translate.NMT): Target must be an ISO 639-1 language code. See https://g.co/cloud/translate/v2/translate-reference#supported_languages """ + from google.cloud import translate_v2 as translate translate_client = translate.Client() if isinstance(text, six.binary_type): @@ -103,6 +106,7 @@ def translate_text(target, text): Target must be an ISO 639-1 language code. See https://g.co/cloud/translate/v2/translate-reference#supported_languages """ + from google.cloud import translate_v2 as translate translate_client = translate.Client() if isinstance(text, six.binary_type):