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

Support of batch translate #101

Open
shtse8 opened this issue Jul 7, 2022 · 8 comments
Open

Support of batch translate #101

shtse8 opened this issue Jul 7, 2022 · 8 comments

Comments

@shtse8
Copy link

shtse8 commented Jul 7, 2022

I want to pass an array of string for translation. Could you add support of it?

@AidanWelch
Copy link

Okay I added this in my fork

@mashirozx
Copy link

You can spilt batch contents with line break, and translate in one request. In @AidanWelch 's fork, I see Promise.all handling multiple request, which is dangerous that may triage rate limit quickly.

FYI:
image

@shtse8
Copy link
Author

shtse8 commented Aug 5, 2022

You can spilt batch contents with line break, and translate in one request. In @AidanWelch 's fork, I see Promise.all handling multiple request, which is dangerous that may triage rate limit quickly.

FYI: image

it's not secure. line breaks sometimes will be added or removed after translated. be careful when you are using line breaks.

@mashirozx
Copy link

You can spilt batch contents with line break, and translate in one request. In @AidanWelch 's fork, I see Promise.all handling multiple request, which is dangerous that may triage rate limit quickly.
FYI: image

it's not secure. line breaks sometimes will be added or removed after translated. be careful when you are using line breaks.

It's just a suggestion. Although I can't 100% guarantee, I have been requesting in such method for a while and never meet unexpected adding or removing line break.

@AidanWelch
Copy link

You can spilt batch contents with line break, and translate in one request. In @AidanWelch 's fork, I see Promise.all handling multiple request, which is dangerous that may triage rate limit quickly.
FYI: image

it's not secure. line breaks sometimes will be added or removed after translated. be careful when you are using line breaks.

It's just a suggestion. Although I can't 100% guarantee, I have been requesting in such method for a while and never meet unexpected adding or removing line break.

It is now updated to just one request.

@AidanWelch
Copy link

But I should note, not by splitting with line breaks, as that has no guarantee of working in all cases. Instead it is just utilizing fully the batch request API that @shtse8 mapped out

@Asmedian
Copy link

@vitalets do you plan to add batch translation?

@vitalets
Copy link
Owner

@vitalets do you plan to add batch translation?

I think batching via concatenation into single string (as suggested above) should stay in userland, as there are edge cases that library can't be responsible for.
If we found way to access some batching API endpoint that accepts array of queries, I will be happy to add it to library.

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

5 participants