0

I want to transalte a column of my dataframe from Japanese to English. After searching I found Google translate API. I tried various codes as below

Sample Code

from googletrans import Translator
translator = Translator()
sp["Spl"] = sp["件名"].map(lambda x: translator.translate(x, src="ja", dest="en").text)

but everytime I was getting following error AttributeError: 'NoneType' object has no attribute 'group'

I changed the column type from object to string but the error was same.

So I tried the codes on simple strings as follows:

import googletrans
text1 = '日本語が難しい'
text2 = 'What are you doing'
translator = Translator()
print(translator.detect(text1))
print(translator.detect(text2))

Still same error AttributeError: 'NoneType' object has no attribute 'group'

deega
  • 833
  • 3
  • 8
  • 16
  • Does this answer your question? [Googletrans API AttributeError](https://stackoverflow.com/questions/65095668/googletrans-api-attributeerror) – Ari Cooper-Davis Oct 26 '22 at 10:39

1 Answers1

0

It looks like this is an issue with the googletrans library being unable to get past Google's "Before you continue to Google" cookie acceptance page, for which there is currently no easy solution.

As this library is not officially supported by Google you're probably breaking their terms of service by using it. You might be better off using the officially supported Cloud Translation API which has a free tier of 500,000 characters per month.

Ari Cooper-Davis
  • 3,374
  • 3
  • 26
  • 43