worldwide 1.14.3 → 1.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -1
- data/Gemfile.lock +1 -1
- data/data/cldr/paths.txt +4582 -0
- data/data/other/paths.txt +1529 -0
- data/data/regions/BV.yml +1 -1
- data/data/regions/FI.yml +1 -1
- data/data/regions/IE.yml +0 -1
- data/data/regions/paths.txt +1980 -0
- data/lib/worldwide/cldr/fallbacks.rb +15 -1
- data/lib/worldwide/config.rb +3 -3
- data/lib/worldwide/paths.rb +6 -0
- data/lib/worldwide/region.rb +17 -3
- data/lib/worldwide/regions_loader.rb +1 -0
- data/lib/worldwide/version.rb +1 -1
- metadata +5 -2
@@ -16,7 +16,8 @@ module Worldwide
|
|
16
16
|
|
17
17
|
def descendants(locale)
|
18
18
|
compute_all_ancestors
|
19
|
-
|
19
|
+
compute_all_descendants
|
20
|
+
@all_descendants[locale.to_sym] || []
|
20
21
|
end
|
21
22
|
|
22
23
|
def defined_parent_locales
|
@@ -57,6 +58,19 @@ module Worldwide
|
|
57
58
|
|
58
59
|
@all_ancestors_computed = true
|
59
60
|
end
|
61
|
+
|
62
|
+
def compute_all_descendants
|
63
|
+
return if @all_descendants
|
64
|
+
|
65
|
+
@all_descendants = {}
|
66
|
+
|
67
|
+
each do |locale, ancestors|
|
68
|
+
ancestors.each do |ancestor|
|
69
|
+
@all_descendants[ancestor] ||= []
|
70
|
+
@all_descendants[ancestor] << locale
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
60
74
|
end
|
61
75
|
end
|
62
76
|
end
|
data/lib/worldwide/config.rb
CHANGED
@@ -106,7 +106,7 @@ module Worldwide
|
|
106
106
|
end
|
107
107
|
|
108
108
|
def cldr_locale_paths(locale_set, components)
|
109
|
-
|
109
|
+
Paths::CLDR_LOCALE_PATHS.select do |path|
|
110
110
|
match = path.match(CLDR_LOCALE_PATH_REGEX)
|
111
111
|
match && locale_set.include?(match[:locale]) && components.include?(match[:component])
|
112
112
|
end
|
@@ -119,14 +119,14 @@ module Worldwide
|
|
119
119
|
end
|
120
120
|
|
121
121
|
def other_data_path(locale_set)
|
122
|
-
|
122
|
+
Paths::OTHER_DATA_PATHS.select do |path|
|
123
123
|
match = path.match(OTHER_LOCALE_PATH_REGEX)
|
124
124
|
match && locale_set.include?(match[:locale])
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
128
128
|
def regions_data_path(locale_set)
|
129
|
-
|
129
|
+
Paths::REGION_DATA_PATHS.select do |path|
|
130
130
|
match = path.match(REGIONS_LOCALE_PATH_REGEX)
|
131
131
|
match && locale_set.include?(match[:locale])
|
132
132
|
end
|
data/lib/worldwide/paths.rb
CHANGED
@@ -5,10 +5,16 @@ module Worldwide
|
|
5
5
|
GEM_ROOT = File.expand_path(File.join(__dir__, "../.."))
|
6
6
|
DATA_ROOT = File.join(GEM_ROOT, "data")
|
7
7
|
CLDR_ROOT = File.join(GEM_ROOT, "data/cldr")
|
8
|
+
CLDR_LOCALE_PATHS_FILE = File.join(CLDR_ROOT, "paths.txt")
|
9
|
+
CLDR_LOCALE_PATHS = File.read(CLDR_LOCALE_PATHS_FILE).lines.map { |path| File.join(GEM_ROOT, path.strip) }
|
8
10
|
OTHER_DATA_ROOT = File.join(GEM_ROOT, "data/other")
|
11
|
+
OTHER_DATA_PATHS_FILE = File.join(OTHER_DATA_ROOT, "paths.txt")
|
12
|
+
OTHER_DATA_PATHS = File.read(OTHER_DATA_PATHS_FILE).lines.map { |path| File.join(GEM_ROOT, path.strip) }
|
9
13
|
CURRENCY_MAPPINGS = File.join(OTHER_DATA_ROOT, "currency/mappings")
|
10
14
|
GENERATED_LOCALE_ROOT = File.join(OTHER_DATA_ROOT, "generated")
|
11
15
|
REGIONS_ROOT = File.join(DATA_ROOT, "regions")
|
16
|
+
REGION_DATA_PATHS_FILE = File.join(REGIONS_ROOT, "paths.txt")
|
17
|
+
REGION_DATA_PATHS = File.read(REGION_DATA_PATHS_FILE).lines.map { |path| File.join(GEM_ROOT, path.strip) }
|
12
18
|
TIME_ZONE_ROOT = File.join(OTHER_DATA_ROOT, "timezones")
|
13
19
|
end
|
14
20
|
end
|
data/lib/worldwide/region.rb
CHANGED
@@ -163,6 +163,9 @@ module Worldwide
|
|
163
163
|
# Note that this should really be translated; showing this untranslated name to users is a bad idea.
|
164
164
|
attr_reader :tax_name
|
165
165
|
|
166
|
+
# Whether the region uses tax-inclusive pricing.
|
167
|
+
attr_accessor :tax_inclusive
|
168
|
+
|
166
169
|
# "generic" VAT tax rate on "most" goods
|
167
170
|
attr_reader :tax_rate
|
168
171
|
|
@@ -198,7 +201,7 @@ module Worldwide
|
|
198
201
|
attr_accessor :zip_example
|
199
202
|
|
200
203
|
# Is a zip value required in this region? (Possible values: "optional", "recommended", "required")
|
201
|
-
|
204
|
+
attr_writer :zip_requirement
|
202
205
|
|
203
206
|
# A list of character sequences with which a postal code in this region may start.
|
204
207
|
attr_accessor :zip_prefixes
|
@@ -276,6 +279,7 @@ module Worldwide
|
|
276
279
|
@partial_zip_regex = nil
|
277
280
|
@phone_number_prefix = nil
|
278
281
|
@tags = []
|
282
|
+
@tax_inclusive = false
|
279
283
|
@timezone = nil
|
280
284
|
@timezones = {}
|
281
285
|
@unit_system = nil
|
@@ -435,13 +439,23 @@ module Worldwide
|
|
435
439
|
|
436
440
|
# is a postal code required for this region?
|
437
441
|
def zip_required?
|
438
|
-
if zip_requirement.nil?
|
442
|
+
if @zip_requirement.nil?
|
439
443
|
!zip_regex.nil?
|
440
444
|
else
|
441
|
-
REQUIRED == zip_requirement
|
445
|
+
REQUIRED == @zip_requirement
|
442
446
|
end
|
443
447
|
end
|
444
448
|
|
449
|
+
# Returns whether (and how firmly) we require a value in the zip field
|
450
|
+
# Possible returns:
|
451
|
+
# - "required" means a value must be supplied
|
452
|
+
# - "recommended" means a value is optional, but we recommend providing one
|
453
|
+
# - "optional" means a value is optional, and we say it is optional
|
454
|
+
# @return [String]
|
455
|
+
def zip_requirement
|
456
|
+
@zip_requirement || (zip_required? ? REQUIRED : OPTIONAL)
|
457
|
+
end
|
458
|
+
|
445
459
|
# is a neighborhood required for this region?
|
446
460
|
def neighborhood_required?
|
447
461
|
additional_field_required?("neighborhood")
|
@@ -114,6 +114,7 @@ module Worldwide
|
|
114
114
|
region.partial_zip_regex = spec["partial_zip_regex"]
|
115
115
|
region.phone_number_prefix = spec["phone_number_prefix"]
|
116
116
|
region.tags = spec["tags"] || []
|
117
|
+
region.tax_inclusive = spec["tax_inclusive"] || false
|
117
118
|
region.timezone = spec["timezone"]
|
118
119
|
region.timezones = spec["timezones"] || {}
|
119
120
|
region.week_start_day = spec["week_start_day"] || "sunday"
|
data/lib/worldwide/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: worldwide
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-12-
|
11
|
+
date: 2024-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -4671,6 +4671,7 @@ files:
|
|
4671
4671
|
- data/cldr/metazones.yml
|
4672
4672
|
- data/cldr/numbering_systems.yml
|
4673
4673
|
- data/cldr/parent_locales.yml
|
4674
|
+
- data/cldr/paths.txt
|
4674
4675
|
- data/cldr/rbnf_root.yml
|
4675
4676
|
- data/cldr/region_currencies.yml
|
4676
4677
|
- data/cldr/region_validity.yml
|
@@ -6119,6 +6120,7 @@ files:
|
|
6119
6120
|
- data/other/names/vi.yml
|
6120
6121
|
- data/other/names/zh-CN.yml
|
6121
6122
|
- data/other/names/zh-TW.yml
|
6123
|
+
- data/other/paths.txt
|
6122
6124
|
- data/other/territories/bg.yml
|
6123
6125
|
- data/other/territories/cs.yml
|
6124
6126
|
- data/other/territories/da.yml
|
@@ -8438,6 +8440,7 @@ files:
|
|
8438
8440
|
- data/regions/_default/vi.yml
|
8439
8441
|
- data/regions/_default/zh-CN.yml
|
8440
8442
|
- data/regions/_default/zh-TW.yml
|
8443
|
+
- data/regions/paths.txt
|
8441
8444
|
- data/top_locales.yml
|
8442
8445
|
- data/world.yml
|
8443
8446
|
- docs/address_format_strings.md
|