route_translator 13.1.1 → 13.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +6 -0
- data/lib/route_translator/route.rb +5 -1
- data/lib/route_translator/version.rb +1 -1
- data/lib/route_translator.rb +20 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6fce16b25f253c530a462e14251479236768723b507359e93db129274ab14ae
|
4
|
+
data.tar.gz: 0fb41bf9534c717748acc18bd61213998a3648b7808b20ced17132694f84f135
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
data/lib/route_translator.rb
CHANGED
@@ -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.
|
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-
|
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.
|
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
|