discourse/app/serializers/site_text_serializer.rb
Roman Rizzi 82d2284ce6
FIX: I18n couldn't find translations. (#11774)
"I18n.t(key, locale: locale)" fails to find the correct translation in some cases. We should always wrap it with the "I18n.with_locale(locale)" method.

Also, reverting an override wasn't always possible because the serializer always used "I18n.locale" as the locale.
2021-01-20 17:43:00 -03:00

24 lines
468 B
Ruby

# frozen_string_literal: true
class SiteTextSerializer < ApplicationSerializer
attributes :id, :value, :overridden?, :can_revert?
def id
object[:id]
end
def value
object[:value]
end
def overridden?
if options[:overridden_keys]
options[:overridden_keys].include?(object[:id])
else
TranslationOverride.exists?(locale: object[:locale], translation_key: object[:id])
end
end
alias_method :can_revert?, :overridden?
end