route_translator 13.1.1 → 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 +5 -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 +15 -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: 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,10 @@
|
|
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
|
+
|
3
8
|
## 13.1.1 / 2023-07-01
|
4
9
|
|
5
10
|
* [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
@@ -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: 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
|