lushan88a / google_trans_new

A free and unlimited python API for google translate.
MIT License
393 stars 170 forks source link

How do i translate a list? #16

Open realdeveloperongithub opened 3 years ago

realdeveloperongithub commented 3 years ago

If i do translator.translate(item,lang_tgt='en') for every item in my list, I guess i may soon reach the quota of google translate.

lushan88a commented 3 years ago

You need a for loop =。=

realdeveloperongithub commented 3 years ago

You need a for loop =。=

for now i'm using:

for item in raw_list:
    translated = translator.translate(item,lang_tgt='en')
    translated_list.append(translated)
return translated_list

Isn't it risky? I tried to combine them into a string using \n, but it caused chaos because the google_trans_new library just replace the newline with something like "***" again.

lushan88a commented 3 years ago

So far, there is no risk!

lushan88a commented 3 years ago

Now you can use "\n" to cut the sentence.