Python Forum
[GoogleTrans] How can i print my translation word ?...
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[GoogleTrans] How can i print my translation word ?...
#1
Hey Programmers...

I try to translate the word 'Yes' to the Dutch (Ja)... but it don't works perfect...


This is my code:
from googletrans import Translator

translator = Translator()

ab = translator.translate(['Yes'], dest='nl')

print(ab)
If i print my translate 'Yes' in 'Ja' (if i translate Netherlands, you get 'Ja'),
then i get this:

My Result:
Output:
[<googletrans.models.Translated object at 0x035F1E90>]
Can anyone help me to correct my code, just i get 'Ja' or rether... my translated word
thad i want translate to another languale, i.p.v. this above stand print ?...

Thanks for help, Jamie.
Reply
#2
>>> from googletrans import Translator

>>> translator = Translator()
>>> ab = translator.translate('Yes', dest='nl')
>>> ab
<googletrans.models.Translated object at 0x046BD4F0>

>>> ab.text
'Ja'
>>> ab.dest
'nl'
>>> ab.origin
'Yes'

>>> # Method you can use
>>> [i for i in dir(ab) if not '__' in i]
['dest', 'origin', 'pronunciation', 'src', 'text']
If using a REPL like ptpython, Ipython then these method will automatic show up when write ab..
Reply
#3
Hm, I didn't know that library and wrote a multilanguage google translator from scratch a month ago :D
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#4
(Oct-09-2017, 03:28 PM)snippsat Wrote:
>>> from googletrans import Translator

>>> translator = Translator()
>>> ab = translator.translate('Yes', dest='nl')
>>> ab
<googletrans.models.Translated object at 0x046BD4F0>

>>> ab.text
'Ja'
>>> ab.dest
'nl'
>>> ab.origin
'Yes'

>>> # Method you can use
>>> [i for i in dir(ab) if not '__' in i]
['dest', 'origin', 'pronunciation', 'src', 'text']
If using a REPL like ptpython, Ipython then these method will automatic show up when write ab..

Thanks for you code... this problem is fixed !...

Jamie.
Reply
#5
Hi everyone!
Is there any way to print src pronunciations instead of dest? For example, when I print pronunciation I've got pronun from src words:
import itertools
from googletrans import Translator
translator = Translator(service_urls=[
'translate.google.com',
])
import itertools
from googletrans import Translator
translator = Translator(service_urls=[
'translate.google.com',
])
pronunces = translator.translate(words, dest='ru')

for pronunce in pronunces:
print(pronunce.pronunciation)

I've got pronounce in dest=ru, but need en.

I'll be mutch thanks for any help.
Sorry for my English
Reply
#6
(Oct-09-2017, 03:01 PM)JamieVanCadsand Wrote: Hey Programmers...

I try to translate the word 'Yes' to the Dutch (Ja)... but it don't works perfect...


This is my code:
from googletrans import Translator

translator = Translator()

ab = translator.translate(['Yes'], dest='nl')

print(ab)
If i print my translate 'Yes' in 'Ja' (if i translate Netherlands, you get 'Ja'),
then i get this:

My Result:
Output:
[<googletrans.models.Translated object at 0x035F1E90>]
Can anyone help me to correct my code, just i get 'Ja' or rether... my translated word
thad i want translate to another languale, i.p.v. this above stand print ?...

Thanks for help, Jamie.
Reply
#7
at line no 7 of your posting use print(ab.text)
Reply
#8
see this complete googletrans code for Python:

https://neculaifantanaru.com/en/python-c...brary.html

https://neculaifantanaru.com/en/example-...lsoup.html

https://neculaifantanaru.com/en/deepl-ap...slate.html
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Translation AliceCu 2 654 May-16-2023, 09:05 PM
Last Post: deanhystad
  googletrans library to translate text language for using data frame is not running gcozba2023 0 1,215 Mar-06-2023, 09:50 AM
Last Post: gcozba2023
  python print all files which contain specific word in it mg24 5 1,226 Jan-27-2023, 11:20 AM
Last Post: snippsat
  Translation API snippyro 0 1,249 Nov-02-2021, 01:09 AM
Last Post: snippyro
Question Problem: Check if a list contains a word and then continue with the next word Mangono 2 2,484 Aug-12-2021, 04:25 PM
Last Post: palladium
  Translation of R Code to Python for Statistical Learning Course SterlingAesir 2 2,129 Aug-27-2020, 08:46 AM
Last Post: ndc85430
  Python Speech recognition, word by word AceScottie 6 15,970 Apr-12-2020, 09:50 AM
Last Post: vinayakdhage
  recording a translation table into a file arbiel 0 1,441 Mar-31-2020, 02:33 PM
Last Post: arbiel
  print a word after specific word search evilcode1 8 4,807 Oct-22-2019, 08:08 AM
Last Post: newbieAuggie2019
  Manipulation a file for translation apsyrtos 1 2,020 Sep-10-2019, 02:56 AM
Last Post: luoheng

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020