Fix follow recommendation moderation page default language when using regional variant (#32580)
parent
044dd3f788
commit
d728fa9991
|
@ -11,7 +11,7 @@ class FollowRecommendationFilter
|
||||||
attr_reader :params, :language
|
attr_reader :params, :language
|
||||||
|
|
||||||
def initialize(params)
|
def initialize(params)
|
||||||
@language = params.delete('language') || I18n.locale
|
@language = usable_language(params.delete('language') || I18n.locale)
|
||||||
@params = params
|
@params = params
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -22,4 +22,15 @@ class FollowRecommendationFilter
|
||||||
Account.includes(:account_stat).joins(:follow_recommendation).merge(FollowRecommendation.localized(@language).order(rank: :desc))
|
Account.includes(:account_stat).joins(:follow_recommendation).merge(FollowRecommendation.localized(@language).order(rank: :desc))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def usable_language(locale)
|
||||||
|
return locale if Trends.available_locales.include?(locale)
|
||||||
|
|
||||||
|
locale = locale.to_s.split(/[_-]/).first
|
||||||
|
return locale if Trends.available_locales.include?(locale)
|
||||||
|
|
||||||
|
nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue