mirror of
https://github.com/discourse/discourse.git
synced 2025-10-03 17:21:20 +08:00
Follow up to https://github.com/discourse/discourse/pull/34212 This commit affects the crawler view for topic view, e.g. \<site>/t/:slug/:id, and updates the title, subcategory (+parent category breadcrumb), post, if any of them are not in the site default locale, and have an equivalent localization. | before | after | |---|---| | <img width="1264" height="831" alt="Screenshot 2025-08-12 at 7 09 50 PM" src="https://github.com/user-attachments/assets/677d4595-4d4a-482e-b948-c0043576348e" /> mixed mode | <img width="1264" height="831" alt="Screenshot 2025-08-12 at 7 11 35 PM" src="https://github.com/user-attachments/assets/552f16ca-ebf2-4bdd-a052-a3abb8174a29" /> site default locale |
32 lines
843 B
Ruby
32 lines
843 B
Ruby
# frozen_string_literal: true
|
|
|
|
module TopicListResponder
|
|
def respond_with_list(list)
|
|
discourse_expires_in 1.minute
|
|
|
|
respond_to do |format|
|
|
format.html do
|
|
@list = list
|
|
localize_topic_list_content(list)
|
|
|
|
store_preloaded(
|
|
list.preload_key,
|
|
MultiJson.dump(TopicListSerializer.new(list, scope: guardian)),
|
|
)
|
|
render "list/list"
|
|
end
|
|
format.json { render_serialized(list, TopicListSerializer) }
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def localize_topic_list_content(list)
|
|
return if list.topics.blank? || !SiteSetting.content_localization_enabled
|
|
crawl_locale = params[Discourse::LOCALE_PARAM].presence || SiteSetting.default_locale
|
|
|
|
list.topics.each do |topic|
|
|
LocalizationAttributesReplacer.replace_topic_attributes(topic, crawl_locale)
|
|
end
|
|
end
|
|
end
|