worldwide 1.1.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +13 -0
  3. data/Gemfile.lock +1 -1
  4. data/db/data/iana_to_rails_time_zone.yml +615 -0
  5. data/db/data/regions/AE.yml +11 -0
  6. data/db/data/regions/AT/en.yml +2 -1
  7. data/db/data/regions/CA/en.yml +2 -1
  8. data/db/data/regions/CL/bg.yml +1 -1
  9. data/db/data/regions/CL/cs.yml +1 -1
  10. data/db/data/regions/CL/da.yml +1 -1
  11. data/db/data/regions/CL/de.yml +1 -1
  12. data/db/data/regions/CL/el.yml +1 -1
  13. data/db/data/regions/CL/en.yml +22 -12
  14. data/db/data/regions/CL/es.yml +2 -1
  15. data/db/data/regions/CL/fi.yml +1 -1
  16. data/db/data/regions/CL/fr.yml +1 -1
  17. data/db/data/regions/CL/hi.yml +1 -1
  18. data/db/data/regions/CL/hr.yml +2 -1
  19. data/db/data/regions/CL/hu.yml +2 -1
  20. data/db/data/regions/CL/id.yml +1 -1
  21. data/db/data/regions/CL/it.yml +1 -1
  22. data/db/data/regions/CL/ja.yml +1 -1
  23. data/db/data/regions/CL/ko.yml +1 -1
  24. data/db/data/regions/CL/lt.yml +1 -1
  25. data/db/data/regions/CL/ms.yml +1 -1
  26. data/db/data/regions/CL/nb.yml +1 -1
  27. data/db/data/regions/CL/nl.yml +1 -1
  28. data/db/data/regions/CL/pl.yml +2 -1
  29. data/db/data/regions/CL/pt-BR.yml +1 -1
  30. data/db/data/regions/CL/pt-PT.yml +1 -1
  31. data/db/data/regions/CL/ro.yml +1 -1
  32. data/db/data/regions/CL/ru.yml +1 -1
  33. data/db/data/regions/CL/sk.yml +1 -1
  34. data/db/data/regions/CL/sl.yml +1 -1
  35. data/db/data/regions/CL/sv.yml +1 -1
  36. data/db/data/regions/CL/th.yml +1 -1
  37. data/db/data/regions/CL/tr.yml +1 -1
  38. data/db/data/regions/CL/vi.yml +1 -1
  39. data/db/data/regions/CL/zh-CN.yml +1 -1
  40. data/db/data/regions/CL/zh-TW.yml +1 -1
  41. data/db/data/regions/CR.yml +11 -0
  42. data/db/data/regions/KW.yml +10 -0
  43. data/db/data/regions/MX/bg.yml +23 -0
  44. data/db/data/regions/MX/cs.yml +22 -0
  45. data/db/data/regions/MX/da.yml +21 -0
  46. data/db/data/regions/MX/de.yml +22 -0
  47. data/db/data/regions/MX/el.yml +23 -0
  48. data/db/data/regions/MX/en.yml +22 -12
  49. data/db/data/regions/MX/es.yml +25 -0
  50. data/db/data/regions/MX/fi.yml +24 -0
  51. data/db/data/regions/MX/fr.yml +21 -0
  52. data/db/data/regions/MX/hi.yml +22 -0
  53. data/db/data/regions/MX/hr.yml +23 -0
  54. data/db/data/regions/MX/hu.yml +23 -0
  55. data/db/data/regions/MX/id.yml +21 -0
  56. data/db/data/regions/MX/it.yml +23 -0
  57. data/db/data/regions/MX/ja.yml +18 -0
  58. data/db/data/regions/MX/ko.yml +20 -0
  59. data/db/data/regions/MX/lt.yml +24 -0
  60. data/db/data/regions/MX/ms.yml +22 -0
  61. data/db/data/regions/MX/nb.yml +22 -0
  62. data/db/data/regions/MX/nl.yml +21 -0
  63. data/db/data/regions/MX/pl.yml +22 -0
  64. data/db/data/regions/MX/pt-BR.yml +21 -0
  65. data/db/data/regions/MX/pt-PT.yml +22 -0
  66. data/db/data/regions/MX/ro.yml +24 -0
  67. data/db/data/regions/MX/ru.yml +23 -0
  68. data/db/data/regions/MX/sk.yml +21 -0
  69. data/db/data/regions/MX/sl.yml +23 -0
  70. data/db/data/regions/MX/sv.yml +21 -0
  71. data/db/data/regions/MX/th.yml +20 -0
  72. data/db/data/regions/MX/tr.yml +20 -0
  73. data/db/data/regions/MX/vi.yml +21 -0
  74. data/db/data/regions/MX/zh-CN.yml +18 -0
  75. data/db/data/regions/MX/zh-TW.yml +18 -0
  76. data/db/data/regions/PA.yml +11 -0
  77. data/db/data/regions/PE.yml +10 -0
  78. data/db/data/regions/PH/bg.yml +28 -0
  79. data/db/data/regions/PH/cs.yml +27 -0
  80. data/db/data/regions/PH/da.yml +26 -0
  81. data/db/data/regions/PH/de.yml +27 -0
  82. data/db/data/regions/PH/el.yml +28 -0
  83. data/db/data/regions/PH/en.yml +22 -12
  84. data/db/data/regions/PH/es.yml +30 -0
  85. data/db/data/regions/PH/fi.yml +27 -0
  86. data/db/data/regions/PH/fr.yml +26 -0
  87. data/db/data/regions/PH/hi.yml +27 -0
  88. data/db/data/regions/PH/hr.yml +28 -0
  89. data/db/data/regions/PH/hu.yml +30 -0
  90. data/db/data/regions/PH/id.yml +27 -0
  91. data/db/data/regions/PH/it.yml +28 -0
  92. data/db/data/regions/PH/ja.yml +23 -0
  93. data/db/data/regions/PH/ko.yml +25 -0
  94. data/db/data/regions/PH/lt.yml +28 -0
  95. data/db/data/regions/PH/ms.yml +27 -0
  96. data/db/data/regions/PH/nb.yml +27 -0
  97. data/db/data/regions/PH/nl.yml +26 -0
  98. data/db/data/regions/PH/pl.yml +27 -0
  99. data/db/data/regions/PH/pt-BR.yml +26 -0
  100. data/db/data/regions/PH/pt-PT.yml +26 -0
  101. data/db/data/regions/PH/ro.yml +29 -0
  102. data/db/data/regions/PH/ru.yml +27 -0
  103. data/db/data/regions/PH/sk.yml +26 -0
  104. data/db/data/regions/PH/sl.yml +28 -0
  105. data/db/data/regions/PH/sv.yml +27 -0
  106. data/db/data/regions/PH/th.yml +25 -0
  107. data/db/data/regions/PH/tr.yml +25 -0
  108. data/db/data/regions/PH/vi.yml +26 -0
  109. data/db/data/regions/PH/zh-CN.yml +23 -0
  110. data/db/data/regions/PH/zh-TW.yml +23 -0
  111. data/db/data/regions/PH.yml +0 -1
  112. data/db/data/regions/SA.yml +11 -0
  113. data/db/data/regions/TH/en.yml +1 -1
  114. data/db/data/regions/TR/en.yml +2 -1
  115. data/db/data/regions/TW/en.yml +2 -1
  116. data/db/data/regions/US/en.yml +6 -4
  117. data/db/data/regions/UY/en.yml +2 -2
  118. data/db/data/regions/VN/en.yml +3 -2
  119. data/db/data/regions/VN.yml +1 -1
  120. data/db/data/regions/_default/en.yml +89 -49
  121. data/lib/worldwide/address.rb +16 -4
  122. data/lib/worldwide/deprecated_time_zone_mapper.rb +10 -0
  123. data/lib/worldwide/field.rb +10 -22
  124. data/lib/worldwide/version.rb +1 -1
  125. metadata +35 -2
@@ -100,7 +100,7 @@ en:
100
100
  errors:
101
101
  blank_instructional: Enter a street
102
102
  blank_informative: Street is missing
103
- too_long_instructional: Street is too long (maximum is 255 characters)
103
+ too_long_instructional: Street is too long (maximum is %{limit} characters)
104
104
  too_long_informative: Street is too long
105
105
  contains_emojis_instructional: Street can't contain emojis
106
106
  contains_emojis_informative: Street can't contain emojis
@@ -110,9 +110,9 @@ en:
110
110
  local characters, and special characters
111
111
  contains_restricted_characters_informative: Street can't contain restricted characters
112
112
  contains_too_many_words_instructional: Street can't have more than %{word_count} words
113
- contains_too_many_words_informational: Street can't have more than %{word_count} words
113
+ contains_too_many_words_informative: Street can't have more than %{word_count} words
114
114
  contains_html_tags_instructional: Street can't contain HTML
115
- contains_html_tags_informational: Street can't contain HTML
115
+ contains_html_tags_informative: Street can't contain HTML
116
116
  contains_url_instructional: Street can't contain a URL
117
117
  contains_url_informative: Street can't contain a URL
118
118
  street_unknown_for_zip_instructional: Enter a valid street for %{zip}
@@ -128,7 +128,7 @@ en:
128
128
  errors:
129
129
  blank_instructional: Enter a building number
130
130
  blank_informative: Building number is missing
131
- too_long_instructional: Building number is too long (maximum is 255 characters)
131
+ too_long_instructional: Building number is too long (maximum is %{limit} characters)
132
132
  too_long_informative: Building number is too long
133
133
  contains_emojis_instructional: Building number can't contain emojis
134
134
  contains_emojis_informative: Building number can't contain emojis
@@ -157,22 +157,28 @@ en:
157
157
  blank_instructional: Enter an apartment, suite, etc
158
158
  blank_informative: Apartment or suite is missing
159
159
  too_long_instructional: Address line 2 is too long (maximum is 255 characters)
160
- too_long_informational: Address line 2 is too long
161
- contains_emojis: Address line 2 can't contain emojis
162
- contains_mathematical_symbols: Address line 2 can't contain mathematical symbols
163
- contains_restricted_characters: Address line 2 can only contain letters, numbers,
160
+ too_long_informative: Address line 2 is too long
161
+ contains_emojis_instructional: Address line 2 can't contain emojis
162
+ contains_emojis_informative: Address line 2 can't contain emojis
163
+ contains_mathematical_symbols_instructional: Address line 2 can't contain mathematical symbols
164
+ contains_mathematical_symbols_informative: Address line 2 can't contain mathematical symbols
165
+ contains_restricted_characters_instructional: Address line 2 can only contain letters, numbers,
164
166
  local characters, and special characters
165
- contains_too_many_words: Address line 2 can't have more than %{word_count}
166
- words
167
- contains_html_tags: Address line 2 can't contain HTML
168
- contains_url: Address line 2 can't contain a URL
167
+ contains_restricted_characters_informative: Address line 2 can't contain restricted characters
168
+ contains_too_many_words_instructional: Address line 2 must have fewer than %{word_count} words
169
+ contains_too_many_words_informative: Address line 2 must have fewer than %{word_count} words
170
+ contains_html_tags_instructional: Address line 2 can't contain HTML
171
+ contains_html_tags_informative: Address line 2 can't contain HTML
172
+ contains_url_instructional: Address line 2 can't contain a URL
173
+ contains_url_informative: Address line 2 can't contain a URL
169
174
  missing_building_number_instructional: Add a building number if you have one
170
175
  missing_building_number_informative: Building number may be missing
171
176
  street_unknown_for_zip_instructional: Enter a valid street name for %{zip}
172
177
  street_unknown_for_zip_informative: Street name isn't valid for %{zip}
173
178
  building_number_invalid_instructional: Building number couldn't be located for %{street}, %{zip}
174
179
  building_number_invalid_informative: Building number couldn't be located for %{street}, %{zip}
175
- unknown_for_address: Address line 2 may be incorrect
180
+ unknown_for_address_instructional: Address line 2 may be incorrect
181
+ unknown_for_address_informative: Address line 2 may be incorrect
176
182
  warnings:
177
183
  contains_too_many_words: Address line 2 is recommended to have less than %{word_count} words
178
184
  line2:
@@ -197,11 +203,16 @@ en:
197
203
  contains_html_tags_informative: The second address line can't contain HTML tags
198
204
  contains_url_instructional: The second address line can't contain a URL
199
205
  contains_url_informative: The second address line can't contain a URL
200
- missing_building_number: Add a building number if you have one
201
- street_unknown_for_zip: Enter a valid street name for %{zip}
202
- building_number_invalid: Building number couldn't be located for %{street},
206
+ missing_building_number_instructional: Add a building number if you have one
207
+ missing_building_number_informative: Add a building number if you have one
208
+ street_unknown_for_zip_instructional: Enter a valid street name for %{zip}
209
+ street_unknown_for_zip_informative: Enter a valid street name for %{zip}
210
+ building_number_invalid_instructional: Building number couldn't be located for %{street},
211
+ %{zip}
212
+ building_number_invalid_informative: Building number couldn't be located for %{street},
203
213
  %{zip}
204
- unknown_for_address: The second address line may be incorrect
214
+ unknown_for_address_instructional: The second address line may be incorrect
215
+ unknown_for_address_informative: The second address line may be incorrect
205
216
  warnings:
206
217
  contains_too_many_words: The second address line is recommended to have less than %{word_count} words
207
218
  neighborhood:
@@ -209,19 +220,29 @@ en:
209
220
  default: Neighborhood
210
221
  optional: Neighborhood (optional)
211
222
  errors:
212
- blank: Enter a neighborhood
213
- too_long: Neighborhood is too long (maximum is %{limit} characters)
214
- contains_emojis: Neighborhood can't contain emojis
215
- contains_mathematical_symbols: Neighborhood can't contain mathematical symbols
216
- contains_restricted_characters: Neighborhood can only contain letters, numbers,
223
+ blank_instructional: Enter a neighborhood
224
+ blank_informative: Neighborhood is missing
225
+ too_long_instructional: Neighborhood is too long (maximum is %{limit} characters)
226
+ too_long_informative: Neighborhood is too long
227
+ contains_emojis_instructional: Neighborhood can't contain emojis
228
+ contains_emojis_informative: Neighborhood can't contain emojis
229
+ contains_mathematical_symbols_instructional: Neighborhood can't contain mathematical symbols
230
+ contains_mathematical_symbols_informative: Neighborhood can't contain mathematical symbols
231
+ contains_restricted_characters_instructional: Neighborhood can only contain letters, numbers,
217
232
  local characters, and special characters
218
- contains_too_many_words: Neighborhood can't have more than %{word_count}
219
- words
220
- contains_html_tags: Neighborhood can't contain HTML tags
221
- contains_url: Neighborhood can't contain URLs
222
- unknown_for_city: Enter a valid neighborhood name for %{city}
223
- unknown_for_zip: Enter a valid neighborhood name for %{zip}
224
- unknown_for_address: Neighborhood may be incorrect
233
+ contains_restricted_characters_informative: Neighborhood can't contain restricted characters
234
+ contains_too_many_words_instructional: Neighborhood must have fewer than %{word_count} words
235
+ contains_too_many_words_informative: Neighborhood must have fewer than %{word_count} words
236
+ contains_html_tags_instructional: Neighborhood can't contain HTML tags
237
+ contains_html_tags_informative: Neighborhood can't contain HTML tags
238
+ contains_url_instructional: Neighborhood can't contain URLs
239
+ contains_url_informative: Neighborhood can't contain URLs
240
+ unknown_for_city_instructional: Enter a valid neighborhood name for %{city}
241
+ unknown_for_city_informative: Enter a valid neighborhood name for %{city}
242
+ unknown_for_zip_instructional: Enter a valid neighborhood name for %{zip}
243
+ unknown_for_zip_informative: Enter a valid neighborhood name for %{zip}
244
+ unknown_for_address_instructional: Neighborhood may be incorrect
245
+ unknown_for_address_informative: Neighborhood may be incorrect
225
246
  warnings:
226
247
  contains_too_many_words: Neighborhood is recommended to have less than %{word_count} words
227
248
  city:
@@ -231,21 +252,29 @@ en:
231
252
  errors:
232
253
  blank_instructional: Enter a city
233
254
  blank_informative: City is missing
234
- too_long: City is too long (maximum is 255 characters)
235
- contains_emojis: City can't contain emojis
236
- contains_mathematical_symbols: City can't contain mathematical symbols
237
- contains_restricted_characters: City can only contain letters, numbers,
255
+ too_long_instructional: City is too long (maximum is 255 characters)
256
+ too_long_informative: City is too long
257
+ contains_emojis_instructional: City can't contain emojis
258
+ contains_emojis_informative: City can't contain emojis
259
+ contains_mathematical_symbols_instructional: City can't contain mathematical symbols
260
+ contains_mathematical_symbols_informative: City can't contain mathematical symbols
261
+ contains_restricted_characters_instructional: City can only contain letters, numbers,
238
262
  local characters, and special characters
239
- contains_too_many_words: City can't have more than %{word_count} words
240
- contains_html_tags: City can't contain HTML
241
- contains_url: City can't contain a URL
263
+ contains_restricted_characters_informative: City can't contain restricted characters
264
+ contains_too_many_words_instructional: City must have fewer than %{word_count} words
265
+ contains_too_many_words_informative: City must have fewer than %{word_count} words
266
+ contains_html_tags_instructional: City can't contain HTML
267
+ contains_html_tags_informative: City can't contain HTML
268
+ contains_url_instructional: City can't contain a URL
269
+ contains_url_informative: City can't contain a URL
242
270
  unknown_for_zip_instructional: Enter a valid city for %{zip}
243
271
  unknown_for_zip_informative: City doesn't match %{zip}
244
272
  unknown_for_province_instructional: Enter a valid city for %{province}
245
273
  unknown_for_province_informative: City doesn't match %{province}
246
274
  unknown_for_zip_and_province_instructional: Enter a valid city for %{zip}, %{province}
247
275
  unknown_for_zip_and_province_informative: City may be incorrect
248
- unknown_for_address: City may be incorrect
276
+ unknown_for_address_instructional: City may be incorrect
277
+ unknown_for_address_informative: City may be incorrect
249
278
  province:
250
279
  label:
251
280
  default: Region
@@ -263,7 +292,8 @@ en:
263
292
  unknown_for_city_instructional: Region doesn't match %{city}
264
293
  unknown_for_zip_instructional: Select a valid region for %{zip}
265
294
  unknown_for_zip_informative: Region doesn't match %{zip}
266
- unknown_for_address: Region may be incorrect
295
+ unknown_for_address_instructional: Region may be incorrect
296
+ unknown_for_address_informative: Region may be incorrect
267
297
  country:
268
298
  label:
269
299
  default: Country/region
@@ -284,7 +314,8 @@ en:
284
314
  errors:
285
315
  blank_instructional: Enter a postal code
286
316
  blank_informative: Postal code is missing
287
- blocked_address: This location isn't supported
317
+ blocked_address_instructional: This location isn't supported
318
+ blocked_address_informative: This location isn't supported
288
319
  invalid_instructional: Enter a valid postal code
289
320
  invalid_informative: Postal code isn't valid
290
321
  invalid_for_country_instructional: Enter a valid postal code for %{country}
@@ -293,17 +324,23 @@ en:
293
324
  invalid_for_province_informative: Postal code doesn't match %{province}
294
325
  invalid_for_country_and_province_instructional: Enter a valid postal code for %{province}, %{country}
295
326
  invalid_for_country_and_province_informative: Postal code doesn't match %{province}, %{country}
296
- too_long: The postal code is too long
297
- contains_emojis: Postal code can't contain emojis
298
- contains_mathematical_symbols: Postal code can't contain mathematical symbols
299
- contains_restricted_characters: Postal code can only contain letters,
327
+ too_long_instructional: Postal code is too long
328
+ too_long_informative: Postal code is too long
329
+ contains_emojis_instructional: Postal code can't contain emojis
330
+ contains_emojis_informative: Postal code can't contain emojis
331
+ contains_mathematical_symbols_instructional: Postal code can't contain mathematical symbols
332
+ contains_mathematical_symbols_informative: Postal code can't contain mathematical symbols
333
+ contains_restricted_characters_instructional: Postal code can only contain letters,
300
334
  numbers, local characters, and special characters
335
+ contains_restricted_characters_informative: Postal code can't contain restricted characters
301
336
  not_supported_instructional: Postal code not supported. Enter a new address and try again
302
- not_supported_informativel: Postal code not supported
303
- contains_html_tags: Postal code can't contain HTML
337
+ not_supported_informative: Postal code not supported
338
+ contains_html_tags_instructional: Postal code can't contain HTML
339
+ contains_html_tags_informative: Postal code can't contain HTML
304
340
  unknown_for_province_instructional: Enter a valid postal code for %{province}
305
341
  unknown_for_province_informative: Postal code is invalid for %{province}
306
- unknown_for_address: Postal code may be incorrect
342
+ unknown_for_address_instructional: Postal code may be incorrect
343
+ unknown_for_address_informative: Postal code may be incorrect
307
344
  phone:
308
345
  label:
309
346
  default: Phone
@@ -315,10 +352,13 @@ en:
315
352
  invalid_informative: Phone number isn't valid
316
353
  too_long_instructional: Phone number is too long
317
354
  too_long_informative: Phone number is too long
318
- contains_emojis: Phone number can't contain emojis
319
- contains_mathematical_symbols: Phone number can't contain mathematical symbols
320
- contains_restricted_characters: Phone number can only contain letters,
355
+ contains_emojis_instructional: Phone number can't contain emojis
356
+ contains_emojis_informative: Phone number can't contain emojis
357
+ contains_mathematical_symbols_instructional: Phone number can't contain mathematical symbols
358
+ contains_mathematical_symbols_informative: Phone number can't contain mathematical symbols
359
+ contains_restricted_characters_instructional: Phone number can only contain letters,
321
360
  numbers, local characters, and special characters
361
+ contains_restricted_characters_informative: Phone number can't contain restricted characters
322
362
  address:
323
363
  errors:
324
364
  may_not_exist_instructional: Address not found or doesn't exist
@@ -146,15 +146,21 @@ module Worldwide
146
146
  end
147
147
 
148
148
  RESERVED_DELIMITER = "\u00A0"
149
- def concatenated_address1
150
- return address1 if address1.present?
151
-
149
+ def concatenate_address1
152
150
  additional_fields = region.combined_address_format["address1"] || []
151
+ additional_field_keys = additional_fields.map { |field| field["key"] }
152
+
153
+ return address1 if field_values(additional_field_keys).empty?
154
+
153
155
  concatenate_fields(additional_fields)
154
156
  end
155
157
 
156
- def concatenated_address2
158
+ def concatenate_address2
157
159
  additional_fields = region.combined_address_format["address2"] || []
160
+ additional_field_keys = additional_fields.map { |field| field["key"] }
161
+
162
+ return address2 if field_values(additional_field_keys).empty?
163
+
158
164
  concatenate_fields(additional_fields)
159
165
  end
160
166
 
@@ -471,6 +477,12 @@ module Worldwide
471
477
  concatenated_field
472
478
  end
473
479
 
480
+ def field_values(fields)
481
+ fields.index_with do |field|
482
+ send(field.underscore.to_sym)
483
+ end.compact
484
+ end
485
+
474
486
  def concatenation_delimiter(concatenated_field, decorator, field_index)
475
487
  if field_index == 0
476
488
  ""
@@ -8,6 +8,16 @@ module Worldwide
8
8
  def to_supported(zone)
9
9
  DEPRECATED_ZONES_MAP.fetch(zone&.to_sym, zone)
10
10
  end
11
+
12
+ def to_rails(iana_timezone)
13
+ iana_timezones[iana_timezone]
14
+ end
15
+
16
+ private
17
+
18
+ def iana_timezones
19
+ @iana_timezones ||= YAML.safe_load_file("#{Worldwide::Paths::DB_DATA_ROOT}/iana_to_rails_time_zone.yml")
20
+ end
11
21
  end
12
22
 
13
23
  DEPRECATED_ZONES_MAP = {
@@ -48,6 +48,9 @@ module Worldwide
48
48
  end
49
49
 
50
50
  def error(locale: I18n.locale, code:, options: {})
51
+ unless code.end_with?("_instructional", "_informative")
52
+ code = "#{code}_instructional"
53
+ end
51
54
  lookup("errors.#{code}", locale: locale, options: options)
52
55
  end
53
56
 
@@ -63,33 +66,18 @@ module Worldwide
63
66
 
64
67
  def default_lookup(key_suffix, options: {})
65
68
  base = base_key("_default")
66
-
67
- message = I18n.t("#{base}.#{key_suffix}", default: nil, **options)
68
- return message if message.present?
69
-
70
- key = key_suffix.include?("_instructional") ? "#{base}.#{key_suffix.sub("_instructional", "")}" : "#{base}.#{key_suffix}_instructional"
71
- message = I18n.t(key, default: nil, **options)
72
- return message if message.present?
73
-
74
- I18n.with_locale(:en) { I18n.t("#{base}.#{key_suffix}", default: nil, **options) }
69
+ I18n.t("#{base}.#{key_suffix}", default: nil, **options) ||
70
+ I18n.with_locale(:en) { I18n.t("#{base}.#{key_suffix}", default: nil, **options) }
75
71
  end
76
72
 
77
73
  def lookup(key_suffix, locale:, options: {})
78
74
  I18n.with_locale(locale) do
79
- unless @country_code.nil?
80
- message = I18n.t("#{base_key(@country_code)}.#{key_suffix}", default: nil, **options)
81
- return message if message.present?
82
-
83
- key = if key_suffix.include?("_instructional")
84
- "#{base_key(@country_code)}.#{key_suffix.sub("_instructional", "")}"
85
- else
86
- "#{base_key(@country_code)}.#{key_suffix}_instructional"
87
- end
88
- message = I18n.t(key, default: nil, **options)
89
- return message if message.present?
75
+ if @country_code.nil?
76
+ default_lookup(key_suffix, options: options)
77
+ else
78
+ I18n.t("#{base_key(@country_code)}.#{key_suffix}", default: nil, **options) ||
79
+ default_lookup(key_suffix, options: options)
90
80
  end
91
-
92
- default_lookup(key_suffix, options: options)
93
81
  end
94
82
  end
95
83
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Worldwide
4
- VERSION = "1.1.0"
4
+ VERSION = "1.3.0"
5
5
  end
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.1.0
4
+ version: 1.3.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-06-04 00:00:00.000000000 Z
11
+ date: 2024-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -6213,6 +6213,7 @@ files:
6213
6213
  - data/other/units/zh-TW.yml
6214
6214
  - data/top_locales.yml
6215
6215
  - db/data/country_codes.yml
6216
+ - db/data/iana_to_rails_time_zone.yml
6216
6217
  - db/data/regions/AC.yml
6217
6218
  - db/data/regions/AD.yml
6218
6219
  - db/data/regions/AE.yml
@@ -7706,7 +7707,39 @@ files:
7706
7707
  - db/data/regions/PF.yml
7707
7708
  - db/data/regions/PG.yml
7708
7709
  - db/data/regions/PH.yml
7710
+ - db/data/regions/PH/bg.yml
7711
+ - db/data/regions/PH/cs.yml
7712
+ - db/data/regions/PH/da.yml
7713
+ - db/data/regions/PH/de.yml
7714
+ - db/data/regions/PH/el.yml
7709
7715
  - db/data/regions/PH/en.yml
7716
+ - db/data/regions/PH/es.yml
7717
+ - db/data/regions/PH/fi.yml
7718
+ - db/data/regions/PH/fr.yml
7719
+ - db/data/regions/PH/hi.yml
7720
+ - db/data/regions/PH/hr.yml
7721
+ - db/data/regions/PH/hu.yml
7722
+ - db/data/regions/PH/id.yml
7723
+ - db/data/regions/PH/it.yml
7724
+ - db/data/regions/PH/ja.yml
7725
+ - db/data/regions/PH/ko.yml
7726
+ - db/data/regions/PH/lt.yml
7727
+ - db/data/regions/PH/ms.yml
7728
+ - db/data/regions/PH/nb.yml
7729
+ - db/data/regions/PH/nl.yml
7730
+ - db/data/regions/PH/pl.yml
7731
+ - db/data/regions/PH/pt-BR.yml
7732
+ - db/data/regions/PH/pt-PT.yml
7733
+ - db/data/regions/PH/ro.yml
7734
+ - db/data/regions/PH/ru.yml
7735
+ - db/data/regions/PH/sk.yml
7736
+ - db/data/regions/PH/sl.yml
7737
+ - db/data/regions/PH/sv.yml
7738
+ - db/data/regions/PH/th.yml
7739
+ - db/data/regions/PH/tr.yml
7740
+ - db/data/regions/PH/vi.yml
7741
+ - db/data/regions/PH/zh-CN.yml
7742
+ - db/data/regions/PH/zh-TW.yml
7710
7743
  - db/data/regions/PK.yml
7711
7744
  - db/data/regions/PL.yml
7712
7745
  - db/data/regions/PM.yml