discourse/app/serializers/site_text_serializer.rb

24 lines
482 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2014-09-25 02:45:35 +08:00
class SiteTextSerializer < ApplicationSerializer
attributes :id, :value, :overridden?, :can_revert?
2014-09-25 02:45:35 +08:00
def id
object[:id]
2014-09-25 02:45:35 +08:00
end
def value
object[:value]
2014-09-25 02:45:35 +08:00
end
def overridden?
if I18n.exists?(object[:id])
I18n.overrides_disabled { I18n.t(object[:id]) != object[:value] }
else
TranslationOverride.exists?(locale: I18n.locale, translation_key: object[:id])
end
2014-09-25 02:45:35 +08:00
end
alias_method :can_revert?, :overridden?
2014-09-25 02:45:35 +08:00
end