discourse/app/serializers/site_text_serializer.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

62 lines
1.1 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
2014-09-24 13:45:35 -05:00
class SiteTextSerializer < ApplicationSerializer
attributes :id,
:value,
:status,
:old_default,
:new_default,
:interpolation_keys,
:has_interpolation_keys?,
:overridden?,
:can_revert?
2014-09-24 13:45:35 -05:00
def id
object[:id]
2014-09-24 13:45:35 -05:00
end
def value
object[:value]
2014-09-24 13:45:35 -05:00
end
def status
if override.present?
override.status
else
"up_to_date"
end
end
def old_default
override.original_translation if override.present?
end
def new_default
override.current_default if override.present?
end
def interpolation_keys
object[:interpolation_keys]
end
def has_interpolation_keys?
object[:interpolation_keys].present?
end
def overridden?
2019-07-01 20:53:16 -05:00
if options[:overridden_keys]
options[:overridden_keys].include?(object[:id])
else
override.present?
end
2014-09-24 13:45:35 -05:00
end
alias_method :can_revert?, :overridden?
private
def override
TranslationOverride.find_by(locale: object[:locale], translation_key: object[:id])
end
2014-09-24 13:45:35 -05:00
end