mirror of
https://github.com/discourse/discourse.git
synced 2024-12-24 19:03:49 +08:00
341acacba8
Recently we started giving admins a notice in the advice panel when their translations have become outdated due to changes in core. However, we didn't include any additional information. This PR adds more information about the outdated translation inside the site text edit page, together with an option to dismiss the warning.
62 lines
1.1 KiB
Ruby
62 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class SiteTextSerializer < ApplicationSerializer
|
|
attributes :id,
|
|
:value,
|
|
:status,
|
|
:old_default,
|
|
:new_default,
|
|
:interpolation_keys,
|
|
:has_interpolation_keys?,
|
|
:overridden?,
|
|
:can_revert?
|
|
|
|
def id
|
|
object[:id]
|
|
end
|
|
|
|
def value
|
|
object[:value]
|
|
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?
|
|
if options[:overridden_keys]
|
|
options[:overridden_keys].include?(object[:id])
|
|
else
|
|
override.present?
|
|
end
|
|
end
|
|
|
|
alias_method :can_revert?, :overridden?
|
|
|
|
private
|
|
|
|
def override
|
|
TranslationOverride.find_by(locale: object[:locale], translation_key: object[:id])
|
|
end
|
|
end
|