-
Notifications
You must be signed in to change notification settings - Fork 264
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
Add Yandex translator option to translate_missing functionality #343
Conversation
end | ||
|
||
def options_for_html | ||
{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Yandex API needs format: 'html'
for translating HTML values
https://tech.yandex.com/translate/doc/dg/reference/translate-docpage/
I see that the yandex-translate gem doesn't support the format
option yet.
We should make sure HTML keys are supported before merging this, because otherwise they will have broken markup.
Looks like there is an abandoned PR for this aegorov/yandex-translator#13
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened a pr to do that work over there and updated the implementation here to utilize it:
aegorov/yandex-translator#14
protected | ||
|
||
def translate_values(list, **options) | ||
list.map { |item| translator.translate(item, options) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: This is going to cause lots of requests to the Yandex API, processed in-sequence (slow).
It would be better to pass multiple text
parameters to the request, batched to avoid hitting the 10,000 character limit, each batch in its own Thread or Fiber. This should be implemented in the yandex gem.
This is not a blocker for submitting this PR (just waiting for a new release of the yandex gem).
translate_missing can be incredibly useful but the two existing options both cost money to use. Yandex Translate is a potential free option for people.