Методы перевода с английского на голландский: примеры кода

  1. Использование библиотеки googletrans:

    from googletrans import Translator
    def translate_english_to_dutch(text):
    translator = Translator()
    translation = translator.translate(text, src='en', dest='nl')
    return translation.text
    english_text = "Hello, how are you?"
    dutch_translation = translate_english_to_dutch(english_text)
    print(dutch_translation)
  2. библиотека:

    from translate import Translator
    def translate_english_to_dutch(text):
    translator = Translator(to_lang="nl")
    translation = translator.translate(text)
    return translation
    english_text = "Hello, how are you?"
    dutch_translation = translate_english_to_dutch(english_text)
    print(dutch_translation)

    библиотека:

    from mtranslate import translate
    def translate_english_to_dutch(text):
    translation = translate(text, 'nl', 'en')
    return translation
    english_text = "Hello, how are you?"
    dutch_translation = translate_english_to_dutch(english_text)
    print(dutch_translation)
  3. Использование библиотеки TextBlob:

    from textblob import TextBlob
    def translate_english_to_dutch(text):
    blob = TextBlob(text)
    translation = blob.translate(to='nl')
    return translation
    english_text = "Hello, how are you?"
    dutch_translation = translate_english_to_dutch(english_text)
    print(dutch_translation)