translatable_routes 1.3.3 → 1.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +63 -0
- data/lib/translatable_routes/action_dispatch/named_route_collection.rb +17 -5
- data/lib/translatable_routes/railtie.rb +8 -2
- data/lib/translatable_routes/version.rb +1 -1
- data/test/dummy/config/environments/production.rb +5 -1
- data/test/dummy/config/environments/test.rb +9 -1
- data/test/dummy/log/test.log +175 -0
- data/test/helpers_test.rb +2 -1
- data/test/routes_test.rb +1 -1
- metadata +8 -8
- data/README.rdoc +0 -51
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ecc4e1233d650da515ed0955fba21811733a6fde
|
4
|
+
data.tar.gz: 9affcd41d274b05b0564ab2419523ea38aa8284f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8c336bf59fd5efca03f55d00fb27cfc21cef3c905c35842aacc0f11bc4840cb44a446bdb96091025318892c0290217aefee2d15015d6f8332a46f9c802733a7
|
7
|
+
data.tar.gz: 47b31ce99e9a6ae221a1852084a9f75af59f671d3600ae27a3c6ef88e5ac35bd415fd648ea49c3499d845358b441b2497b2dc91a7bb8e5ba63650b9ba6b49dfb
|
data/README.md
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/translatable_routes.svg)](http://badge.fury.io/rb/translatable_routes) [![Code Climate](https://codeclimate.com/github/museways/translatable_routes/badges/gpa.svg)](https://codeclimate.com/github/museways/translatable_routes) [![Build Status](https://travis-ci.org/museways/translatable_routes.svg?branch=master)](https://travis-ci.org/museways/translatable_routes) [![Dependency Status](https://gemnasium.com/museways/translatable_routes.svg)](https://gemnasium.com/museways/translatable_routes)
|
2
|
+
|
3
|
+
# Translatable Routes
|
4
|
+
|
5
|
+
Minimalistic toolkit to translate routes in rails.
|
6
|
+
|
7
|
+
## Install
|
8
|
+
|
9
|
+
Put this line in your Gemfile:
|
10
|
+
```ruby
|
11
|
+
gem 'translatable_routes'
|
12
|
+
```
|
13
|
+
|
14
|
+
Then bundle:
|
15
|
+
```
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
## Configuration
|
20
|
+
|
21
|
+
In your config/routes.rb use the localized method to decide wich routes will be localized:
|
22
|
+
```ruby
|
23
|
+
localized do
|
24
|
+
get 'about' => 'pages#about'
|
25
|
+
end
|
26
|
+
```
|
27
|
+
|
28
|
+
Put your translations inside the routes key in your locales yamls:
|
29
|
+
```yaml
|
30
|
+
es:
|
31
|
+
routes:
|
32
|
+
users: "usuarios"
|
33
|
+
profile: "perfil"
|
34
|
+
about: "nosotros"
|
35
|
+
```
|
36
|
+
|
37
|
+
NOTE: There is no need to put the full path, just translate each part individually.
|
38
|
+
|
39
|
+
## Usage
|
40
|
+
|
41
|
+
Helpers will continue working the same but I18n.locale will be use as default locale:
|
42
|
+
```ruby
|
43
|
+
about_path # Will output /en/about in case I18n.locale is :en
|
44
|
+
```
|
45
|
+
|
46
|
+
Here is an example of what you may want to add to your controllers to select the current locale:
|
47
|
+
```ruby
|
48
|
+
before_action :select_locale
|
49
|
+
|
50
|
+
protected
|
51
|
+
|
52
|
+
def select_locale
|
53
|
+
I18n.locale = params[:locale]
|
54
|
+
end
|
55
|
+
```
|
56
|
+
|
57
|
+
## Credits
|
58
|
+
|
59
|
+
This gem is maintained and funded by [museways](http://museways.com).
|
60
|
+
|
61
|
+
## License
|
62
|
+
|
63
|
+
It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
|
@@ -2,22 +2,34 @@ module TranslatableRoutes
|
|
2
2
|
module ActionDispatch
|
3
3
|
module NamedRouteCollection
|
4
4
|
extend ActiveSupport::Concern
|
5
|
-
|
5
|
+
|
6
6
|
def define_i18n_url_helper(name)
|
7
7
|
%w(path url).each do |type|
|
8
8
|
helper = :"#{name}_#{type}"
|
9
|
-
|
10
|
-
|
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
|
11
18
|
define_method helper do |*args|
|
12
19
|
options = args.extract_options!
|
13
20
|
suffix = (options[:locale] || I18n.locale).to_s.gsub('-', '_').downcase
|
14
21
|
send "#{name}_#{suffix}_#{type}", *(args << options)
|
15
22
|
end
|
16
23
|
end
|
17
|
-
|
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
|
18
30
|
end
|
19
31
|
end
|
20
|
-
|
32
|
+
|
21
33
|
end
|
22
34
|
end
|
23
35
|
end
|
@@ -2,8 +2,14 @@ module TranslatableRoutes
|
|
2
2
|
class Railtie < Rails::Railtie
|
3
3
|
|
4
4
|
initializer 'translatable_routes' do
|
5
|
-
::ActionDispatch::Routing::RouteSet::NamedRouteCollection.send
|
6
|
-
|
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
|
+
)
|
7
13
|
end
|
8
14
|
|
9
15
|
end
|
@@ -20,7 +20,11 @@ Dummy::Application.configure do
|
|
20
20
|
# config.action_dispatch.rack_cache = true
|
21
21
|
|
22
22
|
# Disable Rails's static asset server (Apache or nginx will already do this).
|
23
|
-
|
23
|
+
if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
|
24
|
+
config.serve_static_files = false
|
25
|
+
else
|
26
|
+
config.serve_static_assets = false
|
27
|
+
end
|
24
28
|
|
25
29
|
# Compress JavaScripts and CSS.
|
26
30
|
config.assets.js_compressor = :uglifier
|
@@ -13,7 +13,11 @@ Dummy::Application.configure do
|
|
13
13
|
config.eager_load = false
|
14
14
|
|
15
15
|
# Configure static asset server for tests with Cache-Control for performance.
|
16
|
-
|
16
|
+
if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
|
17
|
+
config.serve_static_files = false
|
18
|
+
else
|
19
|
+
config.serve_static_assets = false
|
20
|
+
end
|
17
21
|
config.static_cache_control = "public, max-age=3600"
|
18
22
|
|
19
23
|
# Show full error reports and disable caching.
|
@@ -33,4 +37,8 @@ Dummy::Application.configure do
|
|
33
37
|
|
34
38
|
# Print deprecation notices to the stderr.
|
35
39
|
config.active_support.deprecation = :stderr
|
40
|
+
|
41
|
+
if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
|
42
|
+
config.active_support.test_order = :random
|
43
|
+
end
|
36
44
|
end
|
data/test/dummy/log/test.log
CHANGED
@@ -6494,3 +6494,178 @@ HelpersTest: test_create_helpers
|
|
6494
6494
|
RoutesTest: test_translate_routes
|
6495
6495
|
---------------------------------
|
6496
6496
|
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
6497
|
+
[1m[36m (0.3ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
6498
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
6499
|
+
[1m[36m (0.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
6500
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
6501
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
6502
|
+
[1m[35m (0.1ms)[0m begin transaction
|
6503
|
+
-------------------------
|
6504
|
+
HelpersTest: test_helpers
|
6505
|
+
-------------------------
|
6506
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
6507
|
+
[1m[35m (0.0ms)[0m begin transaction
|
6508
|
+
-----------------------
|
6509
|
+
RoutesTest: test_routes
|
6510
|
+
-----------------------
|
6511
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
6512
|
+
[1m[36m (0.3ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
6513
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
6514
|
+
[1m[36m (0.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
6515
|
+
[1m[35m (0.0ms)[0m SELECT version FROM "schema_migrations"
|
6516
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
6517
|
+
[1m[36m (0.3ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
6518
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
6519
|
+
[1m[36m (0.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
6520
|
+
[1m[35m (0.0ms)[0m SELECT version FROM "schema_migrations"
|
6521
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
6522
|
+
[1m[35m (0.1ms)[0m begin transaction
|
6523
|
+
-----------------------
|
6524
|
+
RoutesTest: test_routes
|
6525
|
+
-----------------------
|
6526
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
6527
|
+
[1m[35m (0.1ms)[0m begin transaction
|
6528
|
+
-------------------------
|
6529
|
+
HelpersTest: test_helpers
|
6530
|
+
-------------------------
|
6531
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
6532
|
+
[1m[36m (0.3ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
6533
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
6534
|
+
[1m[36m (0.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
6535
|
+
[1m[35m (0.0ms)[0m SELECT version FROM "schema_migrations"
|
6536
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
6537
|
+
[1m[36m (0.4ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
6538
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
6539
|
+
[1m[36m (0.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
6540
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
6541
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
6542
|
+
[1m[35m (0.1ms)[0m begin transaction
|
6543
|
+
-------------------------
|
6544
|
+
HelpersTest: test_helpers
|
6545
|
+
-------------------------
|
6546
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
6547
|
+
[1m[35m (0.0ms)[0m begin transaction
|
6548
|
+
-----------------------
|
6549
|
+
RoutesTest: test_routes
|
6550
|
+
-----------------------
|
6551
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
6552
|
+
[1m[36m (0.2ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
6553
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
6554
|
+
[1m[36m (0.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
6555
|
+
[1m[35m (0.0ms)[0m SELECT version FROM "schema_migrations"
|
6556
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
6557
|
+
[1m[36m (0.3ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
6558
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
6559
|
+
[1m[36m (0.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
6560
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
6561
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
6562
|
+
[1m[35m (0.1ms)[0m begin transaction
|
6563
|
+
-----------------------
|
6564
|
+
RoutesTest: test_routes
|
6565
|
+
-----------------------
|
6566
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
6567
|
+
[1m[35m (0.1ms)[0m begin transaction
|
6568
|
+
-------------------------
|
6569
|
+
HelpersTest: test_helpers
|
6570
|
+
-------------------------
|
6571
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
6572
|
+
[1m[36m (0.3ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
6573
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
6574
|
+
[1m[36m (0.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
6575
|
+
[1m[35m (0.0ms)[0m SELECT version FROM "schema_migrations"
|
6576
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
6577
|
+
[1m[36m (0.3ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
6578
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
6579
|
+
[1m[36m (0.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
6580
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
6581
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
6582
|
+
[1m[35m (0.1ms)[0m begin transaction
|
6583
|
+
-------------------------
|
6584
|
+
HelpersTest: test_helpers
|
6585
|
+
-------------------------
|
6586
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
6587
|
+
[1m[35m (0.0ms)[0m begin transaction
|
6588
|
+
-----------------------
|
6589
|
+
RoutesTest: test_routes
|
6590
|
+
-----------------------
|
6591
|
+
[1m[36m (0.2ms)[0m [1mrollback transaction[0m
|
6592
|
+
[1m[36m (0.3ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
6593
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
6594
|
+
[1m[36m (0.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
6595
|
+
[1m[35m (0.0ms)[0m SELECT version FROM "schema_migrations"
|
6596
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
6597
|
+
[1m[36m (0.3ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
6598
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
6599
|
+
[1m[36m (0.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
6600
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
6601
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
6602
|
+
[1m[35m (0.1ms)[0m begin transaction
|
6603
|
+
-----------------------
|
6604
|
+
RoutesTest: test_routes
|
6605
|
+
-----------------------
|
6606
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
6607
|
+
[1m[35m (0.0ms)[0m begin transaction
|
6608
|
+
-------------------------
|
6609
|
+
HelpersTest: test_helpers
|
6610
|
+
-------------------------
|
6611
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
6612
|
+
[1m[36m (0.3ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
6613
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
6614
|
+
[1m[36m (0.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
6615
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
6616
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
6617
|
+
[1m[36m (0.3ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
6618
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
6619
|
+
[1m[36m (0.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
6620
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
6621
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
6622
|
+
[1m[35m (0.1ms)[0m begin transaction
|
6623
|
+
-----------------------
|
6624
|
+
RoutesTest: test_routes
|
6625
|
+
-----------------------
|
6626
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
6627
|
+
[1m[35m (0.1ms)[0m begin transaction
|
6628
|
+
-------------------------
|
6629
|
+
HelpersTest: test_helpers
|
6630
|
+
-------------------------
|
6631
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
6632
|
+
[1m[36m (0.3ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
6633
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
6634
|
+
[1m[36m (0.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
6635
|
+
[1m[35m (0.0ms)[0m SELECT version FROM "schema_migrations"
|
6636
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
6637
|
+
[1m[36m (0.3ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
6638
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
6639
|
+
[1m[36m (0.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
6640
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
6641
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
6642
|
+
[1m[35m (0.1ms)[0m begin transaction
|
6643
|
+
-------------------------
|
6644
|
+
HelpersTest: test_helpers
|
6645
|
+
-------------------------
|
6646
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
6647
|
+
[1m[35m (0.0ms)[0m begin transaction
|
6648
|
+
-----------------------
|
6649
|
+
RoutesTest: test_routes
|
6650
|
+
-----------------------
|
6651
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
6652
|
+
[1m[36m (0.3ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
6653
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
6654
|
+
[1m[36m (0.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
6655
|
+
[1m[35m (0.0ms)[0m SELECT version FROM "schema_migrations"
|
6656
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
6657
|
+
[1m[36m (0.4ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
6658
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
6659
|
+
[1m[36m (0.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
6660
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
6661
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
6662
|
+
[1m[35m (0.1ms)[0m begin transaction
|
6663
|
+
-------------------------
|
6664
|
+
HelpersTest: test_helpers
|
6665
|
+
-------------------------
|
6666
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
6667
|
+
[1m[35m (0.0ms)[0m begin transaction
|
6668
|
+
-----------------------
|
6669
|
+
RoutesTest: test_routes
|
6670
|
+
-----------------------
|
6671
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
data/test/helpers_test.rb
CHANGED
data/test/routes_test.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: translatable_routes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Museways
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,8 +16,8 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
- - "
|
19
|
+
version: 4.0.0
|
20
|
+
- - "<="
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: 4.2.0
|
23
23
|
type: :runtime
|
@@ -26,8 +26,8 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
30
|
-
- - "
|
29
|
+
version: 4.0.0
|
30
|
+
- - "<="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 4.2.0
|
33
33
|
- !ruby/object:Gem::Dependency
|
@@ -52,7 +52,7 @@ extensions: []
|
|
52
52
|
extra_rdoc_files: []
|
53
53
|
files:
|
54
54
|
- MIT-LICENSE
|
55
|
-
- README.
|
55
|
+
- README.md
|
56
56
|
- Rakefile
|
57
57
|
- lib/translatable_routes.rb
|
58
58
|
- lib/translatable_routes/action_dispatch/mapper.rb
|
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
128
|
version: '0'
|
129
129
|
requirements: []
|
130
130
|
rubyforge_project:
|
131
|
-
rubygems_version: 2.
|
131
|
+
rubygems_version: 2.4.5
|
132
132
|
signing_key:
|
133
133
|
specification_version: 4
|
134
134
|
summary: Translatable routes for rails.
|
data/README.rdoc
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
{<img src="https://badge.fury.io/rb/translatable_routes.png" alt="Gem Version" />}[http://badge.fury.io/rb/translatable_routes] {<img src="https://codeclimate.com/github/museways/translatable_routes.png" />}[https://codeclimate.com/github/museways/translatable_routes] {<img src="https://travis-ci.org/museways/translatable_routes.png?branch=master" alt="Build Status" />}[https://travis-ci.org/museways/translatable_routes]
|
2
|
-
|
3
|
-
= Translatable Routes
|
4
|
-
|
5
|
-
Minimalistic toolkit to translate routes in rails.
|
6
|
-
|
7
|
-
= Install
|
8
|
-
|
9
|
-
Put this line in your Gemfile:
|
10
|
-
gem 'translatable_routes'
|
11
|
-
|
12
|
-
Then bundle:
|
13
|
-
$ bundle
|
14
|
-
|
15
|
-
= Configuration
|
16
|
-
|
17
|
-
In your config/routes.rb use the localized method to decide wich routes will be localized:
|
18
|
-
localized do
|
19
|
-
get 'about' => 'pages#about'
|
20
|
-
end
|
21
|
-
|
22
|
-
Put your translations inside the routes key in your locales yamls:
|
23
|
-
es:
|
24
|
-
routes:
|
25
|
-
users: "usuarios"
|
26
|
-
profile: "perfil"
|
27
|
-
about: "nosotros"
|
28
|
-
|
29
|
-
NOTE: There is no need to put the full path, just translate each part individually.
|
30
|
-
|
31
|
-
= Usage
|
32
|
-
|
33
|
-
Helpers will continue working the same but I18n.locale will be use as default locale:
|
34
|
-
about_path # Will output /en/about in case I18n.locale is :en
|
35
|
-
|
36
|
-
Here is an example of what you may want to add to your controllers to select the current locale:
|
37
|
-
before_action :select_locale
|
38
|
-
|
39
|
-
protected
|
40
|
-
|
41
|
-
def select_locale
|
42
|
-
I18n.locale = params[:locale]
|
43
|
-
end
|
44
|
-
|
45
|
-
= Credits
|
46
|
-
|
47
|
-
This gem is maintained and funded by museways[http://museways.com].
|
48
|
-
|
49
|
-
= License
|
50
|
-
|
51
|
-
It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
|