route_translator 13.1.0 → 13.2.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/CHANGELOG.md +11 -0
- data/README.md +6 -0
- data/lib/route_translator/route.rb +5 -1
- data/lib/route_translator/translator/route_helpers.rb +10 -14
- data/lib/route_translator/version.rb +1 -1
- data/lib/route_translator.rb +15 -1
- metadata +3 -107
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7cdedc4080c8163372dc065026e2084f00cd8436cb49bbbf0bf9fd3a5624a0b7
|
4
|
+
data.tar.gz: 9b1d8e9b07c2c04e10ce89a976f1cda42efac59a23dabb375361f9ec570418ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 657a89132bee2d9d8b28a1d4940c36e2326b736ec1edb2815756108fae10e69b55b1d166c7b56ec77a0ad271ce54aad9928fe9624152d5de7b51bb8e342a900a
|
7
|
+
data.tar.gz: fbb5fec9b9443e5e2d6eee402a2394248742dbe7a47d144791670aefd3880319e2e1203ab4a4fde3fb38c4ead477ec64baddd460d066abe4033240e68eb08587
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 13.2.0 / 2023-07-28
|
4
|
+
|
5
|
+
* [FEATURE] Add option for standard nested separator ([#285](https://github.com/enriclluelles/route_translator/pull/285))
|
6
|
+
* [ENHANCEMENT] Update development dependencies
|
7
|
+
|
8
|
+
## 13.1.1 / 2023-07-01
|
9
|
+
|
10
|
+
* [ENHANCEMENT] Better integration with ActionController::TestCase
|
11
|
+
* [ENHANCEMENT] Remove Rails 5.1 code
|
12
|
+
* [ENHANCEMENT] Update development dependencies
|
13
|
+
|
3
14
|
## 13.1.0 / 2022-12-26
|
4
15
|
|
5
16
|
* [ENHANCEMENT] Test against Ruby 3.1 and Ruby 3.2
|
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
|
-
|
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
|
@@ -3,17 +3,9 @@
|
|
3
3
|
module RouteTranslator
|
4
4
|
module Translator
|
5
5
|
module RouteHelpers
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
def add_helpers_to_test_cases(helper_container)
|
10
|
-
%w[ActionController ActionMailer ActionView].each do |klass_name|
|
11
|
-
next unless Module.const_defined?(klass_name)
|
12
|
-
|
13
|
-
klass_name.constantize::TestCase.__send__(:include, helper_container)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
6
|
+
TEST_CASE_HOOKS = %i[
|
7
|
+
action_controller_test_case action_mailer_test_case action_view_test_case
|
8
|
+
].freeze
|
17
9
|
|
18
10
|
module_function
|
19
11
|
|
@@ -27,15 +19,19 @@ module RouteTranslator
|
|
27
19
|
|
28
20
|
%w[path url].each do |suffix|
|
29
21
|
helper_container = named_route_collection.send(:"#{suffix}_helpers_module")
|
30
|
-
new_helper_name = "#{old_name}_#{suffix}"
|
22
|
+
new_helper_name = :"#{old_name}_#{suffix}"
|
31
23
|
|
32
|
-
helper_list.push(new_helper_name
|
24
|
+
helper_list.push(new_helper_name) unless helper_list.include?(new_helper_name)
|
33
25
|
|
34
26
|
helper_container.__send__(:define_method, new_helper_name) do |*args|
|
35
27
|
__send__(Translator.route_name_for(args, old_name, suffix, self), *args)
|
36
28
|
end
|
37
29
|
|
38
|
-
|
30
|
+
TEST_CASE_HOOKS.each do |test_case_hook|
|
31
|
+
ActiveSupport.on_load(test_case_hook) do
|
32
|
+
include helper_container
|
33
|
+
end
|
34
|
+
end
|
39
35
|
end
|
40
36
|
end
|
41
37
|
end
|
data/lib/route_translator.rb
CHANGED
@@ -20,7 +20,8 @@ module RouteTranslator
|
|
20
20
|
hide_locale: false,
|
21
21
|
host_locales: {},
|
22
22
|
locale_param_key: :locale,
|
23
|
-
locale_segment_proc: false
|
23
|
+
locale_segment_proc: false,
|
24
|
+
i18n_use_slash_separator: false
|
24
25
|
}.freeze
|
25
26
|
|
26
27
|
Configuration = Struct.new(*DEFAULT_CONFIGURATION.keys)
|
@@ -34,6 +35,18 @@ module RouteTranslator
|
|
34
35
|
@config.generate_unnamed_unlocalized_routes = false
|
35
36
|
@config.hide_locale = true
|
36
37
|
end
|
38
|
+
|
39
|
+
def check_deprecations
|
40
|
+
return if @config.i18n_use_slash_separator
|
41
|
+
|
42
|
+
ActiveSupport::Deprecation.warn <<~MSG
|
43
|
+
`i18n_use_slash_separator` set to `false` is deprecated and will be
|
44
|
+
removed in the next major release of Route Translator to match
|
45
|
+
Rails' ActiveRecord nested model syntax.
|
46
|
+
|
47
|
+
More information at https://github.com/enriclluelles/route_translator/pull/285
|
48
|
+
MSG
|
49
|
+
end
|
37
50
|
end
|
38
51
|
|
39
52
|
module_function
|
@@ -48,6 +61,7 @@ module RouteTranslator
|
|
48
61
|
yield @config if block_given?
|
49
62
|
|
50
63
|
resolve_host_locale_config_conflicts if @config.host_locales.present?
|
64
|
+
check_deprecations
|
51
65
|
|
52
66
|
@config
|
53
67
|
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.
|
4
|
+
version: 13.2.0
|
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:
|
13
|
+
date: 2023-07-28 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: actionpack
|
@@ -52,110 +52,6 @@ dependencies:
|
|
52
52
|
- - "<"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '7.1'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: appraisal
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '2.4'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '2.4'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: byebug
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '11.1'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '11.1'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: minitest
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '5.16'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '5.16'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: rails
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '5.2'
|
104
|
-
- - "<"
|
105
|
-
- !ruby/object:Gem::Version
|
106
|
-
version: '7.1'
|
107
|
-
type: :development
|
108
|
-
prerelease: false
|
109
|
-
version_requirements: !ruby/object:Gem::Requirement
|
110
|
-
requirements:
|
111
|
-
- - ">="
|
112
|
-
- !ruby/object:Gem::Version
|
113
|
-
version: '5.2'
|
114
|
-
- - "<"
|
115
|
-
- !ruby/object:Gem::Version
|
116
|
-
version: '7.1'
|
117
|
-
- !ruby/object:Gem::Dependency
|
118
|
-
name: rake
|
119
|
-
requirement: !ruby/object:Gem::Requirement
|
120
|
-
requirements:
|
121
|
-
- - "~>"
|
122
|
-
- !ruby/object:Gem::Version
|
123
|
-
version: '13.0'
|
124
|
-
type: :development
|
125
|
-
prerelease: false
|
126
|
-
version_requirements: !ruby/object:Gem::Requirement
|
127
|
-
requirements:
|
128
|
-
- - "~>"
|
129
|
-
- !ruby/object:Gem::Version
|
130
|
-
version: '13.0'
|
131
|
-
- !ruby/object:Gem::Dependency
|
132
|
-
name: simplecov
|
133
|
-
requirement: !ruby/object:Gem::Requirement
|
134
|
-
requirements:
|
135
|
-
- - "~>"
|
136
|
-
- !ruby/object:Gem::Version
|
137
|
-
version: 0.22.0
|
138
|
-
type: :development
|
139
|
-
prerelease: false
|
140
|
-
version_requirements: !ruby/object:Gem::Requirement
|
141
|
-
requirements:
|
142
|
-
- - "~>"
|
143
|
-
- !ruby/object:Gem::Version
|
144
|
-
version: 0.22.0
|
145
|
-
- !ruby/object:Gem::Dependency
|
146
|
-
name: simplecov-lcov
|
147
|
-
requirement: !ruby/object:Gem::Requirement
|
148
|
-
requirements:
|
149
|
-
- - "~>"
|
150
|
-
- !ruby/object:Gem::Version
|
151
|
-
version: 0.8.0
|
152
|
-
type: :development
|
153
|
-
prerelease: false
|
154
|
-
version_requirements: !ruby/object:Gem::Requirement
|
155
|
-
requirements:
|
156
|
-
- - "~>"
|
157
|
-
- !ruby/object:Gem::Version
|
158
|
-
version: 0.8.0
|
159
55
|
description: Translates the Rails routes of your application into the languages defined
|
160
56
|
in your locale files
|
161
57
|
email:
|
@@ -204,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
204
100
|
- !ruby/object:Gem::Version
|
205
101
|
version: '0'
|
206
102
|
requirements: []
|
207
|
-
rubygems_version: 3.
|
103
|
+
rubygems_version: 3.4.1
|
208
104
|
signing_key:
|
209
105
|
specification_version: 4
|
210
106
|
summary: Translate your Rails routes in a simple manner
|