From 6a9f7ca3f68239a862106fcbcd9c73649ce36c77 Mon Sep 17 00:00:00 2001 From: Elizabeth Crowdus Date: Wed, 7 Aug 2019 13:57:32 -0700 Subject: [PATCH 1/4] fixing translate-with-glossary bug --- translate/cloud-client/beta_snippets.py | 2 +- translate/cloud-client/beta_snippets_test.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/translate/cloud-client/beta_snippets.py b/translate/cloud-client/beta_snippets.py index 7cd94aed59a0..0f8a423c39ec 100644 --- a/translate/cloud-client/beta_snippets.py +++ b/translate/cloud-client/beta_snippets.py @@ -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] diff --git a/translate/cloud-client/beta_snippets_test.py b/translate/cloud-client/beta_snippets_test.py index f7099a27cae1..56534c6cbad1 100644 --- a/translate/cloud-client/beta_snippets_test.py +++ b/translate/cloud-client/beta_snippets_test.py @@ -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): From ba977c044023c50d51f19e8c5de469fb96cada3c Mon Sep 17 00:00:00 2001 From: Elizabeth Crowdus Date: Thu, 8 Aug 2019 18:29:50 -0700 Subject: [PATCH 2/4] tests passing --- translate/cloud-client/beta_snippets.py | 2 +- translate/cloud-client/beta_snippets_test.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/translate/cloud-client/beta_snippets.py b/translate/cloud-client/beta_snippets.py index 0f8a423c39ec..a560ead5f711 100644 --- a/translate/cloud-client/beta_snippets.py +++ b/translate/cloud-client/beta_snippets.py @@ -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)) # [END translate_list_language_names_beta] diff --git a/translate/cloud-client/beta_snippets_test.py b/translate/cloud-client/beta_snippets_test.py index 56534c6cbad1..f4ab5634a524 100644 --- a/translate/cloud-client/beta_snippets_test.py +++ b/translate/cloud-client/beta_snippets_test.py @@ -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): @@ -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): @@ -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 def test_create_glossary(capsys, unique_glossary_id): From 8fb9f7e7cdcbda782a03a5e5a670f3b443fd9b9e Mon Sep 17 00:00:00 2001 From: Elizabeth Crowdus Date: Fri, 9 Aug 2019 14:38:40 -0700 Subject: [PATCH 3/4] reverting to python3 compatibility --- translate/cloud-client/beta_snippets.py | 2 +- translate/cloud-client/beta_snippets_test.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/translate/cloud-client/beta_snippets.py b/translate/cloud-client/beta_snippets.py index a560ead5f711..0f8a423c39ec 100644 --- a/translate/cloud-client/beta_snippets.py +++ b/translate/cloud-client/beta_snippets.py @@ -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)) # [END translate_list_language_names_beta] diff --git a/translate/cloud-client/beta_snippets_test.py b/translate/cloud-client/beta_snippets_test.py index f4ab5634a524..265fb9867100 100644 --- a/translate/cloud-client/beta_snippets_test.py +++ b/translate/cloud-client/beta_snippets_test.py @@ -77,9 +77,9 @@ def test_batch_translate_text(capsys, bucket): def test_detect_language(capsys): - beta_snippets.detect_language(PROJECT_ID, 'Bonjour le monde') + beta_snippets.detect_language(PROJECT_ID, 'Hæ sæta') out, _ = capsys.readouterr() - assert 'fr' in out + assert 'is' in out def test_list_languages(capsys): @@ -89,10 +89,10 @@ def test_list_languages(capsys): def test_list_languages_with_target(capsys): - beta_snippets.list_languages_with_target(PROJECT_ID, 'es') + beta_snippets.list_languages_with_target(PROJECT_ID, 'is') out, _ = capsys.readouterr() - assert u'Language Code: en' in out - # assert u'Display Name: anglais' in out + assert u'Language Code: sq' in out + assert u'Display Name: albanska' in out def test_create_glossary(capsys, unique_glossary_id): From 2ea876df59eb70d9a7b70beaf2a30e9fcdda3bf6 Mon Sep 17 00:00:00 2001 From: Elizabeth Crowdus Date: Fri, 9 Aug 2019 14:56:33 -0700 Subject: [PATCH 4/4] snippets test fix --- translate/cloud-client/snippets_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translate/cloud-client/snippets_test.py b/translate/cloud-client/snippets_test.py index 5123576698ad..6d63759daeee 100644 --- a/translate/cloud-client/snippets_test.py +++ b/translate/cloud-client/snippets_test.py @@ -46,4 +46,4 @@ def test_translate_utf8(capsys): text = u'나는 파인애플을 좋아한다.' snippets.translate_text('en', text) out, _ = capsys.readouterr() - assert u'I like pineapples.' in out + assert u'I like pineapple' in out