route_translator 13.1.1 → 13.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 13ffed7aec8713246cd7e9866e95b58a74aa96ffb3d633abcb709577a82d3eb4
4
- data.tar.gz: 917888bdb81c4b9f6f191e2855526b5a674d258b18204f31ed3b47d01eb5c14b
3
+ metadata.gz: b6fce16b25f253c530a462e14251479236768723b507359e93db129274ab14ae
4
+ data.tar.gz: 0fb41bf9534c717748acc18bd61213998a3648b7808b20ced17132694f84f135
5
5
  SHA512:
6
- metadata.gz: 3d98eea935387e378734dea58b0483b1640d9b0680578c037be317dca02e5d187a4e11002c450114d4adb9c98433ad9777c6c38692c9c1e1768988ca32bffc61
7
- data.tar.gz: ad9b23bddd7838864b73a3cbf53f222046ba82f649586f21223407fbe173bc0400c1c4c91f24305da9b7d932bc7475b7612b6112e4bbd35a2938490cfe65ace7
6
+ metadata.gz: 067e8efc0ef38001c0dee08bf2b7640f497edf0f69448448a0c596b63ac32c0110f906160d2fe34991d0c9f50895ef0f775e903f382c54748fedfae6de8df6eb
7
+ data.tar.gz: b5b62f4644dc3fd6ad6401927ce4af0b897572467d86ffaabb444254680e9adaf97194a2c3cc17b6bf9abdfdad1213bd350ddeb73c5e9c242c53baef93590387
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 13.2.1 / 2023-07-28
4
+
5
+ * [BUGFIX] Fix deprecation on Rails Edge
6
+
7
+ ## 13.2.0 / 2023-07-28
8
+
9
+ * [FEATURE] Add option for standard nested separator ([#285](https://github.com/enriclluelles/route_translator/pull/285))
10
+ * [ENHANCEMENT] Update development dependencies
11
+
3
12
  ## 13.1.1 / 2023-07-01
4
13
 
5
14
  * [ENHANCEMENT] Better integration with ActionController::TestCase
data/README.md CHANGED
@@ -280,7 +280,13 @@ end
280
280
  | `host_locales` | Sets `I18n.locale` based on `request.host`. Useful for apps accepting requests from more than one domain. See below for more details | `{}` |
281
281
  | `locale_param_key` | The param key used to set the locale to the newly generated routes | `:locale` |
282
282
  | `locale_segment_proc` | The locale segment of the url will by default be `locale.to_s.downcase`. You can supply your own mechanism via a Proc that takes `locale` as an argument, e.g. `->(locale) { locale.to_s.upcase }` | `false` |
283
+ | `i18n_use_slash_separator` | Use the exact controller path `account/foo` for looking up translations instead of nested keys `account.foo` | `false` |
283
284
 
285
+ #### Deprecated options
286
+
287
+ - `i18n_use_slash_separator` is deprecated and will be forced to `true` in the next major release of Route Translator. This only
288
+ affects application with nested routes. Please set this option to `true` to remove the deprecation message and ensure
289
+ to convert nested routes like `people.products` to the new `people/products`.
284
290
 
285
291
  ### Host-based Locale
286
292
 
@@ -16,7 +16,11 @@ module RouteTranslator
16
16
  def scope
17
17
  @scope ||=
18
18
  if mapping.defaults[:controller]
19
- %i[routes controllers].concat mapping.defaults[:controller].split('/').map(&:to_sym)
19
+ if RouteTranslator.config.i18n_use_slash_separator
20
+ %i[routes controllers].push mapping.defaults[:controller]
21
+ else
22
+ %i[routes controllers].concat mapping.defaults[:controller].split('/').map(&:to_sym)
23
+ end
20
24
  else
21
25
  %i[routes controllers]
22
26
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RouteTranslator
4
- VERSION = '13.1.1'
4
+ VERSION = '13.2.1'
5
5
  end
@@ -5,6 +5,7 @@ require 'active_support'
5
5
  require 'route_translator/extensions'
6
6
  require 'route_translator/translator'
7
7
  require 'route_translator/host'
8
+ require 'route_translator/version'
8
9
 
9
10
  module RouteTranslator
10
11
  extend RouteTranslator::Host
@@ -20,7 +21,8 @@ module RouteTranslator
20
21
  hide_locale: false,
21
22
  host_locales: {},
22
23
  locale_param_key: :locale,
23
- locale_segment_proc: false
24
+ locale_segment_proc: false,
25
+ i18n_use_slash_separator: false
24
26
  }.freeze
25
27
 
26
28
  Configuration = Struct.new(*DEFAULT_CONFIGURATION.keys)
@@ -34,6 +36,18 @@ module RouteTranslator
34
36
  @config.generate_unnamed_unlocalized_routes = false
35
37
  @config.hide_locale = true
36
38
  end
39
+
40
+ def check_deprecations
41
+ return if @config.i18n_use_slash_separator
42
+
43
+ deprecator.warn <<~MSG
44
+ `i18n_use_slash_separator` set to `false` is deprecated and will be
45
+ removed in the next major release of Route Translator to match
46
+ Rails' ActiveRecord nested model syntax.
47
+
48
+ More information at https://github.com/enriclluelles/route_translator/pull/285
49
+ MSG
50
+ end
37
51
  end
38
52
 
39
53
  module_function
@@ -48,6 +62,7 @@ module RouteTranslator
48
62
  yield @config if block_given?
49
63
 
50
64
  resolve_host_locale_config_conflicts if @config.host_locales.present?
65
+ check_deprecations
51
66
 
52
67
  @config
53
68
  end
@@ -76,4 +91,8 @@ module RouteTranslator
76
91
  locale = params[config.locale_param_key]&.to_sym
77
92
  locale if I18n.available_locales.include?(locale)
78
93
  end
94
+
95
+ def deprecator
96
+ @deprecator ||= ActiveSupport::Deprecation.new(RouteTranslator::VERSION, 'RouteTranslator')
97
+ end
79
98
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: route_translator
3
3
  version: !ruby/object:Gem::Version
4
- version: 13.1.1
4
+ version: 13.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geremia Taglialatela
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-07-01 00:00:00.000000000 Z
13
+ date: 2023-07-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: actionpack
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
100
  - !ruby/object:Gem::Version
101
101
  version: '0'
102
102
  requirements: []
103
- rubygems_version: 3.0.9
103
+ rubygems_version: 3.4.1
104
104
  signing_key:
105
105
  specification_version: 4
106
106
  summary: Translate your Rails routes in a simple manner