Skip to content

Commit

Permalink
Fix follow recommendation moderation page default language when using…
Browse files Browse the repository at this point in the history
… regional variant (mastodon#32580)
  • Loading branch information
ClearlyClaire authored Oct 18, 2024
1 parent 8eae0d0 commit 2391937
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion app/models/follow_recommendation_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class FollowRecommendationFilter
attr_reader :params, :language

def initialize(params)
@language = params.delete('language') || I18n.locale
@language = usable_language(params.delete('language') || I18n.locale)
@params = params
end

Expand All @@ -22,4 +22,15 @@ def results
Account.includes(:account_stat).joins(:follow_recommendation).merge(FollowRecommendation.localized(@language).order(rank: :desc))
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

0 comments on commit 2391937

Please sign in to comment.