Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG 4.0.0rc1: TypeError while trying to translate "Formosa" to portuguese #414

Open
2 of 6 tasks
GarciaNicolas opened this issue Sep 4, 2024 · 1 comment
Open
2 of 6 tasks

Comments

@GarciaNicolas
Copy link

Googletrans version:

  • 4.0.0rc1
  • 3.1.0a0
  • 3.0.0
  • 2.x

I'm submitting a ...

  • bug report
  • feature request

Current behavior:
When I try to translate "Formosa", an argentine province, to portuguese it throws an exception

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[97], [line 3](vscode-notebook-cell:?execution_count=97&line=3)
      [1](vscode-notebook-cell:?execution_count=97&line=1) translator = Translator()
----> [3](vscode-notebook-cell:?execution_count=97&line=3) translator.translate("Formosa", dest='pt').text

File ...Python\Python312\Lib\site-packages\googletrans\client.py:222, in Translator.translate(self, text, dest, src)
    [220](file:///.../Python/Python312/Lib/site-packages/googletrans/client.py:220) # not sure
    [221](file:///.../Python/Python312/Lib/site-packages/googletrans/client.py:221) should_spacing = parsed[1][0][0][3]
--> [222](file:///.../Python/Python312/Lib/site-packages/googletrans/client.py:222) translated_parts = list(map(lambda part: TranslatedPart(part[0], part[1] if len(part) >= 2 else []), parsed[1][0][0][5]))
    [223](file:///.../Python/Python312/Lib/site-packages/googletrans/client.py:223) translated = (' ' if should_spacing else '').join(map(lambda part: part.text, translated_parts))
    [225](file:///.../Python/Python312/Lib/site-packages/googletrans/client.py:225) if src == 'auto':

TypeError: 'NoneType' object is not iterable

Expected behavior:
It should return "Formosa"

Related code:

from googletrans import Translator

translator = Translator()
translator.translate("Formosa", dest='pt').text
@nacho00112
Copy link

same, but with "Female" when I try to translate it into Spanish

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants