X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/293fe68eff1923a00992e0a195ba025ab7bd9efa..4a38b3eea4bc36dcbcf625e46689688f3b5b12e2:/lib/locale.rb?ds=inline diff --git a/lib/locale.rb b/lib/locale.rb index b0ad20fc7..5931301b5 100644 --- a/lib/locale.rb +++ b/lib/locale.rb @@ -10,16 +10,16 @@ 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 List.new(reverse.each_with_object([]) do |locale, expanded| locale.candidates.uniq.reverse_each do |candidate| - expanded << candidate if candidate == locale || !expanded.include?(candidate) + expanded << candidate if candidate == locale || expanded.exclude?(candidate) end - end.reverse.uniq << Locale.default) + end.reverse.uniq) end end