mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-01 12:58:30 +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" />
24 lines
623 B
Ruby
24 lines
623 B
Ruby
# frozen_string_literal: true
|
|
|
|
class PostLocalizationCreator
|
|
def self.create(post_id:, locale:, raw:, user:)
|
|
Guardian.new(user).ensure_can_localize_content!
|
|
|
|
post = Post.find_by(id: post_id)
|
|
raise Discourse::NotFound unless post
|
|
|
|
localization =
|
|
PostLocalization.create!(
|
|
post: post,
|
|
locale: locale,
|
|
raw: raw,
|
|
cooked: post.post_analyzer.cook(raw, post.cooking_options || {}),
|
|
post_version: post.version,
|
|
localizer_user_id: user.id,
|
|
)
|
|
|
|
Jobs.enqueue(:process_localized_cooked, post_localization_id: localization.id)
|
|
|
|
localization
|
|
end
|
|
end
|