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

[v5] batch-style still has a text limit of 5000 chars #65

Open
songkeys opened this issue Feb 1, 2021 · 4 comments
Open

[v5] batch-style still has a text limit of 5000 chars #65

songkeys opened this issue Feb 1, 2021 · 4 comments

Comments

@songkeys
Copy link

songkeys commented Feb 1, 2021

There is still a text limit in batch-style RPC mode from v5.

If the character length exceeds 5000 characters, an error will occur:

TypeError: Cannot read property '1' of null
Url: https://translate.google.com/_/TranslateWebserverUi/data/batchexecute?rpcids=MkEWBc&f.sid=3349740657455987534&bl=boq_translate-webserver_20210128.12_p0&hl=en-US&soc-app=1&soc-platform=1&soc-device=1&_reqid=9513&rt=c
    at ....../node_modules/@vitalets/google-translate-api/index.js:90:21
    at processTicksAndRejections (internal/process/task_queues.js:93:5) {
  code: 'BAD_NETWORK'
}

It happens with this line:

if (json[1][0][0][5] === undefined) {

@vitalets
Copy link
Owner

vitalets commented Feb 7, 2021

It seems this is a restriction of Google translation API itself.
Could you try splitting text by chunks as suggested in #20?

@songkeys
Copy link
Author

songkeys commented Feb 7, 2021

Yes. Splitting text does solve the problem. The previous implementation allows only around 3000 characters. And the new one is 5000, which is also the one of web version. Seems reasonable.
I take it this new batch-style just adds up another 2000 of limit? Is there any other difference?

@vitalets
Copy link
Owner

vitalets commented Feb 8, 2021

@songkeys I think we can only check differences on practice. As I didn't find any docs on this RPC API and current implementation was reverse engIneered in this article.

Anyway, I've added note about maximum text length to readme. Thanks!

@vkedwardli
Copy link

In the website, there is a pagination system splitting each 5000 chars

"5,000 character limit. Use the arrows to translate more"

I think this is the hard limit.

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

3 participants