route_translator 8.0.0 → 10.0.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 +28 -0
- data/LICENSE +1 -1
- data/README.md +19 -4
- data/lib/route_translator.rb +5 -8
- data/lib/route_translator/extensions/mapper.rb +6 -6
- data/lib/route_translator/extensions/route_set.rb +2 -2
- data/lib/route_translator/host.rb +8 -8
- data/lib/route_translator/translator.rb +1 -4
- data/lib/route_translator/translator/path.rb +1 -2
- data/lib/route_translator/translator/path/segment.rb +6 -7
- data/lib/route_translator/version.rb +1 -1
- metadata +59 -27
- data/lib/route_translator/host_path_consistency_lambdas.rb +0 -21
- data/lib/route_translator/locale_sanitizer.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ba0fdafb1a82378946c98b7c75a8c659fa83daba8254def31c34a73d8ac243c
|
4
|
+
data.tar.gz: dd8f448c13448b158d5511e36ebba28bbfd6a2a8eaa2f1f7b387d803d735b654
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cb4821500c0ca720fb8dac607c8d349f67e54fa2b9424b5418241e29526bcc6632fd19b8420ab4ff52195eb61cbb0adc6cb9084b43005a17d8f2bc0ab177e47
|
7
|
+
data.tar.gz: 56ddc940436e550ed783bd0b83ced6418ecb06ff1a5a5332218b1d4f1e02e051c825c7020aa22eca795477d1c7d250bd2a064de94bd61f76e5393d790e73ee58
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,33 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 10.0.0 / 2021-01-16
|
4
|
+
|
5
|
+
* [BUGFIX] Verify host path consistency by default ([#91](https://github.com/enriclluelles/route_translator/issues/91), [#171](https://github.com/enriclluelles/route_translator/issues/171))
|
6
|
+
* [FEATURE] Remove the option to verify host path consistency
|
7
|
+
* [ENHANCEMENT] Avoid duplicate routes when using host_locales ([#87](https://github.com/enriclluelles/route_translator/issues/87), [#171](https://github.com/enriclluelles/route_translator/issues/171))
|
8
|
+
* [ENHANCEMENT] Test against Ruby 3.0.0
|
9
|
+
* [ENHANCEMENT] Update development dependencies
|
10
|
+
|
11
|
+
## 9.0.0 / 2020-11-07
|
12
|
+
|
13
|
+
* [ENHANCEMENT] Check for `empty?` instead of `any?` on available_locales array
|
14
|
+
* [ENHANCEMENT] Update development dependencies
|
15
|
+
|
16
|
+
## 8.2.1 / 2020-11-03
|
17
|
+
|
18
|
+
* [ENHANCEMENT] Fix deprecation with URI.parser ([#234](https://github.com/enriclluelles/route_translator/pull/234))
|
19
|
+
|
20
|
+
## 8.2.0 / 2020-11-03
|
21
|
+
|
22
|
+
* [FEATURE] Add Rails 6.1 compatibility
|
23
|
+
* [ENHANCEMENT] Update development dependencies
|
24
|
+
|
25
|
+
## 8.1.0 / 2020-08-10
|
26
|
+
|
27
|
+
* [FEATURE] Allow Ruby 3.0.0
|
28
|
+
* [ENHANCEMENT] Test against latest Ruby versions
|
29
|
+
* [ENHANCEMENT] Update development dependencies
|
30
|
+
|
3
31
|
## 8.0.0 / 2020-04-17
|
4
32
|
|
5
33
|
* [FEATURE] Drop Ruby 2.3 support
|
data/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2007 Raul Murciano [http://raul.murciano.net], Domestika INTERNET S.L. [http://domestika.org], 2015 Enric Lluelles [http://enric.lluell.es],
|
3
|
+
Copyright (c) 2007 Raul Murciano [http://raul.murciano.net], Domestika INTERNET S.L. [http://domestika.org], 2015 Enric Lluelles [http://enric.lluell.es], 2021 Geremia Taglialatela
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# RouteTranslator
|
2
2
|
|
3
3
|
[](https://badge.fury.io/rb/route_translator)
|
4
|
+
[](https://dependabot.com/compatibility-score.html?dependency-name=route_translator&package-manager=bundler&version-scheme=semver)
|
4
5
|
[](https://travis-ci.org/enriclluelles/route_translator)
|
5
6
|
[](https://codeclimate.com/github/enriclluelles/route_translator/maintainability)
|
6
7
|
[](https://coveralls.io/github/enriclluelles/route_translator?branch=master)
|
@@ -9,7 +10,7 @@ RouteTranslator is a gem to allow you to manage the translations of your app rou
|
|
9
10
|
|
10
11
|
It started as a fork of the awesome [translate_routes](https://github.com/raul/translate_routes) plugin by [Raúl Murciano](https://github.com/raul).
|
11
12
|
|
12
|
-
Right now it works with Rails 5.x and Rails 6.
|
13
|
+
Right now it works with Rails 5.x and Rails 6.x
|
13
14
|
|
14
15
|
|
15
16
|
|
@@ -144,6 +145,21 @@ Right now it works with Rails 5.x and Rails 6.0
|
|
144
145
|
Note: you might be tempted to use `before_action` instead of `around_action`: just don't. That could lead to [thread-related issues](https://github.com/enriclluelles/route_translator/issues/44).
|
145
146
|
|
146
147
|
|
148
|
+
### Changing the Language
|
149
|
+
|
150
|
+
To change the language and reload the appropriate route while staying on the same page, use the following code snippet:
|
151
|
+
|
152
|
+
```ruby
|
153
|
+
link_to url_for(locale: 'es'), hreflang: 'es', rel: 'alternate'
|
154
|
+
```
|
155
|
+
|
156
|
+
Although locales are stored by Rails as a symbol (`:es`), when linking to a page in a different locale you need to use a string (`'es'`). Otherwise, instead of a namespaced route (`/es/my-route`) you will get a parameterized route (`/my-route?locale=es`).
|
157
|
+
|
158
|
+
If the page contains a localized slug, the above snippet does not work and a custom implementation is neede.
|
159
|
+
|
160
|
+
More information at [Generating translated URLs](https://github.com/enriclluelles/route_translator/wiki/Generating-translated-URLs)
|
161
|
+
|
162
|
+
|
147
163
|
### Namespaces
|
148
164
|
|
149
165
|
You can translate a namespace route by either its `name` or `path` option:
|
@@ -265,7 +281,6 @@ end
|
|
265
281
|
| `host_locales` | Sets `I18n.locale` based on `request.host`. Useful for apps accepting requests from more than one domain. See below for more details | `{}` |
|
266
282
|
| `locale_param_key` | The param key used to set the locale to the newly generated routes | `:locale` |
|
267
283
|
| `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` |
|
268
|
-
| `verify_host_path_consistency` | Forces a matching of the host associated locale with the translated path locale as part of the route definition. By default, if you use different hosts to translate your application, all translated paths will work on all hosts | `false` |
|
269
284
|
|
270
285
|
|
271
286
|
### Host-based Locale
|
@@ -297,13 +312,13 @@ RouteTranslator.config.host_locales = { 'russia.*' => :ru, '*.com' => :en } #
|
|
297
312
|
RouteTranslator.config.host_locales = { '*.com' => :en, 'russia.*' => :ru } # 'russia.com' will have locale :en
|
298
313
|
```
|
299
314
|
|
300
|
-
If `host_locales` option is set, the following options will be forced
|
315
|
+
If `host_locales` option is set, the following options will be forced:
|
301
316
|
|
302
317
|
```ruby
|
303
318
|
@config.force_locale = false
|
304
319
|
@config.generate_unlocalized_routes = false
|
305
320
|
@config.generate_unnamed_unlocalized_routes = false
|
306
|
-
@config.hide_locale =
|
321
|
+
@config.hide_locale = true
|
307
322
|
```
|
308
323
|
|
309
324
|
This is to avoid odd behaviour brought about by route conflicts and because `host_locales` forces and hides the host-locale dynamically.
|
data/lib/route_translator.rb
CHANGED
@@ -6,8 +6,6 @@ require 'addressable/uri'
|
|
6
6
|
require 'route_translator/extensions'
|
7
7
|
require 'route_translator/translator'
|
8
8
|
require 'route_translator/host'
|
9
|
-
require 'route_translator/host_path_consistency_lambdas'
|
10
|
-
require 'route_translator/locale_sanitizer'
|
11
9
|
|
12
10
|
module RouteTranslator
|
13
11
|
extend RouteTranslator::Host
|
@@ -23,8 +21,7 @@ module RouteTranslator
|
|
23
21
|
hide_locale: false,
|
24
22
|
host_locales: {},
|
25
23
|
locale_param_key: :locale,
|
26
|
-
locale_segment_proc: false
|
27
|
-
verify_host_path_consistency: false
|
24
|
+
locale_segment_proc: false
|
28
25
|
}.freeze
|
29
26
|
|
30
27
|
Configuration = Struct.new(*DEFAULT_CONFIGURATION.keys)
|
@@ -36,7 +33,7 @@ module RouteTranslator
|
|
36
33
|
@config.force_locale = false
|
37
34
|
@config.generate_unlocalized_routes = false
|
38
35
|
@config.generate_unnamed_unlocalized_routes = false
|
39
|
-
@config.hide_locale =
|
36
|
+
@config.hide_locale = true
|
40
37
|
end
|
41
38
|
end
|
42
39
|
|
@@ -65,10 +62,10 @@ module RouteTranslator
|
|
65
62
|
def available_locales
|
66
63
|
locales = config.available_locales
|
67
64
|
|
68
|
-
if locales.
|
69
|
-
locales.map(&:to_sym)
|
70
|
-
else
|
65
|
+
if locales.empty?
|
71
66
|
I18n.available_locales.dup
|
67
|
+
else
|
68
|
+
locales.map(&:to_sym)
|
72
69
|
end
|
73
70
|
end
|
74
71
|
|
@@ -11,7 +11,7 @@ module ActionDispatch
|
|
11
11
|
@localized = false
|
12
12
|
end
|
13
13
|
|
14
|
-
# rubocop:disable Lint/UnderscorePrefixedVariableName
|
14
|
+
# rubocop:disable Lint/UnderscorePrefixedVariableName, Metrics/PerceivedComplexity
|
15
15
|
def add_route(action, controller, options, _path, to, via, formatted, anchor, options_constraints) # :nodoc:
|
16
16
|
return super unless @localized
|
17
17
|
|
@@ -28,19 +28,19 @@ module ActionDispatch
|
|
28
28
|
action = nil
|
29
29
|
end
|
30
30
|
|
31
|
-
as = if
|
32
|
-
options.delete(:as)
|
33
|
-
else
|
31
|
+
as = if options.fetch(:as, true)
|
34
32
|
name_for_action(options.delete(:as), action)
|
33
|
+
else
|
34
|
+
options.delete(:as)
|
35
35
|
end
|
36
36
|
|
37
|
-
path = Mapping.normalize_path URI.
|
37
|
+
path = Mapping.normalize_path URI::DEFAULT_PARSER.escape(path), formatted
|
38
38
|
ast = Journey::Parser.parse path
|
39
39
|
|
40
40
|
mapping = Mapping.build(@scope, @set, ast, controller, default_action, to, via, formatted, options_constraints, anchor, options)
|
41
41
|
@set.add_localized_route(mapping, ast, as, anchor, @scope, path, controller, default_action, to, via, formatted, options_constraints, options)
|
42
42
|
end
|
43
|
-
# rubocop:enable Lint/UnderscorePrefixedVariableName
|
43
|
+
# rubocop:enable Lint/UnderscorePrefixedVariableName, Metrics/PerceivedComplexity
|
44
44
|
|
45
45
|
private
|
46
46
|
|
@@ -33,8 +33,8 @@ module ActionDispatch
|
|
33
33
|
options: scope[:options] ? scope[:options].merge(translated_options) : translated_options
|
34
34
|
}
|
35
35
|
|
36
|
-
if RouteTranslator.config.
|
37
|
-
scope_params[:blocks].push RouteTranslator::
|
36
|
+
if RouteTranslator.config.host_locales.present?
|
37
|
+
scope_params[:blocks].push RouteTranslator::Host.lambdas_for_locale(locale)
|
38
38
|
end
|
39
39
|
|
40
40
|
::ActionDispatch::Routing::Mapper::Mapping.build scope_params, route_set, translated_path_ast, controller, default_action, to, via, formatted, translated_options_constraints, anchor, translated_options
|
@@ -5,20 +5,16 @@ module RouteTranslator
|
|
5
5
|
class << self
|
6
6
|
private
|
7
7
|
|
8
|
+
def lambdas
|
9
|
+
@lambdas ||= {}
|
10
|
+
end
|
11
|
+
|
8
12
|
def regex_for(host_string)
|
9
13
|
escaped = Regexp.escape(host_string).gsub('\*', '.*?').gsub('\.', '\.?')
|
10
14
|
Regexp.new("^#{escaped}$", Regexp::IGNORECASE)
|
11
15
|
end
|
12
16
|
end
|
13
17
|
|
14
|
-
def native_locale?(locale)
|
15
|
-
locale.to_s.match(/native_/).present?
|
16
|
-
end
|
17
|
-
|
18
|
-
def native_locales
|
19
|
-
config.host_locales.values.map { |locale| :"native_#{locale}" }
|
20
|
-
end
|
21
|
-
|
22
18
|
module_function
|
23
19
|
|
24
20
|
def locale_from_host(host)
|
@@ -28,5 +24,9 @@ module RouteTranslator
|
|
28
24
|
locales &= I18n.available_locales
|
29
25
|
locales.first&.to_sym
|
30
26
|
end
|
27
|
+
|
28
|
+
def lambdas_for_locale(locale)
|
29
|
+
lambdas[locale] ||= ->(req) { locale == RouteTranslator::Host.locale_from_host(req.host) }
|
30
|
+
end
|
31
31
|
end
|
32
32
|
end
|
@@ -26,7 +26,7 @@ module RouteTranslator
|
|
26
26
|
translated_options = options.dup
|
27
27
|
|
28
28
|
if translated_options.exclude?(RouteTranslator.locale_param_key)
|
29
|
-
translated_options[RouteTranslator.locale_param_key] =
|
29
|
+
translated_options[RouteTranslator.locale_param_key] = locale.to_s
|
30
30
|
end
|
31
31
|
|
32
32
|
translated_options
|
@@ -53,7 +53,6 @@ module RouteTranslator
|
|
53
53
|
|
54
54
|
def available_locales
|
55
55
|
locales = RouteTranslator.available_locales
|
56
|
-
locales.concat(RouteTranslator.native_locales) if RouteTranslator.native_locales.present?
|
57
56
|
# Make sure the default locale is translated in last place to avoid
|
58
57
|
# problems with wildcards when default locale is omitted in paths. The
|
59
58
|
# default routes will catch all paths like wildcard if it is translated first.
|
@@ -82,8 +81,6 @@ module RouteTranslator
|
|
82
81
|
|
83
82
|
locale = if args_locale
|
84
83
|
args_locale.to_s.underscore
|
85
|
-
elsif kaller.respond_to?("#{old_name}_native_#{current_locale_name}_#{suffix}")
|
86
|
-
"native_#{current_locale_name}"
|
87
84
|
elsif kaller.respond_to?("#{old_name}_#{current_locale_name}_#{suffix}")
|
88
85
|
current_locale_name
|
89
86
|
else
|
@@ -9,8 +9,7 @@ module RouteTranslator
|
|
9
9
|
private
|
10
10
|
|
11
11
|
def display_locale?(locale)
|
12
|
-
!RouteTranslator.config.hide_locale && !
|
13
|
-
(!default_locale?(locale) || config_requires_locale?)
|
12
|
+
!RouteTranslator.config.hide_locale && (!default_locale?(locale) || config_requires_locale?)
|
14
13
|
end
|
15
14
|
|
16
15
|
def config_requires_locale?
|
@@ -24,16 +24,15 @@ module RouteTranslator
|
|
24
24
|
handler = proc { |exception| exception }
|
25
25
|
opts = { locale: locale, scope: scope }
|
26
26
|
|
27
|
-
if I18n.
|
28
|
-
I18n.
|
27
|
+
if I18n.t(str, **opts.merge(exception_handler: handler)).is_a?(I18n::MissingTranslation)
|
28
|
+
I18n.t str, **opts.merge(fallback_options(str, locale))
|
29
29
|
else
|
30
|
-
I18n.
|
30
|
+
I18n.t str, **opts
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
34
|
def translate_string(str, locale, scope)
|
35
|
-
|
36
|
-
translated_resource = translate_resource(str, sanitized_locale, scope)
|
35
|
+
translated_resource = translate_resource(str, locale.to_s, scope)
|
37
36
|
|
38
37
|
Addressable::URI.normalize_component translated_resource
|
39
38
|
end
|
@@ -51,12 +50,12 @@ module RouteTranslator
|
|
51
50
|
def translate(segment, locale, scope)
|
52
51
|
return segment if segment.empty?
|
53
52
|
|
54
|
-
if segment.
|
53
|
+
if segment.start_with?(':')
|
55
54
|
named_param, hyphenized = segment.split('-', 2)
|
56
55
|
return "#{named_param}-#{translate(hyphenized, locale, scope)}" if hyphenized
|
57
56
|
end
|
58
57
|
|
59
|
-
return segment if segment.
|
58
|
+
return segment if segment.start_with?('(', '*') || segment.include?(':')
|
60
59
|
|
61
60
|
appended_part = segment.slice!(/(\()$/)
|
62
61
|
str = translatable_segment(segment)
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: route_translator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 10.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Geremia Taglialatela
|
8
8
|
- Enric Lluelles
|
9
9
|
- Raul Murciano
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-01-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: actionpack
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: 5.0.0.1
|
22
22
|
- - "<"
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: '6.
|
24
|
+
version: '6.2'
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
27
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -31,7 +31,7 @@ dependencies:
|
|
31
31
|
version: 5.0.0.1
|
32
32
|
- - "<"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '6.
|
34
|
+
version: '6.2'
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: activesupport
|
37
37
|
requirement: !ruby/object:Gem::Requirement
|
@@ -41,7 +41,7 @@ dependencies:
|
|
41
41
|
version: 5.0.0.1
|
42
42
|
- - "<"
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
version: '6.
|
44
|
+
version: '6.2'
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
47
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -51,7 +51,7 @@ dependencies:
|
|
51
51
|
version: 5.0.0.1
|
52
52
|
- - "<"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '6.
|
54
|
+
version: '6.2'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: addressable
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '2.
|
75
|
+
version: '2.3'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '2.
|
82
|
+
version: '2.3'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: byebug
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -106,14 +106,14 @@ dependencies:
|
|
106
106
|
requirements:
|
107
107
|
- - "~>"
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: 0.
|
109
|
+
version: 0.20.0
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
112
|
version_requirements: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
114
|
- - "~>"
|
115
115
|
- !ruby/object:Gem::Version
|
116
|
-
version: 0.
|
116
|
+
version: 0.20.0
|
117
117
|
- !ruby/object:Gem::Dependency
|
118
118
|
name: minitest
|
119
119
|
requirement: !ruby/object:Gem::Requirement
|
@@ -137,7 +137,7 @@ dependencies:
|
|
137
137
|
version: 5.0.0.1
|
138
138
|
- - "<"
|
139
139
|
- !ruby/object:Gem::Version
|
140
|
-
version: '6.
|
140
|
+
version: '6.2'
|
141
141
|
type: :development
|
142
142
|
prerelease: false
|
143
143
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -147,7 +147,7 @@ dependencies:
|
|
147
147
|
version: 5.0.0.1
|
148
148
|
- - "<"
|
149
149
|
- !ruby/object:Gem::Version
|
150
|
-
version: '6.
|
150
|
+
version: '6.2'
|
151
151
|
- !ruby/object:Gem::Dependency
|
152
152
|
name: rake
|
153
153
|
requirement: !ruby/object:Gem::Requirement
|
@@ -168,56 +168,90 @@ dependencies:
|
|
168
168
|
requirements:
|
169
169
|
- - "~>"
|
170
170
|
- !ruby/object:Gem::Version
|
171
|
-
version:
|
171
|
+
version: '1.8'
|
172
172
|
type: :development
|
173
173
|
prerelease: false
|
174
174
|
version_requirements: !ruby/object:Gem::Requirement
|
175
175
|
requirements:
|
176
176
|
- - "~>"
|
177
177
|
- !ruby/object:Gem::Version
|
178
|
-
version:
|
178
|
+
version: '1.8'
|
179
|
+
- !ruby/object:Gem::Dependency
|
180
|
+
name: rubocop-minitest
|
181
|
+
requirement: !ruby/object:Gem::Requirement
|
182
|
+
requirements:
|
183
|
+
- - "~>"
|
184
|
+
- !ruby/object:Gem::Version
|
185
|
+
version: 0.10.3
|
186
|
+
type: :development
|
187
|
+
prerelease: false
|
188
|
+
version_requirements: !ruby/object:Gem::Requirement
|
189
|
+
requirements:
|
190
|
+
- - "~>"
|
191
|
+
- !ruby/object:Gem::Version
|
192
|
+
version: 0.10.3
|
179
193
|
- !ruby/object:Gem::Dependency
|
180
194
|
name: rubocop-performance
|
181
195
|
requirement: !ruby/object:Gem::Requirement
|
182
196
|
requirements:
|
183
197
|
- - "~>"
|
184
198
|
- !ruby/object:Gem::Version
|
185
|
-
version: '1.
|
199
|
+
version: '1.9'
|
186
200
|
type: :development
|
187
201
|
prerelease: false
|
188
202
|
version_requirements: !ruby/object:Gem::Requirement
|
189
203
|
requirements:
|
190
204
|
- - "~>"
|
191
205
|
- !ruby/object:Gem::Version
|
192
|
-
version: '1.
|
206
|
+
version: '1.9'
|
193
207
|
- !ruby/object:Gem::Dependency
|
194
208
|
name: rubocop-rails
|
195
209
|
requirement: !ruby/object:Gem::Requirement
|
196
210
|
requirements:
|
197
211
|
- - "~>"
|
198
212
|
- !ruby/object:Gem::Version
|
199
|
-
version: '2.
|
213
|
+
version: '2.9'
|
200
214
|
type: :development
|
201
215
|
prerelease: false
|
202
216
|
version_requirements: !ruby/object:Gem::Requirement
|
203
217
|
requirements:
|
204
218
|
- - "~>"
|
205
219
|
- !ruby/object:Gem::Version
|
206
|
-
version: '2.
|
220
|
+
version: '2.9'
|
207
221
|
- !ruby/object:Gem::Dependency
|
208
|
-
name:
|
222
|
+
name: rubocop-rake
|
209
223
|
requirement: !ruby/object:Gem::Requirement
|
210
224
|
requirements:
|
211
225
|
- - "~>"
|
212
226
|
- !ruby/object:Gem::Version
|
213
|
-
version: 0.
|
227
|
+
version: 0.5.1
|
214
228
|
type: :development
|
215
229
|
prerelease: false
|
216
230
|
version_requirements: !ruby/object:Gem::Requirement
|
217
231
|
requirements:
|
218
232
|
- - "~>"
|
233
|
+
- !ruby/object:Gem::Version
|
234
|
+
version: 0.5.1
|
235
|
+
- !ruby/object:Gem::Dependency
|
236
|
+
name: simplecov
|
237
|
+
requirement: !ruby/object:Gem::Requirement
|
238
|
+
requirements:
|
239
|
+
- - ">="
|
219
240
|
- !ruby/object:Gem::Version
|
220
241
|
version: 0.18.5
|
242
|
+
- - "<"
|
243
|
+
- !ruby/object:Gem::Version
|
244
|
+
version: '0.22'
|
245
|
+
type: :development
|
246
|
+
prerelease: false
|
247
|
+
version_requirements: !ruby/object:Gem::Requirement
|
248
|
+
requirements:
|
249
|
+
- - ">="
|
250
|
+
- !ruby/object:Gem::Version
|
251
|
+
version: 0.18.5
|
252
|
+
- - "<"
|
253
|
+
- !ruby/object:Gem::Version
|
254
|
+
version: '0.22'
|
221
255
|
description: Translates the Rails routes of your application into the languages defined
|
222
256
|
in your locale files
|
223
257
|
email:
|
@@ -237,8 +271,6 @@ files:
|
|
237
271
|
- lib/route_translator/extensions/route_set.rb
|
238
272
|
- lib/route_translator/extensions/test_case.rb
|
239
273
|
- lib/route_translator/host.rb
|
240
|
-
- lib/route_translator/host_path_consistency_lambdas.rb
|
241
|
-
- lib/route_translator/locale_sanitizer.rb
|
242
274
|
- lib/route_translator/route.rb
|
243
275
|
- lib/route_translator/translator.rb
|
244
276
|
- lib/route_translator/translator/path.rb
|
@@ -252,13 +284,13 @@ metadata:
|
|
252
284
|
bug_tracker_uri: https://github.com/enriclluelles/route_translator/issues
|
253
285
|
changelog_uri: https://github.com/enriclluelles/route_translator/blob/master/CHANGELOG.md
|
254
286
|
source_code_uri: https://github.com/enriclluelles/route_translator
|
255
|
-
post_install_message:
|
287
|
+
post_install_message:
|
256
288
|
rdoc_options: []
|
257
289
|
require_paths:
|
258
290
|
- lib
|
259
291
|
required_ruby_version: !ruby/object:Gem::Requirement
|
260
292
|
requirements:
|
261
|
-
- - "
|
293
|
+
- - ">="
|
262
294
|
- !ruby/object:Gem::Version
|
263
295
|
version: '2.4'
|
264
296
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
@@ -267,8 +299,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
267
299
|
- !ruby/object:Gem::Version
|
268
300
|
version: '0'
|
269
301
|
requirements: []
|
270
|
-
rubygems_version: 3.
|
271
|
-
signing_key:
|
302
|
+
rubygems_version: 3.2.3
|
303
|
+
signing_key:
|
272
304
|
specification_version: 4
|
273
305
|
summary: Translate your Rails routes in a simple manner
|
274
306
|
test_files: []
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RouteTranslator
|
4
|
-
module HostPathConsistencyLambdas
|
5
|
-
class << self
|
6
|
-
private
|
7
|
-
|
8
|
-
def lambdas
|
9
|
-
@lambdas ||= {}
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
module_function
|
14
|
-
|
15
|
-
def for_locale(locale)
|
16
|
-
sanitized_locale = RouteTranslator::LocaleSanitizer.sanitize(locale)
|
17
|
-
|
18
|
-
lambdas[sanitized_locale] ||= ->(req) { sanitized_locale == RouteTranslator::Host.locale_from_host(req.host).to_s }
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|