diff options
| author | Markus Reiter | 2017-09-29 11:37:44 +0200 |
|---|---|---|
| committer | Markus Reiter | 2017-09-29 11:41:23 +0200 |
| commit | 479544665b9e6edf66c7add1eb6b3c98d98de384 (patch) | |
| tree | 2cbf58872278d8008899bd3b814d28785d509884 /Library | |
| parent | 06b9ab558606cc186f5450c451cf77a196a3ffcc (diff) | |
| download | brew-479544665b9e6edf66c7add1eb6b3c98d98de384.tar.bz2 | |
Support UN M.49 region codes.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/locale.rb | 6 | ||||
| -rw-r--r-- | Library/Homebrew/test/locale_spec.rb | 4 |
2 files changed, 7 insertions, 3 deletions
diff --git a/Library/Homebrew/locale.rb b/Library/Homebrew/locale.rb index d918e2a2a..c430d11b6 100644 --- a/Library/Homebrew/locale.rb +++ b/Library/Homebrew/locale.rb @@ -2,9 +2,9 @@ class Locale class ParserError < StandardError end - LANGUAGE_REGEX = /(?:[a-z]{2,3})/ # ISO 639-1 or ISO 639-2 - REGION_REGEX = /(?:[A-Z]{2})/ # ISO 3166-1 - SCRIPT_REGEX = /(?:[A-Z][a-z]{3})/ # ISO 15924 + LANGUAGE_REGEX = /(?:[a-z]{2,3})/ # ISO 639-1 or ISO 639-2 + REGION_REGEX = /(?:[A-Z]{2}|\d{3})/ # ISO 3166-1 or UN M.49 + SCRIPT_REGEX = /(?:[A-Z][a-z]{3})/ # ISO 15924 LOCALE_REGEX = /\A((?:#{LANGUAGE_REGEX}|#{REGION_REGEX}|#{SCRIPT_REGEX})(?:\-|$)){1,3}\Z/ diff --git a/Library/Homebrew/test/locale_spec.rb b/Library/Homebrew/test/locale_spec.rb index 9e4d09e83..9c684f0e7 100644 --- a/Library/Homebrew/test/locale_spec.rb +++ b/Library/Homebrew/test/locale_spec.rb @@ -9,6 +9,10 @@ describe Locale do expect(described_class.parse("zh-CN-Hans")).to eql(described_class.new("zh", "CN", "Hans")) end + it "correctly parses a string with a UN M.49 region code" do + expect(described_class.parse("es-419")).to eql(described_class.new("es", "419", nil)) + end + context "raises a ParserError when given" do it "an empty string" do expect { described_class.parse("") }.to raise_error(Locale::ParserError) |
