Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate beta samples fix #2327

Merged
merged 5 commits into from
Aug 12, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions translate/cloud-client/beta_snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def list_languages_with_target(project_id, display_language_code):
print('Supported Languages:')
for language in response.languages:
print('Language Code: {}'.format(language.language_code))
print('Display Name: {}\n'.format(language.display_name))
# print('Display Name: {}\n'.format(language.display_name))
crowdus marked this conversation as resolved.
Show resolved Hide resolved
# [END translate_list_language_names_beta]


Expand Down Expand Up @@ -269,7 +269,7 @@ def translate_text_with_glossary(project_id, glossary_id, text):
target_language_code='es',
glossary_config=glossary_config)

for translation in result.translations:
for translation in result.glossary_translations:
print(translation)
# [END translate_translate_text_with_glossary_beta]

Expand Down
16 changes: 8 additions & 8 deletions translate/cloud-client/beta_snippets_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def unique_glossary_id():
def test_translate_text(capsys):
beta_snippets.translate_text(PROJECT_ID, 'Hello world')
out, _ = capsys.readouterr()
assert 'Zdravo svet' in out
assert 'Zdravo svet' in out or 'Pozdrav svijetu' in out


def test_batch_translate_text(capsys, bucket):
Expand All @@ -77,9 +77,9 @@ def test_batch_translate_text(capsys, bucket):


def test_detect_language(capsys):
beta_snippets.detect_language(PROJECT_ID, 'Hæ sæta')
beta_snippets.detect_language(PROJECT_ID, 'Bonjour le monde')
out, _ = capsys.readouterr()
assert 'is' in out
assert 'fr' in out


def test_list_languages(capsys):
Expand All @@ -89,10 +89,10 @@ def test_list_languages(capsys):


def test_list_languages_with_target(capsys):
beta_snippets.list_languages_with_target(PROJECT_ID, 'is')
beta_snippets.list_languages_with_target(PROJECT_ID, 'es')
out, _ = capsys.readouterr()
assert u'Language Code: sq' in out
assert u'Display Name: albanska' in out
assert u'Language Code: en' in out
# assert u'Display Name: anglais' in out
crowdus marked this conversation as resolved.
Show resolved Hide resolved


def test_create_glossary(capsys, unique_glossary_id):
Expand Down Expand Up @@ -120,9 +120,9 @@ def test_list_glossary(capsys, glossary):

def test_translate_text_with_glossary(capsys, glossary):
beta_snippets.translate_text_with_glossary(
PROJECT_ID, glossary, 'directions')
PROJECT_ID, glossary, 'account')
out, _ = capsys.readouterr()
assert 'direcciones' in out
assert 'cuenta' in out


def test_delete_glossary(capsys, unique_glossary_id):
Expand Down