mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 15:28:37 +08:00
DEV: Add endpoint for dismissing outdated translations (#22509)
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.
This commit is contained in:
@ -1,7 +1,15 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class SiteTextSerializer < ApplicationSerializer
|
||||
attributes :id, :value, :interpolation_keys, :has_interpolation_keys?, :overridden?, :can_revert?
|
||||
attributes :id,
|
||||
:value,
|
||||
:status,
|
||||
:old_default,
|
||||
:new_default,
|
||||
:interpolation_keys,
|
||||
:has_interpolation_keys?,
|
||||
:overridden?,
|
||||
:can_revert?
|
||||
|
||||
def id
|
||||
object[:id]
|
||||
@ -11,6 +19,22 @@ class SiteTextSerializer < ApplicationSerializer
|
||||
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
|
||||
@ -23,9 +47,15 @@ class SiteTextSerializer < ApplicationSerializer
|
||||
if options[:overridden_keys]
|
||||
options[:overridden_keys].include?(object[:id])
|
||||
else
|
||||
TranslationOverride.exists?(locale: object[:locale], translation_key: object[:id])
|
||||
override.present?
|
||||
end
|
||||
end
|
||||
|
||||
alias_method :can_revert?, :overridden?
|
||||
|
||||
private
|
||||
|
||||
def override
|
||||
TranslationOverride.find_by(locale: object[:locale], translation_key: object[:id])
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user