discourse/app/serializers/concerns/localized_fancy_topic_title_mixin.rb
Natalie Tay c61a6f83e7
FEATURE: Localize topic titles in notifications and bookmarks (#34059)
Localizes topic titles in these areas
- user notification
- bookmarks

This commit also updates the user notification bookmark list to use fancy
title instead of title, similar to the other user notification tabs.
2025-08-05 12:12:22 +08:00

29 lines
635 B
Ruby

# frozen_string_literal: true
module LocalizedFancyTopicTitleMixin
def self.included(klass)
klass.attributes :fancy_title
end
def fancy_title
f = _topic.fancy_title
if (ContentLocalization.show_translated_topic?(_topic, scope))
_topic.get_localization&.fancy_title.presence || f
else
f
end
end
def include_fancy_title?
_topic.present? && _topic&.fancy_title.present?
end
private
def _topic
return object if object.class == Topic
return topic if defined?(topic) && topic.class == Topic
object.topic if defined?(object.topic) && object.topic.class == Topic
end
end