Class for translating texts and detecting language (based on Google Translator).
Project description
Class for translating texts and detecting language (based on Google Translator).
Get text translation:
from google_translator_simplified import Translator
Translator.get_translation('pl', 'text for translation', 'en') #'Tekst do tłumaczenia '
Translator.get_translation('de', 'tekst do przetłumaczenia', 'pl') #'Text für die Übersetzung '
Translator.get_translation('pl', 'text for translation') #'Tekst do tłumaczenia '
Translator.get_translation('de', 'tekst do przetłumaczenia') #'Text für die Übersetzung '
Detect language:
from google_translator_simplified import Translator
Translator.detect_lang('text for translation') #'en'
Translator.detect_lang('Mittwoch') #'de'
Translator.detect_lang('inny przykład') #'pl'
Get language abbreviation:
from google_translator_simplified import Translator
Translator.get_abbreviation('english') #'en'
Translator.get_abbreviation('polish') #'pl'
Translator.get_abbreviation('german') #'de'
Get language full name:
from google_translator_simplified import Translator
Translator.get_name('en') #'english'
Translator.get_name('pl') #'polish'
Translator.get_name('de') #'german'
names list:
from google_translator_simplified import Translator
Translator.names_list[:7] #['afrikaans', 'albanian', 'amharic', 'arabic', 'armenian', 'azerbaijani', 'basque'])
abbreviation list:
from google_translator_simplified import Translator
Translator.abbreviation_list[:7] #['af', 'sq', 'am', 'ar', 'hy', 'az', 'eu']
Errors:
from google_translator_simplified import Translator
import unittest
class TestTranslator(unittest.TestCase):
def test_untranslatableError(self):
self.assertRaises(Translator.TranslatorUntranslatableError,
Translator.detect_lang, '')
self.assertRaises(Translator.TranslatorUntranslatableError,
Translator.detect_lang, '``2564&&')
self.assertRaises(Translator.TranslatorUntranslatableError,
Translator.detect_lang, ' ')
self.assertRaises(Translator.TranslatorUntranslatableError,
Translator.detect_lang, ' \t\n')
def test_IncorrectAbbreviation(self):
self.assertRaises(Translator.TranslatorIncorrectAbbreviation,
Translator.get_translation, '', 'text for translation')
self.assertRaises(Translator.TranslatorIncorrectAbbreviation,
Translator.get_translation, 'd', 'text for translation')
self.assertRaises(Translator.TranslatorIncorrectAbbreviation,
Translator.get_translation, 'de', 'text for translation', 'e')
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file google_translator_simplified-0.0.7.tar.gz
.
File metadata
- Download URL: google_translator_simplified-0.0.7.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd68dc42f6ca3408033b4865be0f7358bd2017c73f080e0c55879392a7ccb147 |
|
MD5 | f67fac729dec15bf5e00ac2a62463c6c |
|
BLAKE2b-256 | f5d8198235258981e2154fa18f9d1cfa6ba0236c01730bfb4f7ef140578f3e0f |
File details
Details for the file google_translator_simplified-0.0.7-py3-none-any.whl
.
File metadata
- Download URL: google_translator_simplified-0.0.7-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 853cd787ccd6fc80011cbb12f2dff316fe170e3a6a4c615d8a54b281223026bb |
|
MD5 | adcd11f0e8797ae9c6d036631f2df668 |
|
BLAKE2b-256 | 69935f1e1cd574a0c558027feee692a49703344656f373ebcd45da2f1cbae8ac |