translatable_routes 1.4.0 → 4.0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- metadata +14 -140
- data/MIT-LICENSE +0 -20
- data/README.md +0 -66
- data/Rakefile +0 -32
- data/lib/translatable_routes/action_dispatch/mapper.rb +0 -91
- data/lib/translatable_routes/action_dispatch/named_route_collection.rb +0 -35
- data/lib/translatable_routes/railtie.rb +0 -16
- data/lib/translatable_routes/version.rb +0 -5
- data/lib/translatable_routes.rb +0 -6
- data/test/dummy/README.rdoc +0 -28
- data/test/dummy/Rakefile +0 -6
- data/test/dummy/app/assets/javascripts/application.js +0 -13
- data/test/dummy/app/assets/stylesheets/application.css +0 -13
- data/test/dummy/app/controllers/application_controller.rb +0 -5
- data/test/dummy/app/controllers/namespace/pages_controller.rb +0 -6
- data/test/dummy/app/controllers/namespace/resources_controller.rb +0 -6
- data/test/dummy/app/controllers/nesteds_controller.rb +0 -6
- data/test/dummy/app/controllers/pages_controller.rb +0 -12
- data/test/dummy/app/controllers/resources_controller.rb +0 -6
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/test/dummy/bin/bundle +0 -3
- data/test/dummy/bin/rails +0 -4
- data/test/dummy/bin/rake +0 -4
- data/test/dummy/config/application.rb +0 -22
- data/test/dummy/config/boot.rb +0 -5
- data/test/dummy/config/database.yml +0 -25
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -29
- data/test/dummy/config/environments/production.rb +0 -84
- data/test/dummy/config/environments/test.rb +0 -44
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/test/dummy/config/initializers/inflections.rb +0 -16
- data/test/dummy/config/initializers/mime_types.rb +0 -5
- data/test/dummy/config/initializers/secret_token.rb +0 -13
- data/test/dummy/config/initializers/session_store.rb +0 -3
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/locales/en.yml +0 -10
- data/test/dummy/config/locales/es.yml +0 -10
- data/test/dummy/config/routes.rb +0 -70
- data/test/dummy/config.ru +0 -4
- data/test/dummy/db/schema.rb +0 -16
- data/test/dummy/log/development.log +0 -0
- data/test/dummy/log/test.log +0 -324
- data/test/dummy/public/404.html +0 -58
- data/test/dummy/public/422.html +0 -58
- data/test/dummy/public/500.html +0 -57
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/helpers_test.rb +0 -60
- data/test/routes_test.rb +0 -59
- data/test/test_helper.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: baa156af6077f2db513a314c1575b102fa378537
|
4
|
+
data.tar.gz: 49af524ee4b121b3fc6a52d397e53b977b636f32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fec7c9391134cb2ccb5388a517e5a798f64608e75b052af35a7fc74b368b3a58ce35aca0456fc6e9486edba9588baf70c5f7c5926b1ef194696c86923751d8c3
|
7
|
+
data.tar.gz: b8944ca6666ce1f0488c493d1dfc2a87aecee1ccf080211e998a1d1d549e600c6f824833e1b2df5364791c165197eb888ae5b300895b10cce9bf5469c088d4d8
|
metadata
CHANGED
@@ -1,118 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: translatable_routes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mmontossi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: localizable_routes
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 4.3.0
|
19
|
+
version: '0'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
24
|
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
30
|
-
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 4.3.0
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: sqlite3
|
35
|
-
requirement: !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - "~>"
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '1.3'
|
40
|
-
type: :development
|
41
|
-
prerelease: false
|
42
|
-
version_requirements: !ruby/object:Gem::Requirement
|
43
|
-
requirements:
|
44
|
-
- - "~>"
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: '1.3'
|
47
|
-
description: Minimalistic toolkit to translate routes in rails.
|
26
|
+
version: '0'
|
27
|
+
description: Flexible toolkit to localize routes in rails.
|
48
28
|
email:
|
49
|
-
- mmontossi@
|
29
|
+
- mmontossi@gmail.com
|
50
30
|
executables: []
|
51
31
|
extensions: []
|
52
32
|
extra_rdoc_files: []
|
53
|
-
files:
|
54
|
-
|
55
|
-
- README.md
|
56
|
-
- Rakefile
|
57
|
-
- lib/translatable_routes.rb
|
58
|
-
- lib/translatable_routes/action_dispatch/mapper.rb
|
59
|
-
- lib/translatable_routes/action_dispatch/named_route_collection.rb
|
60
|
-
- lib/translatable_routes/railtie.rb
|
61
|
-
- lib/translatable_routes/version.rb
|
62
|
-
- test/dummy/README.rdoc
|
63
|
-
- test/dummy/Rakefile
|
64
|
-
- test/dummy/app/assets/javascripts/application.js
|
65
|
-
- test/dummy/app/assets/stylesheets/application.css
|
66
|
-
- test/dummy/app/controllers/application_controller.rb
|
67
|
-
- test/dummy/app/controllers/namespace/pages_controller.rb
|
68
|
-
- test/dummy/app/controllers/namespace/resources_controller.rb
|
69
|
-
- test/dummy/app/controllers/nesteds_controller.rb
|
70
|
-
- test/dummy/app/controllers/pages_controller.rb
|
71
|
-
- test/dummy/app/controllers/resources_controller.rb
|
72
|
-
- test/dummy/app/helpers/application_helper.rb
|
73
|
-
- test/dummy/app/views/layouts/application.html.erb
|
74
|
-
- test/dummy/bin/bundle
|
75
|
-
- test/dummy/bin/rails
|
76
|
-
- test/dummy/bin/rake
|
77
|
-
- test/dummy/config.ru
|
78
|
-
- test/dummy/config/application.rb
|
79
|
-
- test/dummy/config/boot.rb
|
80
|
-
- test/dummy/config/database.yml
|
81
|
-
- test/dummy/config/environment.rb
|
82
|
-
- test/dummy/config/environments/development.rb
|
83
|
-
- test/dummy/config/environments/production.rb
|
84
|
-
- test/dummy/config/environments/test.rb
|
85
|
-
- test/dummy/config/initializers/backtrace_silencers.rb
|
86
|
-
- test/dummy/config/initializers/filter_parameter_logging.rb
|
87
|
-
- test/dummy/config/initializers/inflections.rb
|
88
|
-
- test/dummy/config/initializers/mime_types.rb
|
89
|
-
- test/dummy/config/initializers/secret_token.rb
|
90
|
-
- test/dummy/config/initializers/session_store.rb
|
91
|
-
- test/dummy/config/initializers/wrap_parameters.rb
|
92
|
-
- test/dummy/config/locales/en.yml
|
93
|
-
- test/dummy/config/locales/es.yml
|
94
|
-
- test/dummy/config/routes.rb
|
95
|
-
- test/dummy/db/schema.rb
|
96
|
-
- test/dummy/log/development.log
|
97
|
-
- test/dummy/log/test.log
|
98
|
-
- test/dummy/public/404.html
|
99
|
-
- test/dummy/public/422.html
|
100
|
-
- test/dummy/public/500.html
|
101
|
-
- test/dummy/public/favicon.ico
|
102
|
-
- test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705
|
103
|
-
- test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af
|
104
|
-
- test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953
|
105
|
-
- test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994
|
106
|
-
- test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6
|
107
|
-
- test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655
|
108
|
-
- test/helpers_test.rb
|
109
|
-
- test/routes_test.rb
|
110
|
-
- test/test_helper.rb
|
111
|
-
homepage: https://github.com/mmontossi/translatable_routes
|
33
|
+
files: []
|
34
|
+
homepage: https://github.com/mmontossi/localizable_routes
|
112
35
|
licenses:
|
113
36
|
- MIT
|
114
37
|
metadata: {}
|
115
|
-
post_install_message:
|
38
|
+
post_install_message: 'THIS GEM HAS BEEN RENAMED TO: localizable_routes'
|
116
39
|
rdoc_options: []
|
117
40
|
require_paths:
|
118
41
|
- lib
|
@@ -120,7 +43,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
120
43
|
requirements:
|
121
44
|
- - ">="
|
122
45
|
- !ruby/object:Gem::Version
|
123
|
-
version:
|
46
|
+
version: '0'
|
124
47
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
48
|
requirements:
|
126
49
|
- - ">="
|
@@ -128,57 +51,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
51
|
version: '0'
|
129
52
|
requirements: []
|
130
53
|
rubyforge_project:
|
131
|
-
rubygems_version: 2.
|
54
|
+
rubygems_version: 2.5.1
|
132
55
|
signing_key:
|
133
56
|
specification_version: 4
|
134
|
-
summary:
|
135
|
-
test_files:
|
136
|
-
- test/dummy/app/assets/javascripts/application.js
|
137
|
-
- test/dummy/app/assets/stylesheets/application.css
|
138
|
-
- test/dummy/app/controllers/application_controller.rb
|
139
|
-
- test/dummy/app/controllers/namespace/pages_controller.rb
|
140
|
-
- test/dummy/app/controllers/namespace/resources_controller.rb
|
141
|
-
- test/dummy/app/controllers/nesteds_controller.rb
|
142
|
-
- test/dummy/app/controllers/pages_controller.rb
|
143
|
-
- test/dummy/app/controllers/resources_controller.rb
|
144
|
-
- test/dummy/app/helpers/application_helper.rb
|
145
|
-
- test/dummy/app/views/layouts/application.html.erb
|
146
|
-
- test/dummy/bin/bundle
|
147
|
-
- test/dummy/bin/rails
|
148
|
-
- test/dummy/bin/rake
|
149
|
-
- test/dummy/config/application.rb
|
150
|
-
- test/dummy/config/boot.rb
|
151
|
-
- test/dummy/config/database.yml
|
152
|
-
- test/dummy/config/environment.rb
|
153
|
-
- test/dummy/config/environments/development.rb
|
154
|
-
- test/dummy/config/environments/production.rb
|
155
|
-
- test/dummy/config/environments/test.rb
|
156
|
-
- test/dummy/config/initializers/backtrace_silencers.rb
|
157
|
-
- test/dummy/config/initializers/filter_parameter_logging.rb
|
158
|
-
- test/dummy/config/initializers/inflections.rb
|
159
|
-
- test/dummy/config/initializers/mime_types.rb
|
160
|
-
- test/dummy/config/initializers/secret_token.rb
|
161
|
-
- test/dummy/config/initializers/session_store.rb
|
162
|
-
- test/dummy/config/initializers/wrap_parameters.rb
|
163
|
-
- test/dummy/config/locales/en.yml
|
164
|
-
- test/dummy/config/locales/es.yml
|
165
|
-
- test/dummy/config/routes.rb
|
166
|
-
- test/dummy/config.ru
|
167
|
-
- test/dummy/db/schema.rb
|
168
|
-
- test/dummy/log/development.log
|
169
|
-
- test/dummy/log/test.log
|
170
|
-
- test/dummy/public/404.html
|
171
|
-
- test/dummy/public/422.html
|
172
|
-
- test/dummy/public/500.html
|
173
|
-
- test/dummy/public/favicon.ico
|
174
|
-
- test/dummy/Rakefile
|
175
|
-
- test/dummy/README.rdoc
|
176
|
-
- test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705
|
177
|
-
- test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af
|
178
|
-
- test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953
|
179
|
-
- test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994
|
180
|
-
- test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6
|
181
|
-
- test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655
|
182
|
-
- test/helpers_test.rb
|
183
|
-
- test/routes_test.rb
|
184
|
-
- test/test_helper.rb
|
57
|
+
summary: Localizable routes for rails.
|
58
|
+
test_files: []
|
data/MIT-LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright 2015 Mathías Montossi
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
[![Gem Version](https://badge.fury.io/rb/translatable_routes.svg)](http://badge.fury.io/rb/translatable_routes)
|
2
|
-
[![Code Climate](https://codeclimate.com/github/mmontossi/translatable_routes/badges/gpa.svg)](https://codeclimate.com/github/mmontossi/translatable_routes)
|
3
|
-
[![Build Status](https://travis-ci.org/mmontossi/translatable_routes.svg)](https://travis-ci.org/mmontossi/translatable_routes)
|
4
|
-
[![Dependency Status](https://gemnasium.com/mmontossi/translatable_routes.svg)](https://gemnasium.com/mmontossi/translatable_routes)
|
5
|
-
|
6
|
-
# Translatable Routes
|
7
|
-
|
8
|
-
Minimalistic toolkit to translate routes in rails.
|
9
|
-
|
10
|
-
## Install
|
11
|
-
|
12
|
-
Put this line in your Gemfile:
|
13
|
-
```ruby
|
14
|
-
gem 'translatable_routes'
|
15
|
-
```
|
16
|
-
|
17
|
-
Then bundle:
|
18
|
-
```
|
19
|
-
$ bundle
|
20
|
-
```
|
21
|
-
|
22
|
-
## Configuration
|
23
|
-
|
24
|
-
In your config/routes.rb use the localized method to decide wich routes will be localized:
|
25
|
-
```ruby
|
26
|
-
localized do
|
27
|
-
get 'about' => 'pages#about'
|
28
|
-
end
|
29
|
-
```
|
30
|
-
|
31
|
-
Put your translations inside the routes key in your locales yamls:
|
32
|
-
```yaml
|
33
|
-
es:
|
34
|
-
routes:
|
35
|
-
users: "usuarios"
|
36
|
-
profile: "perfil"
|
37
|
-
about: "nosotros"
|
38
|
-
```
|
39
|
-
|
40
|
-
NOTE: There is no need to put the full path, just translate each part individually.
|
41
|
-
|
42
|
-
## Usage
|
43
|
-
|
44
|
-
Helpers will continue working the same but I18n.locale will be use as default locale:
|
45
|
-
```ruby
|
46
|
-
about_path # Will output /en/about in case I18n.locale is :en
|
47
|
-
```
|
48
|
-
|
49
|
-
Here is an example of what you may want to add to your controllers to select the current locale:
|
50
|
-
```ruby
|
51
|
-
before_action :select_locale
|
52
|
-
|
53
|
-
protected
|
54
|
-
|
55
|
-
def select_locale
|
56
|
-
I18n.locale = params[:locale]
|
57
|
-
end
|
58
|
-
```
|
59
|
-
|
60
|
-
## Credits
|
61
|
-
|
62
|
-
This gem is maintained and funded by [mmontossi](https://github.com/mmontossi).
|
63
|
-
|
64
|
-
## License
|
65
|
-
|
66
|
-
It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
|
data/Rakefile
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require 'bundler/setup'
|
3
|
-
rescue LoadError
|
4
|
-
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
-
end
|
6
|
-
|
7
|
-
require 'rdoc/task'
|
8
|
-
|
9
|
-
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
-
rdoc.rdoc_dir = 'rdoc'
|
11
|
-
rdoc.title = 'TranslatableRoutes'
|
12
|
-
rdoc.options << '--line-numbers'
|
13
|
-
rdoc.rdoc_files.include('README.rdoc')
|
14
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
-
end
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
Bundler::GemHelper.install_tasks
|
21
|
-
|
22
|
-
require 'rake/testtask'
|
23
|
-
|
24
|
-
Rake::TestTask.new(:test) do |t|
|
25
|
-
t.libs << 'lib'
|
26
|
-
t.libs << 'test'
|
27
|
-
t.pattern = 'test/**/*_test.rb'
|
28
|
-
t.verbose = false
|
29
|
-
end
|
30
|
-
|
31
|
-
|
32
|
-
task default: :test
|
@@ -1,91 +0,0 @@
|
|
1
|
-
module TranslatableRoutes
|
2
|
-
module ActionDispatch
|
3
|
-
module Mapper
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
|
6
|
-
def localized
|
7
|
-
@locales = I18n.available_locales
|
8
|
-
scope(':locale') { yield }
|
9
|
-
@locales = nil
|
10
|
-
end
|
11
|
-
|
12
|
-
def add_route(action, options)
|
13
|
-
if @locales
|
14
|
-
@locales.each do |locale|
|
15
|
-
if @scope[:scope_level_resource] && resource_method_scope?
|
16
|
-
original_scope_level_resource = @scope[:scope_level_resource].dup
|
17
|
-
end
|
18
|
-
if @scope[:path]
|
19
|
-
original_path = @scope[:path].dup
|
20
|
-
end
|
21
|
-
original_path_names = @scope[:path_names].dup
|
22
|
-
original_options = options.dup
|
23
|
-
@scope[:path] = i18n_path(@scope[:path], locale)
|
24
|
-
@scope[:path_names].each do |key, value|
|
25
|
-
@scope[:path_names][key] = i18n_path(value, locale)
|
26
|
-
end
|
27
|
-
options[:path] = i18n_path(options[:path], locale)
|
28
|
-
(options[:constraints] ||= {}).merge!(locale: locale.to_s)
|
29
|
-
(options[:defaults] ||= {}).merge!(locale: locale.to_s)
|
30
|
-
if @scope[:scope_level_resource] && resource_method_scope?
|
31
|
-
resource = @scope[:scope_level_resource].dup
|
32
|
-
%w(collection_name member_name).each do |method|
|
33
|
-
resource.class_eval do
|
34
|
-
define_method method do
|
35
|
-
"#{super()}_#{locale}"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
@scope[:scope_level_resource] = resource
|
40
|
-
else
|
41
|
-
options[:as] = "#{options[:as] || action}_#{locale}"
|
42
|
-
end
|
43
|
-
super i18n_path(action, locale), options
|
44
|
-
if @scope[:scope_level_resource] && resource_method_scope?
|
45
|
-
@scope[:scope_level_resource] = original_scope_level_resource
|
46
|
-
end
|
47
|
-
if @scope[:path]
|
48
|
-
@scope[:path] = original_path
|
49
|
-
end
|
50
|
-
@scope[:path_names] = original_path_names
|
51
|
-
options = original_options
|
52
|
-
end
|
53
|
-
if @scope[:scope_level_resource] && resource_method_scope?
|
54
|
-
helper = name_for_action(options[:as], action)
|
55
|
-
@set.named_routes.define_i18n_url_helper helper
|
56
|
-
else
|
57
|
-
helper = "#{options[:as] || action}"
|
58
|
-
if @scope[:as]
|
59
|
-
helper.prepend "#{@scope[:as]}_"
|
60
|
-
end
|
61
|
-
@set.named_routes.define_i18n_url_helper helper
|
62
|
-
end
|
63
|
-
else
|
64
|
-
super
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
protected
|
69
|
-
|
70
|
-
def i18n_path(path, locale)
|
71
|
-
case path
|
72
|
-
when String
|
73
|
-
path.gsub(/:?[a-z0-9_-]+/) do |match|
|
74
|
-
if match.starts_with?(':')
|
75
|
-
match
|
76
|
-
else
|
77
|
-
I18n.t(
|
78
|
-
"routes.#{match.gsub('-', '_')}",
|
79
|
-
locale: locale.to_s,
|
80
|
-
default: match.gsub('_', '-')
|
81
|
-
)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
when Symbol
|
85
|
-
path
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
module TranslatableRoutes
|
2
|
-
module ActionDispatch
|
3
|
-
module NamedRouteCollection
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
|
6
|
-
def define_i18n_url_helper(name)
|
7
|
-
%w(path url).each do |type|
|
8
|
-
helper = :"#{name}_#{type}"
|
9
|
-
|
10
|
-
if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
|
11
|
-
target = instance_variable_get("@#{type}_helpers_module")
|
12
|
-
else
|
13
|
-
target = @module
|
14
|
-
end
|
15
|
-
|
16
|
-
target.remove_possible_method helper
|
17
|
-
target.module_eval do
|
18
|
-
define_method helper do |*args|
|
19
|
-
options = args.extract_options!
|
20
|
-
suffix = (options[:locale] || url_options[:locale] || I18n.locale).to_s.gsub('-', '_').downcase
|
21
|
-
send "#{name}_#{suffix}_#{type}", *(args << options)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
|
26
|
-
instance_variable_get("@#{type}_helpers") << helper
|
27
|
-
else
|
28
|
-
helpers << helper
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module TranslatableRoutes
|
2
|
-
class Railtie < Rails::Railtie
|
3
|
-
|
4
|
-
initializer 'translatable_routes' do
|
5
|
-
::ActionDispatch::Routing::RouteSet::NamedRouteCollection.send(
|
6
|
-
:include,
|
7
|
-
TranslatableRoutes::ActionDispatch::NamedRouteCollection
|
8
|
-
)
|
9
|
-
::ActionDispatch::Routing::Mapper.send(
|
10
|
-
:include,
|
11
|
-
TranslatableRoutes::ActionDispatch::Mapper
|
12
|
-
)
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
16
|
-
end
|
data/lib/translatable_routes.rb
DELETED
data/test/dummy/README.rdoc
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
== README
|
2
|
-
|
3
|
-
This README would normally document whatever steps are necessary to get the
|
4
|
-
application up and running.
|
5
|
-
|
6
|
-
Things you may want to cover:
|
7
|
-
|
8
|
-
* Ruby version
|
9
|
-
|
10
|
-
* System dependencies
|
11
|
-
|
12
|
-
* Configuration
|
13
|
-
|
14
|
-
* Database creation
|
15
|
-
|
16
|
-
* Database initialization
|
17
|
-
|
18
|
-
* How to run the test suite
|
19
|
-
|
20
|
-
* Services (job queues, cache servers, search engines, etc.)
|
21
|
-
|
22
|
-
* Deployment instructions
|
23
|
-
|
24
|
-
* ...
|
25
|
-
|
26
|
-
|
27
|
-
Please feel free to use a different markup language if you do not plan to run
|
28
|
-
<tt>rake doc:app</tt>.
|
data/test/dummy/Rakefile
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
-
// listed below.
|
3
|
-
//
|
4
|
-
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
-
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
-
//
|
7
|
-
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
-
// compiled file.
|
9
|
-
//
|
10
|
-
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
-
// about supported directives.
|
12
|
-
//
|
13
|
-
//= require_tree .
|
@@ -1,13 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
-
* listed below.
|
4
|
-
*
|
5
|
-
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
-
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
-
*
|
8
|
-
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
-
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
-
*
|
11
|
-
*= require_self
|
12
|
-
*= require_tree .
|
13
|
-
*/
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>Dummy</title>
|
5
|
-
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
|
6
|
-
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
|
7
|
-
<%= csrf_meta_tags %>
|
8
|
-
</head>
|
9
|
-
<body>
|
10
|
-
|
11
|
-
<%= yield %>
|
12
|
-
|
13
|
-
</body>
|
14
|
-
</html>
|
data/test/dummy/bin/bundle
DELETED
data/test/dummy/bin/rails
DELETED
data/test/dummy/bin/rake
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require File.expand_path('../boot', __FILE__)
|
2
|
-
|
3
|
-
require 'rails/all'
|
4
|
-
|
5
|
-
Bundler.require(*Rails.groups)
|
6
|
-
require 'translatable_routes'
|
7
|
-
|
8
|
-
module Dummy
|
9
|
-
class Application < Rails::Application
|
10
|
-
# Settings in config/environments/* take precedence over those specified here.
|
11
|
-
# Application configuration should go into files in config/initializers
|
12
|
-
# -- all .rb files in that directory are automatically loaded.
|
13
|
-
|
14
|
-
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
15
|
-
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
16
|
-
# config.time_zone = 'Central Time (US & Canada)'
|
17
|
-
|
18
|
-
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
19
|
-
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
20
|
-
# config.i18n.default_locale = :de
|
21
|
-
end
|
22
|
-
end
|