mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 19:36:22 +08:00
82d2284ce6
"I18n.t(key, locale: locale)" fails to find the correct translation in some cases. We should always wrap it with the "I18n.with_locale(locale)" method. Also, reverting an override wasn't always possible because the serializer always used "I18n.locale" as the locale.
24 lines
468 B
Ruby
24 lines
468 B
Ruby
# frozen_string_literal: true
|
|
|
|
class SiteTextSerializer < ApplicationSerializer
|
|
attributes :id, :value, :overridden?, :can_revert?
|
|
|
|
def id
|
|
object[:id]
|
|
end
|
|
|
|
def value
|
|
object[:value]
|
|
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
|