discourse/lib/localized_cooked_post_processor.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

28 lines
697 B
Ruby

# frozen_string_literal: true
class LocalizedCookedPostProcessor
include CookedProcessorMixin
def initialize(post_localization, post, opts = {})
@post_localization = post_localization
@post = post
@opts = opts
@doc = Loofah.html5_fragment(@post_localization.cooked)
@cooking_options = @post.cooking_options || {}
@cooking_options[:topic_id] = @post.topic_id
@cooking_options = @cooking_options.symbolize_keys
@model = @post
@category_id = @post&.topic&.category_id
@omit_nofollow = @post.omit_nofollow?
@size_cache = {}
end
def post_process
post_process_oneboxes
post_process_images
end
def html
@doc.try(:to_html)
end
end