-
-
Save FrnandMG/6cd2bd213eb9d89e021c4fbdbbd7f5c5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Aprende como traducir cualquier Texto con Python por #Tecsify | |
¡Tecnología que empodera!""" | |
from deep_translator import GoogleTranslator | |
# - - Esta parte del código traduce únicamente un texto plano | |
traductor = GoogleTranslator(source='es', target='en') | |
resultado = traductor.translate("La educación es el arma más poderosa para cambiar al mundo") | |
print(resultado) | |
#----------------------------------------------------------------------------- | |
# - - Esta parte del código traduce un archivo, esta comentada porque si el archivo no existe dará error. | |
#translated = GoogleTranslator(source='en', target='es').translate_file(r'C:\Users\Tecsify.txt') | |
#print(translated) | |
#----------------------------------------------------------------------------- | |
# - - Esta parte del código traduce una lista de palabras por separado sin que se vean afectadas por el contexto de la oración | |
lista = ["Tecsify","¡Tecnología","que","Empodera!"] | |
traductor = GoogleTranslator(source='auto', target='fr') | |
resultado = traductor.translate_batch(lista) | |
print(resultado) | |
#----------------------------------------------------------------------------- | |
#www.Tecsify.com/blog |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment