cask --language: have specific match always trump general

This commit is contained in:
Vítor Galvão 2018-05-28 15:01:58 +01:00
parent e954bedc5f
commit dc1edf6bfc
2 changed files with 6 additions and 3 deletions

View File

@ -134,9 +134,7 @@ module Hbc
end
MacOS.languages.map(&Locale.method(:parse)).each do |locale|
key = @language_blocks.keys.detect do |strings|
strings.any? { |string| locale.include?(string) }
end
key = locale.detect(@language_blocks.keys)
next if key.nil?

View File

@ -68,6 +68,11 @@ class Locale
end
alias == eql?
def detect(locale_groups)
locale_groups.detect { |locales| locales.any? { |locale| eql?(locale) } } ||
locale_groups.detect { |locales| locales.any? { |locale| include?(locale) } }
end
def to_s
[@language, @region, @script].compact.join("-")
end