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

Update batchTrans.js - Issue #11 #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

SinaElahimanesh
Copy link

Hello,
I solved it by adding a new function, alternativeBatchTranslation, in batchTrans.js file.
In case of error, it catches the error and by finding the error reason, translates all the words and also returns the error type.
So in case of
const texts = ["", "Hallo Welt", "guten morgen"]; google .translateBatch(texts) .then(res => console.log("batch translation: ", res));
The result will be like bellow:
[ 'ERROR: error translating batch: The input text length must be of type string between 1 and 5000 characters', 'Hello World', 'Good morning' ]
As it can be seen the first box has an error, and the second and third element is translated successfully =)

I am eagerly waiting for you to merge my pull request and accept it.
Thanks a lot.
Sina Elahimanesh

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

Successfully merging this pull request may close these issues.

1 participant