Closed travisrecupero closed 1 year ago
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.
@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.
@travisrecupero Sure please open a PR and I will get to it asap
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 intotranslate_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
I just added an
except
and a print when I getNotValidPayload