route_translator 1.0.1 → 1.0.2
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.
- data/lib/route_translator/version.rb +1 -1
- metadata +2 -10
- data/.travis.yml +0 -7
- data/Gemfile +0 -5
- data/LICENSE +0 -20
- data/README.md +0 -128
- data/Rakefile +0 -22
- data/gemfiles/Gemfile.rails-3.0.x +0 -5
- data/gemfiles/Gemfile.rails-3.1.x +0 -5
- data/route_translator.gemspec +0 -21
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: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-07-
|
13
|
+
date: 2012-07-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: mocha
|
@@ -35,13 +35,6 @@ executables: []
|
|
35
35
|
extensions: []
|
36
36
|
extra_rdoc_files: []
|
37
37
|
files:
|
38
|
-
- .travis.yml
|
39
|
-
- Gemfile
|
40
|
-
- LICENSE
|
41
|
-
- README.md
|
42
|
-
- Rakefile
|
43
|
-
- gemfiles/Gemfile.rails-3.0.x
|
44
|
-
- gemfiles/Gemfile.rails-3.1.x
|
45
38
|
- lib/route_translator.rb
|
46
39
|
- lib/route_translator/route_set.rb
|
47
40
|
- lib/route_translator/route_set/dictionary_management.rb
|
@@ -49,7 +42,6 @@ files:
|
|
49
42
|
- lib/route_translator/route_set/translator.rb
|
50
43
|
- lib/route_translator/version.rb
|
51
44
|
- lib/tasks/route_translator.rake
|
52
|
-
- route_translator.gemspec
|
53
45
|
- test/locales/routes.yml
|
54
46
|
- test/route_translator_test.rb
|
55
47
|
- test/test_helper.rb
|
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2007 Raul Murciano [http://raul.murciano.net], Domestika INTERNET S.L. [http://domestika.org], 2012 Enric Lluelles [http://enric.lluell.es]
|
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,128 +0,0 @@
|
|
1
|
-
RouteTranslator
|
2
|
-
===============
|
3
|
-
|
4
|
-
[](http://travis-ci.org/enriclluelles/route_translator)
|
5
|
-
|
6
|
-
RouteTranslator is a gem to allow you to manage the translations of your
|
7
|
-
app routes with a simple dictionary format
|
8
|
-
|
9
|
-
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) and then I made changes as I needed until it became the actual code
|
10
|
-
|
11
|
-
Right now it works with all the different flavous of rails3 (3.0, 3.1, 3.2) but I'm planning to make it compatible with rails 2.3 too. I'll see how it goes
|
12
|
-
|
13
|
-
|
14
|
-
Quick Start
|
15
|
-
-----------
|
16
|
-
|
17
|
-
1. If you have this `routes.rb` file originally:
|
18
|
-
|
19
|
-
```ruby
|
20
|
-
MyApp::Application.routes.draw do
|
21
|
-
|
22
|
-
namespace :admin do
|
23
|
-
resources :cars
|
24
|
-
end
|
25
|
-
|
26
|
-
resources :cars
|
27
|
-
end
|
28
|
-
```
|
29
|
-
|
30
|
-
the output of `rake routes.rb` would be this:
|
31
|
-
|
32
|
-
```
|
33
|
-
admin_cars GET /admin/cars(.:format) admin/cars#index
|
34
|
-
POST /admin/cars(.:format) admin/cars#create
|
35
|
-
new_admin_car GET /admin/cars/new(.:format) admin/cars#new
|
36
|
-
edit_admin_car GET /admin/cars/:id/edit(.:format) admin/cars#edit
|
37
|
-
admin_car GET /admin/cars/:id(.:format) admin/cars#show
|
38
|
-
PUT /admin/cars/:id(.:format) admin/cars#update
|
39
|
-
DELETE /admin/cars/:id(.:format) admin/cars#destroy
|
40
|
-
cars GET /cars(.:format) cars#index
|
41
|
-
POST /cars(.:format) cars#create
|
42
|
-
new_car GET /cars/new(.:format) cars#new
|
43
|
-
edit_car GET /cars/:id/edit(.:format) cars#edit
|
44
|
-
car GET /cars/:id(.:format) cars#show
|
45
|
-
PUT /cars/:id(.:format) cars#update
|
46
|
-
DELETE /cars/:id(.:format) cars#destroy
|
47
|
-
```
|
48
|
-
|
49
|
-
2. Add the gem to your `Gemfile`:
|
50
|
-
|
51
|
-
```ruby
|
52
|
-
gem 'route_translator'
|
53
|
-
```
|
54
|
-
|
55
|
-
And execute `bundle install`
|
56
|
-
|
57
|
-
3. Wrap the groups of routes that you want to translate inside a
|
58
|
-
`localized` block:
|
59
|
-
|
60
|
-
```ruby
|
61
|
-
MyApp::Application.routes.draw do
|
62
|
-
|
63
|
-
namespace :admin do
|
64
|
-
resources :cars
|
65
|
-
end
|
66
|
-
|
67
|
-
localized do
|
68
|
-
resources :cars
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
MyApp::Application.routes.translate_from_file #you can pass the file path as a param here
|
73
|
-
#the deault is config/i18n-routes.yml
|
74
|
-
```
|
75
|
-
|
76
|
-
And add the translations to a YAML file, for example
|
77
|
-
`config/i18n-routes.yml`:
|
78
|
-
|
79
|
-
```yaml
|
80
|
-
es:
|
81
|
-
cars: coches
|
82
|
-
new: nuevo
|
83
|
-
fr:
|
84
|
-
cars: voitures
|
85
|
-
new: nouveau
|
86
|
-
```
|
87
|
-
|
88
|
-
4. Your routes are translated! Here's the output of your `rake routes` now:
|
89
|
-
|
90
|
-
```
|
91
|
-
admin_cars GET /admin/cars(.:format) admin/cars#index
|
92
|
-
POST /admin/cars(.:format) admin/cars#create
|
93
|
-
new_admin_car GET /admin/cars/new(.:format) admin/cars#new
|
94
|
-
edit_admin_car GET /admin/cars/:id/edit(.:format) admin/cars#edit
|
95
|
-
admin_car GET /admin/cars/:id(.:format) admin/cars#show
|
96
|
-
PUT /admin/cars/:id(.:format) admin/cars#update
|
97
|
-
DELETE /admin/cars/:id(.:format) admin/cars#destroy
|
98
|
-
cars_en GET /cars(.:format) cars#index {:locale=>"en"}
|
99
|
-
cars_es GET /es/coches(.:format) cars#index {:locale=>"es"}
|
100
|
-
cars_fr GET /fr/voitures(.:format) cars#index {:locale=>"fr"}
|
101
|
-
POST /cars(.:format) cars#create {:locale=>"en"}
|
102
|
-
POST /es/coches(.:format) cars#create {:locale=>"es"}
|
103
|
-
POST /fr/voitures(.:format) cars#create {:locale=>"fr"}
|
104
|
-
new_car_en GET /cars/new(.:format) cars#new {:locale=>"en"}
|
105
|
-
new_car_es GET /es/coches/nuevo(.:format) cars#new {:locale=>"es"}
|
106
|
-
new_car_fr GET /fr/voitures/nouveau(.:format) cars#new {:locale=>"fr"}
|
107
|
-
edit_car_en GET /cars/:id/edit(.:format) cars#edit {:locale=>"en"}
|
108
|
-
edit_car_es GET /es/coches/:id/edit(.:format) cars#edit {:locale=>"es"}
|
109
|
-
edit_car_fr GET /fr/voitures/:id/edit(.:format) cars#edit {:locale=>"fr"}
|
110
|
-
car_en GET /cars/:id(.:format) cars#show {:locale=>"en"}
|
111
|
-
car_es GET /es/coches/:id(.:format) cars#show {:locale=>"es"}
|
112
|
-
car_fr GET /fr/voitures/:id(.:format) cars#show {:locale=>"fr"}
|
113
|
-
PUT /cars/:id(.:format) cars#update {:locale=>"en"}
|
114
|
-
PUT /es/coches/:id(.:format) cars#update {:locale=>"es"}
|
115
|
-
PUT /fr/voitures/:id(.:format) cars#update {:locale=>"fr"}
|
116
|
-
DELETE /cars/:id(.:format) cars#destroy {:locale=>"en"}
|
117
|
-
DELETE /es/coches/:id(.:format) cars#destroy {:locale=>"es"}
|
118
|
-
DELETE /fr/voitures/:id(.:format) cars#destroy {:locale=>"fr"}
|
119
|
-
```
|
120
|
-
|
121
|
-
Note that the route inside a `localized` are translated
|
122
|
-
|
123
|
-
5. Include this filter in your `ApplicationController` if you want to set
|
124
|
-
the I18n.locale value from the value set in the route
|
125
|
-
|
126
|
-
```ruby
|
127
|
-
before_filter :set_locale_from_url
|
128
|
-
```
|
data/Rakefile
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'rake/testtask'
|
3
|
-
require 'rdoc/task'
|
4
|
-
|
5
|
-
desc 'Default: run tests.'
|
6
|
-
task :default => :test
|
7
|
-
|
8
|
-
desc 'Test the translate_routes plugin.'
|
9
|
-
Rake::TestTask.new(:test) do |t|
|
10
|
-
t.libs << 'lib'
|
11
|
-
t.pattern = 'test/**/*_test.rb'
|
12
|
-
t.verbose = true
|
13
|
-
end
|
14
|
-
|
15
|
-
desc 'Generate documentation for the translate_routes plugin.'
|
16
|
-
Rake::RDocTask.new(:rdoc) do |rdoc|
|
17
|
-
rdoc.rdoc_dir = 'rdoc'
|
18
|
-
rdoc.title = 'RouteTranslator'
|
19
|
-
rdoc.options << '--line-numbers' << '--inline-source'
|
20
|
-
rdoc.rdoc_files.include('README')
|
21
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
22
|
-
end
|
data/route_translator.gemspec
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require File.expand_path('../lib/route_translator/version', __FILE__)
|
3
|
-
|
4
|
-
Gem::Specification.new do |s|
|
5
|
-
s.name = "route_translator"
|
6
|
-
s.version = RouteTranslator::VERSION
|
7
|
-
|
8
|
-
s.authors = ["Raul Murciano", "Enric Lluelles"]
|
9
|
-
s.email = %q{enric@lluell.es}
|
10
|
-
|
11
|
-
s.homepage = %q{http://github.com/enriclluelles/route_translator}
|
12
|
-
|
13
|
-
s.description = %q{Translates the Rails routes of your application into the languages defined in your locale files}
|
14
|
-
s.summary = %q{Translate your Rails routes in a simple manner}
|
15
|
-
|
16
|
-
s.files = `git ls-files`.split($\) - %w(.gitignore test_runner)
|
17
|
-
s.test_files = `git ls-files test`.split($\)
|
18
|
-
s.require_paths = ["lib"]
|
19
|
-
|
20
|
-
s.add_runtime_dependency("mocha")
|
21
|
-
end
|