-
Notifications
You must be signed in to change notification settings - Fork 52
DEV: Immediately send post for language detection for dual-text translations #226
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
Conversation
| def execute(args) | ||
| return unless SiteSetting.translator_enabled | ||
|
|
||
| translatable = args[:type].constantize.find_by(id: args[:translatable_id]) |
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.
Should we validate that args[:type] returns a string?
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.
fair!
| class AutomaticTranslations | ||
| def inject(plugin) | ||
| plugin.on(:post_process_cooked) do |_, post| | ||
| if SiteSetting.automatic_translation_target_languages.present? && post.user_id > 0 |
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.
I'm missing some context on how auto-translation should work for system-type users like system (typically with negative user IDs), I'm assuming from these that they are deliberately exempt?
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.
Yes, for now, bot posts should not be translated. (so stuff like discobot PMs or AI bot responses should generally be avoided)
tyb-talks
left a comment
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.
lgtm outside of the nit on validating args[:type] :)
Not too long ago, we moved language detections to a scheduled job. (see internal /t/134867/21)
But the new inline translation feature (when turned on) sends all content for translation the moment it is created. So far, we are not seeing an issue with load for this.
This PR reverts the batching for language detection to the original way, in-line with the new translation feature.
This PR also does a bit of cleanup - introducing three files to encapsulate the plugin event hooks into their own functionality (automatic translation, inline translation, dual-text translation)
This changes here will help to simplify the problem of 🌐 showing up in the post briefly, but in a subsequent PR.