mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-02 17:57:36 +08:00
This is a follow up to https://github.com/discourse/discourse/pull/34900. When a user manually updates translation via the translation composer, also send the new translated cooked for post processing. I moved the Processor to core, given PostLocalizations are core feature. <img width="551" height="385" alt="Screenshot 2025-10-08 at 6 12 26 PM" src="https://github.com/user-attachments/assets/1cce7ce3-5487-4e75-90fd-440792b9a899" />
23 lines
672 B
Ruby
23 lines
672 B
Ruby
# frozen_string_literal: true
|
|
|
|
class PostLocalizationUpdater
|
|
def self.update(post_id:, locale:, raw:, user:)
|
|
Guardian.new(user).ensure_can_localize_content!
|
|
|
|
localization = PostLocalization.find_by(post_id: post_id, locale: locale)
|
|
raise Discourse::NotFound unless localization
|
|
|
|
post = Post.find_by(id: post_id)
|
|
raise Discourse::NotFound unless post
|
|
|
|
localization.raw = raw
|
|
localization.cooked = PrettyText.cook(raw)
|
|
localization.localizer_user_id = user.id
|
|
localization.post_version = post.version
|
|
localization.save!
|
|
|
|
Jobs.enqueue(:process_localized_cooked, post_localization_id: localization.id)
|
|
|
|
localization
|
|
end
|
|
end
|