X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/c24c2e481cc6d27e76274ed4e32668a4690a7788..4d2ea315168b8cdbb6b00e0c9bf3d9da30566f5f:/lib/locale.rb diff --git a/lib/locale.rb b/lib/locale.rb index b0ad20fc7..56d398576 100644 --- a/lib/locale.rb +++ b/lib/locale.rb @@ -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