From dc1edf6bfc067fd1f4c9990a68b3763d00a29bfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Galv=C3=A3o?= Date: Mon, 28 May 2018 15:01:58 +0100 Subject: [PATCH] cask --language: have specific match always trump general --- Library/Homebrew/cask/lib/hbc/dsl.rb | 4 +--- Library/Homebrew/locale.rb | 5 +++++ 2 files changed, 6 insertions(+), 3 deletions(-) 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