mirror of
https://github.com/discourse/discourse.git
synced 2025-06-23 02:31:33 +08:00

Currently, this is the order of i18n translate function: 1. Translation in required language; 2. Optional `defaultValue` provided; 3. Fallback to forum default language. When admin set language as English GB, translation was not correctly displayed as it went to step 2 and displayed `defaultValue` instead of correct translation from default language.
56 lines
1.2 KiB
Ruby
56 lines
1.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class FlagSerializer < ApplicationSerializer
|
|
attributes :id,
|
|
:name,
|
|
:name_key,
|
|
:description,
|
|
:short_description,
|
|
:applies_to,
|
|
:position,
|
|
:require_message,
|
|
:enabled,
|
|
:is_flag,
|
|
:applies_to,
|
|
:is_used,
|
|
:auto_action_type,
|
|
:system
|
|
|
|
def i18n_prefix
|
|
"#{@options[:target] || "post_action"}_types.#{object.name_key}"
|
|
end
|
|
|
|
def name
|
|
# system flags are using i18n translations when custom flags are using value entered by admin
|
|
I18n.t("#{i18n_prefix}.title", default: object.name)
|
|
end
|
|
|
|
def description
|
|
I18n.t(
|
|
"#{i18n_prefix}.description",
|
|
default: object.description.to_s,
|
|
base_path: Discourse.base_path,
|
|
)
|
|
end
|
|
|
|
def short_description
|
|
I18n.t("#{i18n_prefix}.short_description", base_path: Discourse.base_path, default: "")
|
|
end
|
|
|
|
def is_flag
|
|
!object.score_type && object.id != PostActionType::LIKE_POST_ACTION_ID
|
|
end
|
|
|
|
def is_used
|
|
@options[:used_flag_ids].include?(object.id)
|
|
end
|
|
|
|
def applies_to
|
|
Array.wrap(object.applies_to)
|
|
end
|
|
|
|
def system
|
|
object.system?
|
|
end
|
|
end
|