diff --git a/Library/Homebrew/cask/lib/hbc/dsl.rb b/Library/Homebrew/cask/lib/hbc/dsl.rb index a1129a21aeeb1f5b562db5db3f40a2d29919a0ad..8e0a7715af427c6a49a88f5220bcf614fe892208 100644 --- a/Library/Homebrew/cask/lib/hbc/dsl.rb +++ b/Library/Homebrew/cask/lib/hbc/dsl.rb @@ -114,22 +114,25 @@ module Hbc @language_blocks.default = block else language_eval - @language end end def language_eval - return if instance_variable_defined?(:@language) + return @language if instance_variable_defined?(:@language) - return unless instance_variable_defined?(:@language_blocks) + if @language_blocks.nil? || @language_blocks.empty? + return @language = nil + end - MacOS.languages.map(&Locale.method(:parse)).any? { |locale| + MacOS.languages.map(&Locale.method(:parse)).each do |locale| key = @language_blocks.keys.detect { |strings| strings.any? { |string| locale.include?(string) } } - return @language = @language_blocks[key].call unless key.nil? - } + next if key.nil? + + return @language = @language_blocks[key].call + end @language = @language_blocks.default.call end