Don't fall back to name:en if it's not in the user's language list

Fix to #2755
This commit is contained in:
Tom Hughes 2020-08-06 14:21:30 +01:00
parent c24c2e481c
commit 4d2ea31516
2 changed files with 4 additions and 4 deletions

View file

@ -10,8 +10,8 @@ class Locale < I18n::Locale::Tag::Rfc4646
preferred.expand & self
end
def preferred(preferred)
candidates(preferred).first
def preferred(preferred, options = { :default => Locale.default })
candidates(preferred).first || options[:default]
end
def expand
@ -19,7 +19,7 @@ class Locale < I18n::Locale::Tag::Rfc4646
locale.candidates.uniq.reverse_each do |candidate|
expanded << candidate if candidate == locale || !expanded.include?(candidate)
end
end.reverse.uniq << Locale.default)
end.reverse.uniq)
end
end