diff --git a/Library/Homebrew/cask/lib/hbc/dsl.rb b/Library/Homebrew/cask/lib/hbc/dsl.rb index 9d229e2880..652f37c193 100644 --- a/Library/Homebrew/cask/lib/hbc/dsl.rb +++ b/Library/Homebrew/cask/lib/hbc/dsl.rb @@ -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? diff --git a/Library/Homebrew/locale.rb b/Library/Homebrew/locale.rb index c430d11b64..38860403fe 100644 --- a/Library/Homebrew/locale.rb +++ b/Library/Homebrew/locale.rb @@ -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