discourse/lib/post_localization_destroyer.rb
Natalie Tay 38e6420016
FEATURE: Also process manually updated translations (#35276)
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"
/>
2025-10-09 00:33:36 +08:00

15 lines
415 B
Ruby

# frozen_string_literal: true
class PostLocalizationDestroyer
def self.destroy(post_id:, locale:, acting_user:)
Guardian.new(acting_user).ensure_can_localize_content!
localization = PostLocalization.find_by(post_id: post_id, locale: locale)
raise Discourse::NotFound unless localization
post = localization.post
localization.destroy!
post.publish_change_to_clients! :revised
end
end