worldwide 0.14.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci-typescript.yml +32 -0
- data/.github/workflows/npm-release.yml +38 -0
- data/.vscode/settings.json +8 -0
- data/CHANGELOG.md +12 -1
- data/Gemfile.lock +1 -1
- data/db/data/regions/BE.yml +5 -2
- data/db/data/regions/BR.yml +7 -4
- data/db/data/regions/CL/en.yml +1 -1
- data/db/data/regions/CL.yml +7 -4
- data/db/data/regions/CO.yml +3 -2
- data/db/data/regions/ES.yml +5 -2
- data/db/data/regions/ID.yml +3 -2
- data/db/data/regions/IL.yml +5 -2
- data/db/data/regions/MX/en.yml +20 -0
- data/db/data/regions/MX.yml +7 -4
- data/db/data/regions/NL.yml +5 -2
- data/db/data/regions/PH/en.yml +25 -0
- data/db/data/regions/PH.yml +4 -2
- data/db/data/regions/TR/en.yml +1 -1
- data/db/data/regions/TR.yml +4 -2
- data/db/data/regions/TW/en.yml +1 -1
- data/db/data/regions/TW.yml +8 -0
- data/db/data/regions/VN/en.yml +1 -1
- data/db/data/regions/VN.yml +4 -2
- data/db/data/regions/_default/cs.yml +27 -2
- data/db/data/regions/_default/da.yml +25 -1
- data/db/data/regions/_default/el.yml +28 -1
- data/db/data/regions/_default/es.yml +29 -1
- data/db/data/regions/_default/fi.yml +25 -1
- data/db/data/regions/_default/fr.yml +28 -1
- data/db/data/regions/_default/hi.yml +25 -1
- data/db/data/regions/_default/hu.yml +28 -2
- data/db/data/regions/_default/id.yml +26 -1
- data/db/data/regions/_default/ja.yml +20 -1
- data/db/data/regions/_default/lt.yml +28 -1
- data/db/data/regions/_default/ms.yml +26 -1
- data/db/data/regions/_default/pt-BR.yml +26 -1
- data/db/data/regions/_default/ro.yml +26 -1
- data/db/data/regions/_default/ru.yml +25 -1
- data/db/data/regions/_default/sk.yml +25 -1
- data/db/data/regions/_default/sl.yml +27 -1
- data/db/data/regions/_default/sv.yml +25 -1
- data/db/data/regions/_default/th.yml +24 -1
- data/db/data/regions/_default/tr.yml +24 -1
- data/db/data/regions/_default/vi.yml +24 -1
- data/db/data/regions/_default/zh-CN.yml +20 -1
- data/db/data/regions/_default/zh-TW.yml +20 -1
- data/lib/worldwide/address.rb +4 -4
- data/lib/worldwide/region.rb +27 -2
- data/lib/worldwide/regions_loader.rb +2 -1
- data/lib/worldwide/version.rb +1 -1
- data/worldwide.gemspec +1 -1
- metadata +6 -2
@@ -208,7 +208,7 @@ vi:
|
|
208
208
|
optional: Khu phố (không bắt buộc)
|
209
209
|
errors:
|
210
210
|
blank: Nhập khu phố
|
211
|
-
too_long: Khu phố quá dài (tối đa
|
211
|
+
too_long: Khu phố quá dài (tối đa %{limit} ký tự)
|
212
212
|
contains_emojis: Khu phố không được chứa biểu tượng cảm xúc
|
213
213
|
contains_mathematical_symbols: Khu phố không được chứa ký hiệu toán học
|
214
214
|
contains_restricted_characters: Khu phố chỉ được chứa chữ cái, chữ số,
|
@@ -222,3 +222,26 @@ vi:
|
|
222
222
|
unknown_for_address: Khu phố có thể không chính xác.
|
223
223
|
warnings:
|
224
224
|
contains_too_many_words: Khu phố nên có tối đa %{word_count} từ
|
225
|
+
line2:
|
226
|
+
label:
|
227
|
+
default: Căn hộ, dãy, v.v.
|
228
|
+
optional: Căn hộ, dãy, v.v. (không bắt buộc)
|
229
|
+
errors:
|
230
|
+
blank: Nhập căn hộ, dãy, v.v.
|
231
|
+
too_long: Dòng địa chỉ thứ hai quá dài (tối đa %{limit} ký tự)
|
232
|
+
contains_emojis: Dòng địa chỉ thứ hai không được chứa biểu tượng cảm xúc
|
233
|
+
contains_mathematical_symbols: Dòng địa chỉ thứ hai không được chứa ký
|
234
|
+
hiệu toán học
|
235
|
+
contains_restricted_characters: Dòng địa chỉ thứ hai chỉ được chứa chữ
|
236
|
+
cái, chữ số, ký tự địa phương và ký tự đặc biệt
|
237
|
+
contains_too_many_words: Dòng địa chỉ thứ hai chỉ được có tối đa %{word_count}
|
238
|
+
từ
|
239
|
+
contains_html_tags: Dòng địa chỉ thứ hai không được chứa thẻ HTML.
|
240
|
+
contains_url: Dòng địa chỉ thứ hai không được chứa URL.
|
241
|
+
missing_building_number: Thêm số tòa nhà nếu có.
|
242
|
+
street_unknown_for_zip: Nhập tên đường hợp lệ cho %{zip}.
|
243
|
+
building_number_invalid: Không thể định vị số tòa nhà cho %{street}, %{zip}.
|
244
|
+
unknown_for_address: Dòng địa chỉ thứ hai có thể không chính xác.
|
245
|
+
warnings:
|
246
|
+
contains_too_many_words: Dòng địa chỉ thứ hai nên có tối đa %{word_count}
|
247
|
+
từ
|
@@ -186,7 +186,7 @@ zh-CN:
|
|
186
186
|
optional: 街区(选填)
|
187
187
|
errors:
|
188
188
|
blank: 输入街区
|
189
|
-
too_long:
|
189
|
+
too_long: 街区名过长(最多 %{limit} 个字符)
|
190
190
|
contains_emojis: 街区名不能包含表情符号
|
191
191
|
contains_mathematical_symbols: 街区名不能包含数学符号
|
192
192
|
contains_restricted_characters: 街区名只能包含字母、数字、当地字符和特殊字符
|
@@ -198,3 +198,22 @@ zh-CN:
|
|
198
198
|
unknown_for_address: 街区名可能不正确。
|
199
199
|
warnings:
|
200
200
|
contains_too_many_words: 建议街区名少于 %{word_count} 个字词
|
201
|
+
line2:
|
202
|
+
label:
|
203
|
+
default: 公寓、房间号等
|
204
|
+
optional: 公寓、房间号等(可选)
|
205
|
+
errors:
|
206
|
+
blank: 输入公寓、房间号等
|
207
|
+
too_long: 第二个地址行过长(最多 %{limit} 个字符)
|
208
|
+
contains_emojis: 第二个地址行不能包含表情符号
|
209
|
+
contains_mathematical_symbols: 第二个地址行不能包含数学符号
|
210
|
+
contains_restricted_characters: 第二个地址行只能包含字母、数字、当地字符和特殊字符
|
211
|
+
contains_too_many_words: 第二个地址行不能超过 %{word_count} 个字词
|
212
|
+
contains_html_tags: 第二个地址行不能包含 HTML 标记。
|
213
|
+
contains_url: 第二个地址行不能包含 URL。
|
214
|
+
missing_building_number: 添加大楼编号(如果有)。
|
215
|
+
street_unknown_for_zip: 输入 %{zip} 对应的有效街道名称。
|
216
|
+
building_number_invalid: 大楼编号与 %{street} 和 %{zip} 不匹配。
|
217
|
+
unknown_for_address: 第二个地址行可能不正确。
|
218
|
+
warnings:
|
219
|
+
contains_too_many_words: 建议第二个地址行少于 %{word_count} 个字词
|
@@ -186,7 +186,7 @@ zh-TW:
|
|
186
186
|
optional: 鄰 (選填)
|
187
187
|
errors:
|
188
188
|
blank: 請輸入「鄰」
|
189
|
-
too_long: "「鄰」過長 (最多
|
189
|
+
too_long: "「鄰」過長 (最多 %{limit} 個字元)"
|
190
190
|
contains_emojis: "「鄰」不得包含表情符號"
|
191
191
|
contains_mathematical_symbols: "「鄰」不得包含數學符號"
|
192
192
|
contains_restricted_characters: "「鄰」僅可包含字母、數字、當地字元和特殊字元"
|
@@ -198,3 +198,22 @@ zh-TW:
|
|
198
198
|
unknown_for_address: "「鄰」可能不正確。"
|
199
199
|
warnings:
|
200
200
|
contains_too_many_words: 建議「鄰」少於 %{word_count} 個字
|
201
|
+
line2:
|
202
|
+
label:
|
203
|
+
default: 公寓、套房等
|
204
|
+
optional: 公寓、套房等 (選填)
|
205
|
+
errors:
|
206
|
+
blank: 請輸入公寓、套房等
|
207
|
+
too_long: "「地址第二行」過長 (最多 %{limit} 個字元)"
|
208
|
+
contains_emojis: "「地址第二行」不得包含表情符號"
|
209
|
+
contains_mathematical_symbols: "「地址第二行」不得包含數學符號"
|
210
|
+
contains_restricted_characters: "「地址第二行」僅可包含字母、數字、當地字元和特殊字元"
|
211
|
+
contains_too_many_words: "「地址第二行」不得超過 %{word_count} 個字"
|
212
|
+
contains_html_tags: "「地址第二行」不得包含 HTML 標籤。"
|
213
|
+
contains_url: "「地址第二行」不得包含網址。"
|
214
|
+
missing_building_number: 如果您有建築物號碼,請新增建築物號碼。
|
215
|
+
street_unknown_for_zip: 請輸入 %{zip} 的有效街道名稱。
|
216
|
+
building_number_invalid: 在 %{zip},%{street} 找不到此建築物號碼。
|
217
|
+
unknown_for_address: "「地址第二行」可能並不正確。"
|
218
|
+
warnings:
|
219
|
+
contains_too_many_words: "「地址第二行」建議少於 %{word_count} 字"
|
data/lib/worldwide/address.rb
CHANGED
@@ -149,23 +149,23 @@ module Worldwide
|
|
149
149
|
def concatenated_address1
|
150
150
|
return address1 if address1.present?
|
151
151
|
|
152
|
-
additional_fields = region.
|
152
|
+
additional_fields = region.combined_address_format["address1"] || []
|
153
153
|
concatenate_fields(additional_fields)
|
154
154
|
end
|
155
155
|
|
156
156
|
def concatenated_address2
|
157
|
-
additional_fields = region.
|
157
|
+
additional_fields = region.combined_address_format["address2"] || []
|
158
158
|
concatenate_fields(additional_fields)
|
159
159
|
end
|
160
160
|
|
161
161
|
def split_address1
|
162
|
-
additional_fields = region.
|
162
|
+
additional_fields = region.combined_address_format["address1"] || []
|
163
163
|
split_fields_arr = address1&.split(RESERVED_DELIMITER) || []
|
164
164
|
split_fields(additional_fields, split_fields_arr)
|
165
165
|
end
|
166
166
|
|
167
167
|
def split_address2
|
168
|
-
additional_fields = region.
|
168
|
+
additional_fields = region.combined_address_format["address2"] || []
|
169
169
|
split_fields_arr = address2&.split(RESERVED_DELIMITER) || []
|
170
170
|
split_fields(additional_fields, split_fields_arr)
|
171
171
|
end
|
data/lib/worldwide/region.rb
CHANGED
@@ -34,6 +34,7 @@ module Worldwide
|
|
34
34
|
:zip_regex,
|
35
35
|
:zip_requirement,
|
36
36
|
:additional_address_fields,
|
37
|
+
:combined_address_format,
|
37
38
|
]
|
38
39
|
|
39
40
|
# A region may have more than one parent.
|
@@ -197,9 +198,12 @@ module Worldwide
|
|
197
198
|
# If true, then the province is optional for addresses in this region.
|
198
199
|
attr_accessor :province_optional
|
199
200
|
|
200
|
-
#
|
201
|
+
# An array of the additional address fields that are defined for this region
|
201
202
|
attr_accessor :additional_address_fields
|
202
203
|
|
204
|
+
# A hash of the rules for concatening the additional address fields into the standard fields
|
205
|
+
attr_accessor :combined_address_format
|
206
|
+
|
203
207
|
def initialize(
|
204
208
|
alpha_three: nil,
|
205
209
|
continent: false,
|
@@ -235,7 +239,8 @@ module Worldwide
|
|
235
239
|
@tax_rate = tax_rate
|
236
240
|
@use_zone_code_as_short_name = use_zone_code_as_short_name
|
237
241
|
|
238
|
-
@additional_address_fields =
|
242
|
+
@additional_address_fields = []
|
243
|
+
@combined_address_format = {}
|
239
244
|
@building_number_required = false
|
240
245
|
@building_number_may_be_in_address2 = false
|
241
246
|
@currency = nil
|
@@ -414,6 +419,21 @@ module Worldwide
|
|
414
419
|
end
|
415
420
|
end
|
416
421
|
|
422
|
+
# is a neighborhood required for this region?
|
423
|
+
def neighborhood_required?
|
424
|
+
additional_field_required?("neighborhood")
|
425
|
+
end
|
426
|
+
|
427
|
+
# is a street name required for this region?
|
428
|
+
def street_name_required?
|
429
|
+
additional_field_required?("streetName")
|
430
|
+
end
|
431
|
+
|
432
|
+
# is a street number required for this region?
|
433
|
+
def street_number_required?
|
434
|
+
additional_field_required?("streetNumber")
|
435
|
+
end
|
436
|
+
|
417
437
|
# is the given postal code value valid for this region?
|
418
438
|
def valid_zip?(zip, partial_match: false)
|
419
439
|
normalized = Zip.normalize(
|
@@ -441,6 +461,11 @@ module Worldwide
|
|
441
461
|
end
|
442
462
|
end
|
443
463
|
|
464
|
+
def additional_field_required?(field_name)
|
465
|
+
field = additional_address_fields.find { |f| f["name"] == field_name }
|
466
|
+
field ? !!field["required"] : false
|
467
|
+
end
|
468
|
+
|
444
469
|
def answers_to_cldr_code(search_code)
|
445
470
|
return false if Util.blank?(search_code) || Util.blank?(cldr_code)
|
446
471
|
return true if search_code.casecmp(cldr_code).zero?
|
@@ -95,7 +95,8 @@ module Worldwide
|
|
95
95
|
end
|
96
96
|
|
97
97
|
def apply_territory_attributes(region, spec)
|
98
|
-
region.additional_address_fields = spec["additional_address_fields"] ||
|
98
|
+
region.additional_address_fields = spec["additional_address_fields"] || []
|
99
|
+
region.combined_address_format = spec["combined_address_format"] || {}
|
99
100
|
region.building_number_required = spec["building_number_required"] || false
|
100
101
|
region.building_number_may_be_in_address2 = spec["building_number_may_be_in_address2"] || false
|
101
102
|
currency_code = spec["currency"]
|
data/lib/worldwide/version.rb
CHANGED
data/worldwide.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.metadata["changelog_uri"] = "https://github.com/Shopify/worldwide/blob/main/CHANGELOG.md"
|
19
19
|
|
20
20
|
spec.files = %x(git ls-files -z).split("\x0").reject do |f|
|
21
|
-
f.match(%r{^(rake|test|spec|features)/})
|
21
|
+
f.match(%r{^(rake|test|spec|features|lang/typescript)/})
|
22
22
|
end
|
23
23
|
spec.bindir = "exe"
|
24
24
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
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: 0.
|
4
|
+
version: 1.0.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-05-
|
11
|
+
date: 2024-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -64,11 +64,14 @@ files:
|
|
64
64
|
- ".github/CONTRIBUTING.md"
|
65
65
|
- ".github/dependabot.yml"
|
66
66
|
- ".github/pull_request_template.md"
|
67
|
+
- ".github/workflows/ci-typescript.yml"
|
67
68
|
- ".github/workflows/ci.yml"
|
68
69
|
- ".github/workflows/cla.yml"
|
70
|
+
- ".github/workflows/npm-release.yml"
|
69
71
|
- ".gitignore"
|
70
72
|
- ".rubocop.yml"
|
71
73
|
- ".ruby-version"
|
74
|
+
- ".vscode/settings.json"
|
72
75
|
- CHANGELOG.md
|
73
76
|
- Gemfile
|
74
77
|
- Gemfile.lock
|
@@ -7703,6 +7706,7 @@ files:
|
|
7703
7706
|
- db/data/regions/PF.yml
|
7704
7707
|
- db/data/regions/PG.yml
|
7705
7708
|
- db/data/regions/PH.yml
|
7709
|
+
- db/data/regions/PH/en.yml
|
7706
7710
|
- db/data/regions/PK.yml
|
7707
7711
|
- db/data/regions/PL.yml
|
7708
7712
|
- db/data/regions/PM.yml
|