diff --git a/Library/Homebrew/locale.rb b/Library/Homebrew/locale.rb index eefbc464f8..40647ea62c 100644 --- a/Library/Homebrew/locale.rb +++ b/Library/Homebrew/locale.rb @@ -47,12 +47,12 @@ class Locale return if (sep && scanner.eos?) || (sep.nil? && !scanner.eos?) end - if (region = scanner.scan(REGION_REGEX)) + if (script = scanner.scan(SCRIPT_REGEX)) sep = scanner.scan(/-/) return if (sep && scanner.eos?) || (sep.nil? && !scanner.eos?) end - script = scanner.scan(SCRIPT_REGEX) + region = scanner.scan(REGION_REGEX) return unless scanner.eos? diff --git a/Library/Homebrew/test/locale_spec.rb b/Library/Homebrew/test/locale_spec.rb index e704fe87b0..3b627c7705 100644 --- a/Library/Homebrew/test/locale_spec.rb +++ b/Library/Homebrew/test/locale_spec.rb @@ -9,7 +9,7 @@ describe Locale do expect(described_class.parse("zh")).to eql(described_class.new("zh", nil, nil)) expect(described_class.parse("zh-CN")).to eql(described_class.new("zh", "CN", nil)) expect(described_class.parse("zh-Hans")).to eql(described_class.new("zh", nil, "Hans")) - expect(described_class.parse("zh-CN-Hans")).to eql(described_class.new("zh", "CN", "Hans")) + expect(described_class.parse("zh-Hans-CN")).to eql(described_class.new("zh", "CN", "Hans")) end it "correctly parses a string with a UN M.49 region code" do @@ -22,6 +22,7 @@ describe Locale do end it "a string in a wrong format" do + expect { described_class.parse("zh-CN-Hans") }.to raise_error(Locale::ParserError) expect { described_class.parse("zh_CN_Hans") }.to raise_error(Locale::ParserError) expect { described_class.parse("zhCNHans") }.to raise_error(Locale::ParserError) expect { described_class.parse("zh-CN_Hans") }.to raise_error(Locale::ParserError) @@ -52,16 +53,16 @@ describe Locale do it { is_expected.to include("zh") } it { is_expected.to include("zh-CN") } it { is_expected.to include("CN") } - it { is_expected.to include("CN-Hans") } + it { is_expected.to include("Hans-CN") } it { is_expected.to include("Hans") } - it { is_expected.to include("zh-CN-Hans") } + it { is_expected.to include("zh-Hans-CN") } end describe "#eql?" do subject(:locale) { described_class.new("zh", "CN", "Hans") } context "when all parts match" do - it { is_expected.to eql("zh-CN-Hans") } + it { is_expected.to eql("zh-Hans-CN") } it { is_expected.to eql(locale) } end @@ -69,7 +70,7 @@ describe Locale do it { is_expected.not_to eql("zh") } it { is_expected.not_to eql("zh-CN") } it { is_expected.not_to eql("CN") } - it { is_expected.not_to eql("CN-Hans") } + it { is_expected.not_to eql("Hans-CN") } it { is_expected.not_to eql("Hans") } end diff --git a/docs/Cask-Cookbook.md b/docs/Cask-Cookbook.md index c096a442fc..3d6acb1fb1 100644 --- a/docs/Cask-Cookbook.md +++ b/docs/Cask-Cookbook.md @@ -647,7 +647,7 @@ installer script: "#{staged_path}/install.sh" ### Stanza: `language` -The `language` stanza can match [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) language codes, regional identifiers ([ISO 3166-1 Alpha 2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)) and script codes ([ISO 15924](https://en.wikipedia.org/wiki/ISO_15924)), or a combination thereof. +The `language` stanza can match [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) language codes, script codes ([ISO 15924](https://en.wikipedia.org/wiki/ISO_15924)) and regional identifiers ([ISO 3166-1 Alpha 2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)), or a combination thereof. US English should always be used as the default language: