From 066eff62931fc0f116193dec7314610cec60b849 Mon Sep 17 00:00:00 2001 From: Encrylize Date: Wed, 9 Aug 2017 13:58:08 +0200 Subject: [PATCH] Update language names to match Google Translate (#33) * Change language names to match Google Translate This commit also fixes an issue introduced by commit 04a0e6df (issue #26), where language names with underscores in them would not work, because everything after an underscore is ignored. * Add test for language names with spaces in them --- googletrans/constants.py | 12 ++++++------ tests/test_client.py | 5 +++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/googletrans/constants.py b/googletrans/constants.py index d419433..c5099e7 100644 --- a/googletrans/constants.py +++ b/googletrans/constants.py @@ -19,8 +19,8 @@ LANGUAGES = { 'ca': 'catalan', 'ceb': 'cebuano', 'ny': 'chichewa', - 'zh-CN': 'chinese_simplified', - 'zh-TW': 'chinese_traditional', + 'zh-cn': 'chinese (simplified)', + 'zh-tw': 'chinese (traditional)', 'co': 'corsican', 'hr': 'croatian', 'cs': 'czech', @@ -38,7 +38,7 @@ LANGUAGES = { 'de': 'german', 'el': 'greek', 'gu': 'gujarati', - 'ht': 'haitian_creole', + 'ht': 'haitian creole', 'ha': 'hausa', 'haw': 'hawaiian', 'iw': 'hebrew', @@ -56,7 +56,7 @@ LANGUAGES = { 'kk': 'kazakh', 'km': 'khmer', 'ko': 'korean', - 'ku': 'kurdish', + 'ku': 'kurdish (kurmanji)', 'ky': 'kyrgyz', 'lo': 'lao', 'la': 'latin', @@ -71,7 +71,7 @@ LANGUAGES = { 'mi': 'maori', 'mr': 'marathi', 'mn': 'mongolian', - 'my': 'myanmar', + 'my': 'myanmar (burmese)', 'ne': 'nepali', 'no': 'norwegian', 'ps': 'pashto', @@ -82,7 +82,7 @@ LANGUAGES = { 'ro': 'romanian', 'ru': 'russian', 'sm': 'samoan', - 'gd': 'scots_gaelic', + 'gd': 'scots gaelic', 'sr': 'serbian', 'st': 'sesotho', 'sn': 'shona', diff --git a/tests/test_client.py b/tests/test_client.py index f913e3e..4370c52 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -42,6 +42,11 @@ def test_language_name(translator): assert result.text == u'Dia dhuit' +def test_language_name_with_space(translator): + result = translator.translate(u'Hello', src='en', dest='chinese (simplified)') + assert result.dest == 'zh-cn' + + def test_language_rfc1766(translator): result = translator.translate(u'luna', src='it_ch@euro', dest='en') assert result.text == u'moon'