mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 00:43:24 +08:00
6fc62586a2
This is the first of a number of PRs aimed at helping admins manage their translation overrides. It simply adds a list of available interpolation keys below the input field when editing an override. It also includes custom interpolation key.
32 lines
657 B
Ruby
32 lines
657 B
Ruby
# frozen_string_literal: true
|
|
|
|
class SiteTextSerializer < ApplicationSerializer
|
|
attributes :id, :value, :interpolation_keys, :has_interpolation_keys?, :overridden?, :can_revert?
|
|
|
|
def id
|
|
object[:id]
|
|
end
|
|
|
|
def value
|
|
object[:value]
|
|
end
|
|
|
|
def interpolation_keys
|
|
object[:interpolation_keys]
|
|
end
|
|
|
|
def has_interpolation_keys?
|
|
object[:interpolation_keys].present?
|
|
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
|