Skip to content
Newer
Older
100755 122 lines (84 sloc) 4.79 KB
b39c18c @jaimeiniesta Clean up README.markdown for proper whitespace indentation, fixes Act…
jaimeiniesta authored
1 TranslateRoutes
64995f6 @raul README.rdoc -> README.markdown
authored
2 ===============
3
3b2e5f8 @raul Mention rails-translate-routes as the better alternative for Rails >= 3
authored
4 Rails >= 3
5 ----------
4ae229b @raul Announce discontinued development in README, linking alternatives.
authored
6
3b2e5f8 @raul Mention rails-translate-routes as the better alternative for Rails >= 3
authored
7 The master branch supported some versions of Rails 3, though **I've discontinued the development**.
7700031 @raul Mention Enric Lluelles' fork.
authored
8
9 Two forks have been published as different gems and are the best alternatives I'm aware of:
10
11 - Francesc Pla's [rails-translate-routes](https://github.com/francesc/rails-translate-routes)
12 - Enric Lluelles' [route_translator](https://github.com/enriclluelles/route_translator)
13
14 Free Software is wonderful, isn't it? :)
4ae229b @raul Announce discontinued development in README, linking alternatives.
authored
15
16 Rails 2
17 -------
18
19 You can find branches for Rails [2.1.x](http://github.com/raul/translate_routes/tree/rails2.1), [2.2.x](http://github.com/raul/translate_routes/tree/rails2.2) and [2.3.x](http://github.com/raul/translate_routes/tree/rails2.3)
65edf06 @raul Added links to branches for different Rails versions
authored
20
b39c18c @jaimeiniesta Clean up README.markdown for proper whitespace indentation, fixes Act…
jaimeiniesta authored
21 This Rails plugin provides a simple way to translate your URLs to any number of languages, even on a fully working application.
64995f6 @raul README.rdoc -> README.markdown
authored
22
b39c18c @jaimeiniesta Clean up README.markdown for proper whitespace indentation, fixes Act…
jaimeiniesta authored
23 It works fine with all kind of routing definitions, including RESTful and named routes.
a20c2e0 @raul Documentation updated with links to the demo application and wiki.
authored
24 **Your current code will remain untouched**: your current routing code, helpers and links will be translated transparently - even in your tests.
64995f6 @raul README.rdoc -> README.markdown
authored
25 (Un)installing it is a very clean and simple process, so why don't you give it a chance? ;)
26
2cbcf8a @raul Reviewed doc example
authored
27 Installation
28 ------------
29 Add translate_routes to your `Gemfile`:
4ae229b @raul Announce discontinued development in README, linking alternatives.
authored
30
2cbcf8a @raul Reviewed doc example
authored
31 gem 'translate_routes'
4ae229b @raul Announce discontinued development in README, linking alternatives.
authored
32
2cbcf8a @raul Reviewed doc example
authored
33 And let bundle do the rest:
34
35 bundle install
36
37 Quick Start
64995f6 @raul README.rdoc -> README.markdown
authored
38 -----------
39
2cbcf8a @raul Reviewed doc example
authored
40 1) Let's imagine you have this `routes.rb` file:
64995f6 @raul README.rdoc -> README.markdown
authored
41
2cbcf8a @raul Reviewed doc example
authored
42 TranslateRoutesApp::Application.routes.draw do
43 match 'contact' => 'contact#index'
64995f6 @raul README.rdoc -> README.markdown
authored
44 end
45
2cbcf8a @raul Reviewed doc example
authored
46 You can see the available routes with the `rake routes` task:
64995f6 @raul README.rdoc -> README.markdown
authored
47
48
2cbcf8a @raul Reviewed doc example
authored
49 contact /contact(.:format) {:controller=>"contact", :action=>"index"}
64995f6 @raul README.rdoc -> README.markdown
authored
50
2cbcf8a @raul Reviewed doc example
authored
51 2) Now write your translations on a standard YAML file (e.g: in `/config/i18n-routes.yml`), including all the locales and their translations pairs:
64995f6 @raul README.rdoc -> README.markdown
authored
52
2cbcf8a @raul Reviewed doc example
authored
53 en:
54 # you can leave empty locales, for example the default one
55 es:
56 contact: contacto
b39c18c @jaimeiniesta Clean up README.markdown for proper whitespace indentation, fixes Act…
jaimeiniesta authored
57
2cbcf8a @raul Reviewed doc example
authored
58 3) Append this line in your `routes.rb` file to activate the translations specifying the path of the translations file:
64995f6 @raul README.rdoc -> README.markdown
authored
59
b39c18c @jaimeiniesta Clean up README.markdown for proper whitespace indentation, fixes Act…
jaimeiniesta authored
60 ActionDispatch::Routing::Translator.translate_from_file('config','i18n-routes.yml')
64995f6 @raul README.rdoc -> README.markdown
authored
61
2cbcf8a @raul Reviewed doc example
authored
62 4) Execute `rake routes` to see the new routes:
64995f6 @raul README.rdoc -> README.markdown
authored
63
2cbcf8a @raul Reviewed doc example
authored
64 contact_es /es/contacto(.:format) {:controller=>"contact", :action=>"index"}
65 contact_en /contact(.:format) {:controller=>"contact", :action=>"index"}
64995f6 @raul README.rdoc -> README.markdown
authored
66
2cbcf8a @raul Reviewed doc example
authored
67 5) Include this filter in your ApplicationController:
64995f6 @raul README.rdoc -> README.markdown
authored
68
69 before_filter :set_locale_from_url
70
2cbcf8a @raul Reviewed doc example
authored
71 Now your application recognizes the different routes and sets the `I18n.locale` value in your controllers,
b39c18c @jaimeiniesta Clean up README.markdown for proper whitespace indentation, fixes Act…
jaimeiniesta authored
72 but what about the routes generation? As you can see on the previous `rake routes` execution, the
73 `contact_es_es_path` and `contact_en_us_path` routing helpers have been generated and are
74 available in your controllers and views. Additionally, a `contact_path` helper has been generated, which
75 generates the routes according to the current request's locale. This way your link
64995f6 @raul README.rdoc -> README.markdown
authored
76
c917eff @raul Accepted patch from Aitor Garay-Romero: root routes with prefix now d…
authored
77 This means that if you use named routes **you don't need to modify your application links** because the routing helpers are automatically adapted to the current locale.
64995f6 @raul README.rdoc -> README.markdown
authored
78
2cbcf8a @raul Reviewed doc example
authored
79 6) Hey, but what about my tests?
64995f6 @raul README.rdoc -> README.markdown
authored
80
b39c18c @jaimeiniesta Clean up README.markdown for proper whitespace indentation, fixes Act…
jaimeiniesta authored
81 Of course, your functional and integration testing involves some requests.
64995f6 @raul README.rdoc -> README.markdown
authored
82 The plugin includes some code to add a default locale parameter so they can remain untouched.
83 Append it to your `test_helper` and it will be applied.
84
a20c2e0 @raul Documentation updated with links to the demo application and wiki.
authored
85 Documentation
86 -------------
87 You can find additional information in [the translate_routes' wiki](http://wiki.github.com/raul/translate_routes).
64995f6 @raul README.rdoc -> README.markdown
authored
88
a20c2e0 @raul Documentation updated with links to the demo application and wiki.
authored
89 Questions, suggestions, bug reports...
90 --------------------------------------
64995f6 @raul README.rdoc -> README.markdown
authored
91 Feedback, questions and comments will be always welcome at raul@murciano.net
92
93 Credits
94 -------
c917eff @raul Accepted patch from Aitor Garay-Romero: root routes with prefix now d…
authored
95 * Main development:
b39c18c @jaimeiniesta Clean up README.markdown for proper whitespace indentation, fixes Act…
jaimeiniesta authored
96 * Raul Murciano <http://raul.murciano.net> - code
97 * Domestika INTERNET S.L <http://domestika.org> - incredible support, really nice people to work with!
64995f6 @raul README.rdoc -> README.markdown
authored
98
c917eff @raul Accepted patch from Aitor Garay-Romero: root routes with prefix now d…
authored
99 * Contributors:
7b9ec09 @raul Updated contributors list
authored
100 * [Aitor Garay-Romero](http://github.com/aitorgr)
42a0d7c @raul Updated contributors list
authored
101 * [Christian Hølmer](http://github.com/hoelmer)
a86697f @raul Link to contributor Nico Ritsche
authored
102 * [Nico Ritsche](https://github.com/ncri)
7b9ec09 @raul Updated contributors list
authored
103 * [Cedric Darricau](http://github.com/devsigner)
20c7cdc @raul Integrating awesome contributions to get a Rails3 version
authored
104 * [Olivier Gonzalez](http://github.com/gonzoyumo)
105 * [Kristian Mandrup](http://github.com/kristianmandrup)
106 * [Pieter Visser](http://github.com/pietervisser)
107 * [Marian Theisen](http://github.com/cice)
3b8c4f6 @raul Gemified thanks to Enric Lluelles
authored
108 * [Enric Lluelles](http://github.com/enriclluelles)
dd2a5b9 @raul Fixed doc formatting thanks to Jaime Iniesta
authored
109 * [Jaime Iniesta](http://github.com/jaimeiniesta)
64995f6 @raul README.rdoc -> README.markdown
authored
110
111 Rails routing resources
112 -----------------------
b39c18c @jaimeiniesta Clean up README.markdown for proper whitespace indentation, fixes Act…
jaimeiniesta authored
113 * David Black's 'Rails Routing' ebook rocks! - 'Ruby for Rails' too, BTW.
c917eff @raul Accepted patch from Aitor Garay-Romero: root routes with prefix now d…
authored
114 * Obie Fernandez's 'The Rails Way' - the definitive RoR reference, great work Obie!
115 * As a part of the impressive Rails Guides set there is an [awesome document about rails routing](http://guides.rails.info/routing_outside_in.html) by Mike Gunderloy:
116
64995f6 @raul README.rdoc -> README.markdown
authored
117
118 License
119 -------
b39c18c @jaimeiniesta Clean up README.markdown for proper whitespace indentation, fixes Act…
jaimeiniesta authored
120 Copyright (c) 2007 Released under the MIT license (see MIT-LICENSE)
121 Raul Murciano <http://raul.murciano.net>
c917eff @raul Accepted patch from Aitor Garay-Romero: root routes with prefix now d…
authored
122 Domestika INTERNET S.L. <http://domestika.org>
Something went wrong with that request. Please try again.