Skip to content
New issue

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

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

Already on GitHub? # to your account

NotValidPayload does not return relevant data #200

Closed
travisrecupero opened this issue Mar 1, 2023 · 3 comments
Closed

NotValidPayload does not return relevant data #200

travisrecupero opened this issue Mar 1, 2023 · 3 comments

Comments

@travisrecupero
Copy link

  • deep_translator version: 1.10.0
  • Python version: 3.10
  • Operating System: Windows 10

Description

I created an xml translator that uses this api for translations. I used to translate one word at a time until I saw translate_batch(..). I am currently using the GoogleTranslator class (I don't reinstantiate this). The problem is that when one string of a batch is invalid, the string is not printed in the error. On my end, I cant step into translate_batch to find my invalid string.

Note that I am handling the 5k character limit so this is not the issue (by the error message, one might think this is their problem instead of a invalid translation).

What I Did

python main.py

I just added an except and a print when I get NotValidPayload

@travisrecupero
Copy link
Author

Update:
I found the error in my application. When using this API, strings that include a digit are accepted as valid payloads but strings that are only a digit or digits (text.isdigit()) are invalid.

I can update the code in validate.py to handle this case. I can also update the code in exceptions.py to give the user explicit string errors when using translate_batch(..). Let me know if you would like me open a PR.

@jiaulislam
Copy link
Contributor

jiaulislam commented Mar 3, 2023

@travisrecupero I have seen that issue in my earlier project. I didn't know the reason or understood why it should raise an exception if its only digit but I guess you open a PR for that issue, as I was working some other areas of this project it would be appreciated.

@nidhaloff
Copy link
Owner

@travisrecupero Sure please open a PR and I will get to it asap

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

No branches or pull requests

3 participants