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

@ -13,7 +13,7 @@ module BrowseHelper
unless object.redacted?
available_locales = Locale.list(name_locales(object))
locale = available_locales.preferred(preferred_languages)
locale = available_locales.preferred(preferred_languages, :default => nil)
if object.tags.include? "name:#{locale}"
name = t "printable_name.with_name_html", :name => tag.bdi(object.tags["name:#{locale}"].to_s), :id => tag.bdi(name)

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