discourse/app/serializers/basic_topic_serializer.rb
Natalie Tay 51ebe7064c
FEATURE: Show localized posts and topics based on user's locale (#32618)
Related:
- https://github.com/discourse/discourse-translator/pull/205
- https://github.com/discourse/discourse-translator/pull/274
- https://github.com/discourse/discourse-translator/pull/294

With this PR, we will start showing localized posts (if available) based
on the user's locale.

This work had been done in discourse-translator, but is now moving to
core.
2025-05-15 19:11:06 +08:00

16 lines
425 B
Ruby

# frozen_string_literal: true
# The most basic attributes of a topic that we need to create a link for it.
class BasicTopicSerializer < ApplicationSerializer
attributes :id, :title, :fancy_title, :slug, :posts_count
def fancy_title
f = object.fancy_title
if (ContentLocalization.show_translated_topic?(object, scope))
object.get_localization&.fancy_title.presence || f
else
f
end
end
end