Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

google-translator-simplified

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

google-translator-simplified

Class for translating texts and detecting language (based on Google Translator).

  • 0.0.7
  • PyPI
  • Socket score

Maintainers
1

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')

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc