rails 4.0.0 → 4.2.11.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (190) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +30 -23
  3. data/guides/CHANGELOG.md +108 -6
  4. data/guides/Rakefile +21 -6
  5. data/guides/assets/images/akshaysurve.jpg +0 -0
  6. data/guides/assets/images/edge_badge.png +0 -0
  7. data/guides/assets/images/feature_tile.gif +0 -0
  8. data/guides/assets/images/footer_tile.gif +0 -0
  9. data/guides/assets/images/fxn.png +0 -0
  10. data/guides/assets/images/getting_started/article_with_comments.png +0 -0
  11. data/guides/assets/images/getting_started/challenge.png +0 -0
  12. data/guides/assets/images/getting_started/confirm_dialog.png +0 -0
  13. data/guides/assets/images/getting_started/forbidden_attributes_for_new_article.png +0 -0
  14. data/guides/assets/images/getting_started/form_with_errors.png +0 -0
  15. data/guides/assets/images/getting_started/index_action_with_edit_link.png +0 -0
  16. data/guides/assets/images/getting_started/new_article.png +0 -0
  17. data/guides/assets/images/getting_started/rails_welcome.png +0 -0
  18. data/guides/assets/images/getting_started/routing_error_no_controller.png +0 -0
  19. data/guides/assets/images/getting_started/routing_error_no_route_matches.png +0 -0
  20. data/guides/assets/images/getting_started/show_action_for_articles.png +0 -0
  21. data/guides/assets/images/getting_started/template_is_missing_articles_new.png +0 -0
  22. data/guides/assets/images/getting_started/unknown_action_create_for_articles.png +0 -0
  23. data/guides/assets/images/getting_started/unknown_action_new_for_articles.png +0 -0
  24. data/guides/assets/images/header_tile.gif +0 -0
  25. data/guides/assets/images/icons/README +1 -1
  26. data/guides/assets/images/icons/callouts/11.png +0 -0
  27. data/guides/assets/images/icons/callouts/12.png +0 -0
  28. data/guides/assets/images/icons/callouts/13.png +0 -0
  29. data/guides/assets/images/icons/callouts/15.png +0 -0
  30. data/guides/assets/images/icons/caution.png +0 -0
  31. data/guides/assets/images/icons/example.png +0 -0
  32. data/guides/assets/images/radar.png +0 -0
  33. data/guides/assets/images/rails4_features.png +0 -0
  34. data/guides/assets/images/rails_guides_kindle_cover.jpg +0 -0
  35. data/guides/assets/images/vijaydev.jpg +0 -0
  36. data/guides/assets/javascripts/guides.js +36 -34
  37. data/guides/assets/stylesheets/main.css +6 -2
  38. data/guides/assets/stylesheets/print.css +1 -1
  39. data/guides/bug_report_templates/action_controller_gem.rb +47 -0
  40. data/guides/bug_report_templates/action_controller_master.rb +54 -0
  41. data/guides/bug_report_templates/active_record_gem.rb +5 -2
  42. data/guides/bug_report_templates/active_record_master.rb +3 -2
  43. data/guides/bug_report_templates/generic_gem.rb +15 -0
  44. data/guides/bug_report_templates/generic_master.rb +26 -0
  45. data/guides/rails_guides.rb +23 -4
  46. data/guides/rails_guides/generator.rb +1 -1
  47. data/guides/rails_guides/helpers.rb +4 -2
  48. data/guides/rails_guides/levenshtein.rb +27 -21
  49. data/guides/rails_guides/markdown.rb +11 -7
  50. data/guides/rails_guides/markdown/renderer.rb +1 -1
  51. data/guides/source/2_2_release_notes.md +3 -3
  52. data/guides/source/2_3_release_notes.md +12 -12
  53. data/guides/source/3_0_release_notes.md +10 -13
  54. data/guides/source/3_1_release_notes.md +7 -4
  55. data/guides/source/3_2_release_notes.md +17 -14
  56. data/guides/source/4_0_release_notes.md +110 -54
  57. data/guides/source/4_1_release_notes.md +730 -0
  58. data/guides/source/4_2_release_notes.md +877 -0
  59. data/guides/source/_license.html.erb +1 -1
  60. data/guides/source/_welcome.html.erb +6 -2
  61. data/guides/source/action_controller_overview.md +223 -57
  62. data/guides/source/action_mailer_basics.md +129 -76
  63. data/guides/source/action_view_overview.md +247 -246
  64. data/guides/source/active_job_basics.md +339 -0
  65. data/guides/source/active_model_basics.md +374 -20
  66. data/guides/source/active_record_basics.md +46 -45
  67. data/guides/source/active_record_callbacks.md +83 -28
  68. data/guides/source/{migrations.md → active_record_migrations.md} +191 -275
  69. data/guides/source/active_record_postgresql.md +433 -0
  70. data/guides/source/active_record_querying.md +382 -300
  71. data/guides/source/active_record_validations.md +64 -55
  72. data/guides/source/active_support_core_extensions.md +229 -187
  73. data/guides/source/active_support_instrumentation.md +23 -22
  74. data/guides/source/api_documentation_guidelines.md +167 -15
  75. data/guides/source/asset_pipeline.md +768 -294
  76. data/guides/source/association_basics.md +188 -96
  77. data/guides/source/autoloading_and_reloading_constants.md +1311 -0
  78. data/guides/source/caching_with_rails.md +45 -11
  79. data/guides/source/command_line.md +96 -65
  80. data/guides/source/configuring.md +404 -70
  81. data/guides/source/contributing_to_ruby_on_rails.md +270 -130
  82. data/guides/source/credits.html.erb +7 -3
  83. data/guides/source/debugging_rails_applications.md +471 -284
  84. data/guides/source/development_dependencies_install.md +115 -21
  85. data/guides/source/documents.yaml +31 -9
  86. data/guides/source/engines.md +737 -291
  87. data/guides/source/form_helpers.md +137 -89
  88. data/guides/source/generators.md +60 -28
  89. data/guides/source/getting_started.md +1007 -596
  90. data/guides/source/i18n.md +178 -96
  91. data/guides/source/index.html.erb +2 -1
  92. data/guides/source/initialization.md +248 -104
  93. data/guides/source/kindle/toc.html.erb +1 -1
  94. data/guides/source/layout.html.erb +14 -22
  95. data/guides/source/layouts_and_rendering.md +78 -46
  96. data/guides/source/maintenance_policy.md +78 -0
  97. data/guides/source/nested_model_forms.md +10 -7
  98. data/guides/source/plugins.md +66 -57
  99. data/guides/source/rails_application_templates.md +49 -12
  100. data/guides/source/rails_on_rack.md +50 -60
  101. data/guides/source/routing.md +190 -139
  102. data/guides/source/ruby_on_rails_guides_guidelines.md +12 -13
  103. data/guides/source/security.md +134 -83
  104. data/guides/source/testing.md +322 -200
  105. data/guides/source/upgrading_ruby_on_rails.md +834 -37
  106. data/guides/source/working_with_javascript_in_rails.md +36 -26
  107. data/guides/w3c_validator.rb +2 -0
  108. metadata +93 -116
  109. data/guides/assets/images/getting_started/forbidden_attributes_for_new_post.png +0 -0
  110. data/guides/assets/images/getting_started/new_post.png +0 -0
  111. data/guides/assets/images/getting_started/post_with_comments.png +0 -0
  112. data/guides/assets/images/getting_started/show_action_for_posts.png +0 -0
  113. data/guides/assets/images/getting_started/template_is_missing_posts_new.png +0 -0
  114. data/guides/assets/images/getting_started/undefined_method_post_path.png +0 -0
  115. data/guides/assets/images/getting_started/unknown_action_create_for_posts.png +0 -0
  116. data/guides/assets/images/getting_started/unknown_action_new_for_posts.png +0 -0
  117. data/guides/assets/images/jaimeiniesta.jpg +0 -0
  118. data/guides/code/getting_started/Gemfile +0 -43
  119. data/guides/code/getting_started/Gemfile.lock +0 -150
  120. data/guides/code/getting_started/README.rdoc +0 -28
  121. data/guides/code/getting_started/Rakefile +0 -6
  122. data/guides/code/getting_started/app/assets/javascripts/application.js +0 -16
  123. data/guides/code/getting_started/app/assets/javascripts/comments.js.coffee +0 -3
  124. data/guides/code/getting_started/app/assets/javascripts/posts.js.coffee +0 -3
  125. data/guides/code/getting_started/app/assets/javascripts/welcome.js.coffee +0 -3
  126. data/guides/code/getting_started/app/assets/stylesheets/application.css +0 -13
  127. data/guides/code/getting_started/app/assets/stylesheets/comments.css.scss +0 -3
  128. data/guides/code/getting_started/app/assets/stylesheets/posts.css.scss +0 -3
  129. data/guides/code/getting_started/app/assets/stylesheets/welcome.css.scss +0 -3
  130. data/guides/code/getting_started/app/controllers/application_controller.rb +0 -5
  131. data/guides/code/getting_started/app/controllers/comments_controller.rb +0 -17
  132. data/guides/code/getting_started/app/controllers/posts_controller.rb +0 -47
  133. data/guides/code/getting_started/app/controllers/welcome_controller.rb +0 -4
  134. data/guides/code/getting_started/app/helpers/application_helper.rb +0 -2
  135. data/guides/code/getting_started/app/helpers/comments_helper.rb +0 -2
  136. data/guides/code/getting_started/app/helpers/posts_helper.rb +0 -2
  137. data/guides/code/getting_started/app/helpers/welcome_helper.rb +0 -2
  138. data/guides/code/getting_started/app/models/comment.rb +0 -3
  139. data/guides/code/getting_started/app/models/post.rb +0 -7
  140. data/guides/code/getting_started/app/views/comments/_comment.html.erb +0 -15
  141. data/guides/code/getting_started/app/views/comments/_form.html.erb +0 -13
  142. data/guides/code/getting_started/app/views/layouts/application.html.erb +0 -14
  143. data/guides/code/getting_started/app/views/posts/_form.html.erb +0 -27
  144. data/guides/code/getting_started/app/views/posts/edit.html.erb +0 -5
  145. data/guides/code/getting_started/app/views/posts/index.html.erb +0 -21
  146. data/guides/code/getting_started/app/views/posts/new.html.erb +0 -5
  147. data/guides/code/getting_started/app/views/posts/show.html.erb +0 -18
  148. data/guides/code/getting_started/app/views/welcome/index.html.erb +0 -3
  149. data/guides/code/getting_started/bin/bundle +0 -4
  150. data/guides/code/getting_started/bin/rails +0 -4
  151. data/guides/code/getting_started/bin/rake +0 -4
  152. data/guides/code/getting_started/config.ru +0 -4
  153. data/guides/code/getting_started/config/application.rb +0 -18
  154. data/guides/code/getting_started/config/boot.rb +0 -4
  155. data/guides/code/getting_started/config/database.yml +0 -25
  156. data/guides/code/getting_started/config/environment.rb +0 -5
  157. data/guides/code/getting_started/config/environments/development.rb +0 -30
  158. data/guides/code/getting_started/config/environments/production.rb +0 -80
  159. data/guides/code/getting_started/config/environments/test.rb +0 -36
  160. data/guides/code/getting_started/config/initializers/backtrace_silencers.rb +0 -7
  161. data/guides/code/getting_started/config/initializers/filter_parameter_logging.rb +0 -4
  162. data/guides/code/getting_started/config/initializers/inflections.rb +0 -16
  163. data/guides/code/getting_started/config/initializers/locale.rb +0 -9
  164. data/guides/code/getting_started/config/initializers/mime_types.rb +0 -5
  165. data/guides/code/getting_started/config/initializers/secret_token.rb +0 -12
  166. data/guides/code/getting_started/config/initializers/session_store.rb +0 -3
  167. data/guides/code/getting_started/config/initializers/wrap_parameters.rb +0 -14
  168. data/guides/code/getting_started/config/locales/en.yml +0 -23
  169. data/guides/code/getting_started/config/routes.rb +0 -7
  170. data/guides/code/getting_started/db/migrate/20130122042648_create_posts.rb +0 -10
  171. data/guides/code/getting_started/db/migrate/20130122045842_create_comments.rb +0 -11
  172. data/guides/code/getting_started/db/schema.rb +0 -33
  173. data/guides/code/getting_started/db/seeds.rb +0 -7
  174. data/guides/code/getting_started/public/404.html +0 -58
  175. data/guides/code/getting_started/public/422.html +0 -58
  176. data/guides/code/getting_started/public/500.html +0 -57
  177. data/guides/code/getting_started/public/favicon.ico +0 -0
  178. data/guides/code/getting_started/public/robots.txt +0 -5
  179. data/guides/code/getting_started/test/controllers/comments_controller_test.rb +0 -7
  180. data/guides/code/getting_started/test/controllers/posts_controller_test.rb +0 -7
  181. data/guides/code/getting_started/test/controllers/welcome_controller_test.rb +0 -9
  182. data/guides/code/getting_started/test/fixtures/comments.yml +0 -11
  183. data/guides/code/getting_started/test/fixtures/posts.yml +0 -9
  184. data/guides/code/getting_started/test/helpers/comments_helper_test.rb +0 -4
  185. data/guides/code/getting_started/test/helpers/posts_helper_test.rb +0 -4
  186. data/guides/code/getting_started/test/helpers/welcome_helper_test.rb +0 -4
  187. data/guides/code/getting_started/test/models/comment_test.rb +0 -7
  188. data/guides/code/getting_started/test/models/post_test.rb +0 -7
  189. data/guides/code/getting_started/test/test_helper.rb +0 -15
  190. data/guides/source/kindle/KINDLE.md +0 -26
@@ -13,17 +13,22 @@ So, in the process of _internationalizing_ your Rails application you have to:
13
13
 
14
14
  In the process of _localizing_ your application you'll probably want to do the following three things:
15
15
 
16
- * Replace or supplement Rails' default locale e.g. date and time formats, month names, Active Record model names, etc.
17
- * Abstract strings in your application into keyed dictionaries e.g. flash messages, static text in your views, etc.
16
+ * Replace or supplement Rails' default locale - e.g. date and time formats, month names, Active Record model names, etc.
17
+ * Abstract strings in your application into keyed dictionaries - e.g. flash messages, static text in your views, etc.
18
18
  * Store the resulting dictionaries somewhere.
19
19
 
20
20
  This guide will walk you through the I18n API and contains a tutorial on how to internationalize a Rails application from the start.
21
21
 
22
22
  After reading this guide, you will know:
23
23
 
24
+ * How I18n works in Ruby on Rails
25
+ * How to correctly use I18n into a RESTful application in various ways
26
+ * How to use I18n to translate ActiveRecord errors or ActionMailer E-mail subjects
27
+ * Some other tools to go further with the translation process of your application
28
+
24
29
  --------------------------------------------------------------------------------
25
30
 
26
- NOTE: The Ruby I18n framework provides you with all necessary means for internationalization/localization of your Rails application. You may, however, use any of various plugins and extensions available, which add additional functionality or features. See the Rails [I18n Wiki](http://rails-i18n.org/wiki) for more information.
31
+ NOTE: The Ruby I18n framework provides you with all necessary means for internationalization/localization of your Rails application. You may, also use various gems available to add additional functionality or features. See the [rails-i18n gem](https://github.com/svenfuchs/rails-i18n) for more information.
27
32
 
28
33
  How I18n in Ruby on Rails Works
29
34
  -------------------------------
@@ -33,13 +38,13 @@ Internationalization is a complex problem. Natural languages differ in so many w
33
38
  * providing support for English and similar languages out of the box
34
39
  * making it easy to customize and extend everything for other languages
35
40
 
36
- As part of this solution, **every static string in the Rails framework** e.g. Active Record validation messages, time and date formats **has been internationalized**, so _localization_ of a Rails application means "over-riding" these defaults.
41
+ As part of this solution, **every static string in the Rails framework** - e.g. Active Record validation messages, time and date formats - **has been internationalized**, so _localization_ of a Rails application means "over-riding" these defaults.
37
42
 
38
43
  ### The Overall Architecture of the Library
39
44
 
40
45
  Thus, the Ruby I18n gem is split into two parts:
41
46
 
42
- * The public API of the i18n framework a Ruby module with public methods that define how the library works
47
+ * The public API of the i18n framework - a Ruby module with public methods that define how the library works
43
48
  * A default backend (which is intentionally named _Simple_ backend) that implements these methods
44
49
 
45
50
  As a user you should always only access the public methods on the I18n module, but it is useful to know about the capabilities of the backend.
@@ -87,22 +92,22 @@ Rails adds all `.rb` and `.yml` files from the `config/locales` directory to you
87
92
 
88
93
  The default `en.yml` locale in this directory contains a sample pair of translation strings:
89
94
 
90
- ```ruby
95
+ ```yaml
91
96
  en:
92
97
  hello: "Hello world"
93
98
  ```
94
99
 
95
- This means, that in the `:en` locale, the key _hello_ will map to the _Hello world_ string. Every string inside Rails is internationalized in this way, see for instance Active Record validation messages in the [`activerecord/lib/active_record/locale/en.yml`](https://github.com/rails/rails/blob/master/activerecord/lib/active_record/locale/en.yml file or time and date formats in the [`activesupport/lib/active_support/locale/en.yml`](https://github.com/rails/rails/blob/master/activesupport/lib/active_support/locale/en.yml) file. You can use YAML or standard Ruby Hashes to store translations in the default (Simple) backend.
100
+ This means, that in the `:en` locale, the key _hello_ will map to the _Hello world_ string. Every string inside Rails is internationalized in this way, see for instance Active Model validation messages in the [`activemodel/lib/active_model/locale/en.yml`](https://github.com/rails/rails/blob/master/activemodel/lib/active_model/locale/en.yml) file or time and date formats in the [`activesupport/lib/active_support/locale/en.yml`](https://github.com/rails/rails/blob/master/activesupport/lib/active_support/locale/en.yml) file. You can use YAML or standard Ruby Hashes to store translations in the default (Simple) backend.
96
101
 
97
102
  The I18n library will use **English** as a **default locale**, i.e. if you don't set a different locale, `:en` will be used for looking up translations.
98
103
 
99
- NOTE: The i18n library takes a **pragmatic approach** to locale keys (after [some discussion](http://groups.google.com/group/rails-i18n/browse_thread/thread/14dede2c7dbe9470/80eec34395f64f3c?hl=en), including only the _locale_ ("language") part, like `:en`, `:pl`, not the _region_ part, like `:en-US` or `:en-GB`, which are traditionally used for separating "languages" and "regional setting" or "dialects". Many international applications use only the "language" element of a locale such as `:cs`, `:th` or `:es` (for Czech, Thai and Spanish). However, there are also regional differences within different language groups that may be important. For instance, in the `:en-US` locale you would have $ as a currency symbol, while in `:en-GB`, you would have £. Nothing stops you from separating regional and other settings in this way: you just have to provide full "English - United Kingdom" locale in a `:en-GB` dictionary. Various [Rails I18n plugins](http://rails-i18n.org/wiki) such as [Globalize3](https://github.com/svenfuchs/globalize3) may help you implement it.
104
+ NOTE: The i18n library takes a **pragmatic approach** to locale keys (after [some discussion](http://groups.google.com/group/rails-i18n/browse_thread/thread/14dede2c7dbe9470/80eec34395f64f3c?hl=en)), including only the _locale_ ("language") part, like `:en`, `:pl`, not the _region_ part, like `:en-US` or `:en-GB`, which are traditionally used for separating "languages" and "regional setting" or "dialects". Many international applications use only the "language" element of a locale such as `:cs`, `:th` or `:es` (for Czech, Thai and Spanish). However, there are also regional differences within different language groups that may be important. For instance, in the `:en-US` locale you would have $ as a currency symbol, while in `:en-GB`, you would have £. Nothing stops you from separating regional and other settings in this way: you just have to provide full "English - United Kingdom" locale in a `:en-GB` dictionary. Few gems such as [Globalize3](https://github.com/globalize/globalize) may help you implement it.
100
105
 
101
106
  The **translations load path** (`I18n.load_path`) is just a Ruby Array of paths to your translation files that will be loaded automatically and available in your application. You can pick whatever directory and translation file naming scheme makes sense for you.
102
107
 
103
108
  NOTE: The backend will lazy-load these translations when a translation is looked up for the first time. This makes it possible to just swap the backend with something else even after translations have already been announced.
104
109
 
105
- The default `application.rb` files has instructions on how to add locales from another directory and how to set a different default locale. Just uncomment and edit the specific lines.
110
+ The default `application.rb` file has instructions on how to add locales from another directory and how to set a different default locale. Just uncomment and edit the specific lines.
106
111
 
107
112
  ```ruby
108
113
  # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
@@ -132,7 +137,7 @@ If you want to translate your Rails application to a **single language other tha
132
137
 
133
138
  However, you would probably like to **provide support for more locales** in your application. In such case, you need to set and pass the locale between requests.
134
139
 
135
- WARNING: You may be tempted to store the chosen locale in a _session_ or a <em>cookie</em>, however **do not do this**. The locale should be transparent and a part of the URL. This way you won't break people's basic assumptions about the web itself: if you send a URL to a friend, they should see the same page and content as you. A fancy word for this would be that you're being [<em>RESTful</em>](http://en.wikipedia.org/wiki/Representational_State_Transfer. Read more about the RESTful approach in [Stefan Tilkov's articles](http://www.infoq.com/articles/rest-introduction). Sometimes there are exceptions to this rule and those are discussed below.
140
+ WARNING: You may be tempted to store the chosen locale in a _session_ or a *cookie*. However, **do not do this**. The locale should be transparent and a part of the URL. This way you won't break people's basic assumptions about the web itself: if you send a URL to a friend, they should see the same page and content as you. A fancy word for this would be that you're being [*RESTful*](http://en.wikipedia.org/wiki/Representational_State_Transfer). Read more about the RESTful approach in [Stefan Tilkov's articles](http://www.infoq.com/articles/rest-introduction). Sometimes there are exceptions to this rule and those are discussed below.
136
141
 
137
142
  The _setting part_ is easy. You can set the locale in a `before_action` in the `ApplicationController` like this:
138
143
 
@@ -174,7 +179,7 @@ end
174
179
  # in your /etc/hosts file to try this out locally
175
180
  def extract_locale_from_tld
176
181
  parsed_locale = request.host.split('.').last
177
- I18n.available_locales.include?(parsed_locale.to_sym) ? parsed_locale : nil
182
+ I18n.available_locales.map(&:to_s).include?(parsed_locale) ? parsed_locale : nil
178
183
  end
179
184
  ```
180
185
 
@@ -187,7 +192,7 @@ We can also set the locale from the _subdomain_ in a very similar way:
187
192
  # in your /etc/hosts file to try this out locally
188
193
  def extract_locale_from_subdomain
189
194
  parsed_locale = request.subdomains.first
190
- I18n.available_locales.include?(parsed_locale.to_sym) ? parsed_locale : nil
195
+ I18n.available_locales.map(&:to_s).include?(parsed_locale) ? parsed_locale : nil
191
196
  end
192
197
  ```
193
198
 
@@ -207,17 +212,16 @@ The most usual way of setting (and passing) the locale would be to include it in
207
212
 
208
213
  This approach has almost the same set of advantages as setting the locale from the domain name: namely that it's RESTful and in accord with the rest of the World Wide Web. It does require a little bit more work to implement, though.
209
214
 
210
- Getting the locale from `params` and setting it accordingly is not hard; including it in every URL and thus **passing it through the requests** is. To include an explicit option in every URL (e.g. `link_to( books_url(locale: I18n.locale))`) would be tedious and probably impossible, of course.
215
+ Getting the locale from `params` and setting it accordingly is not hard; including it in every URL and thus **passing it through the requests** is. To include an explicit option in every URL, e.g. `link_to(books_url(locale: I18n.locale))`, would be tedious and probably impossible, of course.
211
216
 
212
- Rails contains infrastructure for "centralizing dynamic decisions about the URLs" in its [`ApplicationController#default_url_options`](http://api.rubyonrails.org/classes/ActionController/Base.html#M000515, which is useful precisely in this scenario: it enables us to set "defaults" for [`url_for`](http://api.rubyonrails.org/classes/ActionController/Base.html#M000503) and helper methods dependent on it (by implementing/overriding this method).
217
+ Rails contains infrastructure for "centralizing dynamic decisions about the URLs" in its [`ApplicationController#default_url_options`](http://api.rubyonrails.org/classes/ActionDispatch/Routing/Mapper/Base.html#method-i-default_url_options), which is useful precisely in this scenario: it enables us to set "defaults" for [`url_for`](http://api.rubyonrails.org/classes/ActionDispatch/Routing/UrlFor.html#method-i-url_for) and helper methods dependent on it (by implementing/overriding this method).
213
218
 
214
219
  We can include something like this in our `ApplicationController` then:
215
220
 
216
221
  ```ruby
217
222
  # app/controllers/application_controller.rb
218
- def default_url_options(options={})
219
- logger.debug "default_url_options is passed options: #{options.inspect}\n"
220
- { locale: I18n.locale }
223
+ def default_url_options(options = {})
224
+ { locale: I18n.locale }.merge options
221
225
  end
222
226
  ```
223
227
 
@@ -253,16 +257,16 @@ You would probably need to map URLs like these:
253
257
 
254
258
  ```ruby
255
259
  # config/routes.rb
256
- match '/:locale' => 'dashboard#index'
260
+ get '/:locale' => 'dashboard#index'
257
261
  ```
258
262
 
259
263
  Do take special care about the **order of your routes**, so this route declaration does not "eat" other ones. (You may want to add it directly before the `root :to` declaration.)
260
264
 
261
- NOTE: Have a look at two plugins which simplify work with routes in this way: Sven Fuchs's [routing_filter](https://github.com/svenfuchs/routing-filter/tree/master) and Raul Murciano's [translate_routes](https://github.com/raul/translate_routes/tree/master).
265
+ NOTE: Have a look at various gems which simplify working with routes: [routing_filter](https://github.com/svenfuchs/routing-filter/tree/master), [rails-translate-routes](https://github.com/francesc/rails-translate-routes), [route_translator](https://github.com/enriclluelles/route_translator).
262
266
 
263
267
  ### Setting the Locale from the Client Supplied Information
264
268
 
265
- In specific cases, it would make sense to set the locale from client-supplied information, i.e. not from the URL. This information may come for example from the users' preferred language (set in their browser), can be based on the users' geographical location inferred from their IP, or users can provide it simply by choosing the locale in your application interface and saving it to their profile. This approach is more suitable for web-based applications or services, not for websites see the box about _sessions_, _cookies_ and RESTful architecture above.
269
+ In specific cases, it would make sense to set the locale from client-supplied information, i.e. not from the URL. This information may come for example from the users' preferred language (set in their browser), can be based on the users' geographical location inferred from their IP, or users can provide it simply by choosing the locale in your application interface and saving it to their profile. This approach is more suitable for web-based applications or services, not for websites - see the box about _sessions_, _cookies_ and RESTful architecture above.
266
270
 
267
271
 
268
272
  #### Using `Accept-Language`
@@ -277,21 +281,22 @@ def set_locale
277
281
  I18n.locale = extract_locale_from_accept_language_header
278
282
  logger.debug "* Locale set to '#{I18n.locale}'"
279
283
  end
284
+
280
285
  private
281
- def extract_locale_from_accept_language_header
282
- request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first
283
- end
286
+ def extract_locale_from_accept_language_header
287
+ request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first
288
+ end
284
289
  ```
285
290
 
286
- Of course, in a production environment you would need much more robust code, and could use a plugin such as Iain Hecker's [http_accept_language](https://github.com/iain/http_accept_language/tree/master or even Rack middleware such as Ryan Tomayko's [locale](https://github.com/rack/rack-contrib/blob/master/lib/rack/contrib/locale.rb).
291
+ Of course, in a production environment you would need much more robust code, and could use a gem such as Iain Hecker's [http_accept_language](https://github.com/iain/http_accept_language/tree/master) or even Rack middleware such as Ryan Tomayko's [locale](https://github.com/rack/rack-contrib/blob/master/lib/rack/contrib/locale.rb).
287
292
 
288
293
  #### Using GeoIP (or Similar) Database
289
294
 
290
- Another way of choosing the locale from client information would be to use a database for mapping the client IP to the region, such as [GeoIP Lite Country](http://www.maxmind.com/app/geolitecountry). The mechanics of the code would be very similar to the code above you would need to query the database for the user's IP, and look up your preferred locale for the country/region/city returned.
295
+ Another way of choosing the locale from client information would be to use a database for mapping the client IP to the region, such as [GeoIP Lite Country](http://www.maxmind.com/app/geolitecountry). The mechanics of the code would be very similar to the code above - you would need to query the database for the user's IP, and look up your preferred locale for the country/region/city returned.
291
296
 
292
297
  #### User Profile
293
298
 
294
- You can also provide users of your application with means to set (and possibly over-ride) the locale in your application interface, as well. Again, mechanics for this approach would be very similar to the code above you'd probably let users choose a locale from a dropdown list and save it to their profile in the database. Then you'd set the locale to this value.
299
+ You can also provide users of your application with means to set (and possibly over-ride) the locale in your application interface, as well. Again, mechanics for this approach would be very similar to the code above - you'd probably let users choose a locale from a dropdown list and save it to their profile in the database. Then you'd set the locale to this value.
295
300
 
296
301
  Internationalizing your Application
297
302
  -----------------------------------
@@ -304,11 +309,22 @@ You most probably have something like this in one of your applications:
304
309
 
305
310
  ```ruby
306
311
  # config/routes.rb
307
- Yourapp::Application.routes.draw do
312
+ Rails.application.routes.draw do
308
313
  root to: "home#index"
309
314
  end
310
315
  ```
311
316
 
317
+ ```ruby
318
+ # app/controllers/application_controller.rb
319
+ class ApplicationController < ActionController::Base
320
+ before_action :set_locale
321
+
322
+ def set_locale
323
+ I18n.locale = params[:locale] || I18n.default_locale
324
+ end
325
+ end
326
+ ```
327
+
312
328
  ```ruby
313
329
  # app/controllers/home_controller.rb
314
330
  class HomeController < ApplicationController
@@ -353,7 +369,7 @@ NOTE: Rails adds a `t` (`translate`) helper method to your views so that you do
353
369
 
354
370
  So let's add the missing translations into the dictionary files (i.e. do the "localization" part):
355
371
 
356
- ```ruby
372
+ ```yaml
357
373
  # config/locales/en.yml
358
374
  en:
359
375
  hello_world: Hello world!
@@ -394,7 +410,7 @@ en:
394
410
 
395
411
  ### Adding Date/Time Formats
396
412
 
397
- OK! Now let's add a timestamp to the view, so we can demo the **date/time localization** feature as well. To localize the time format you pass the Time object to `I18n.l` or (preferably) use Rails' `#l` helper. You can pick a format by passing the `:format` option by default the `:default` format is used.
413
+ OK! Now let's add a timestamp to the view, so we can demo the **date/time localization** feature as well. To localize the time format you pass the Time object to `I18n.l` or (preferably) use Rails' `#l` helper. You can pick a format by passing the `:format` option - by default the `:default` format is used.
398
414
 
399
415
  ```erb
400
416
  # app/views/home/index.html.erb
@@ -405,7 +421,7 @@ OK! Now let's add a timestamp to the view, so we can demo the **date/time locali
405
421
 
406
422
  And in our pirate translations file let's add a time format (it's already there in Rails' defaults for English):
407
423
 
408
- ```ruby
424
+ ```yaml
409
425
  # config/locales/pirate.yml
410
426
  pirate:
411
427
  time:
@@ -417,15 +433,15 @@ So that would give you:
417
433
 
418
434
  ![rails i18n demo localized time to pirate](images/i18n/demo_localized_pirate.png)
419
435
 
420
- TIP: Right now you might need to add some more date/time formats in order to make the I18n backend work as expected (at least for the 'pirate' locale). Of course, there's a great chance that somebody already did all the work by **translating Rails' defaults for your locale**. See the [rails-i18n repository at Github](https://github.com/svenfuchs/rails-i18n/tree/master/rails/locale) for an archive of various locale files. When you put such file(s) in `config/locales/` directory, they will automatically be ready for use.
436
+ TIP: Right now you might need to add some more date/time formats in order to make the I18n backend work as expected (at least for the 'pirate' locale). Of course, there's a great chance that somebody already did all the work by **translating Rails' defaults for your locale**. See the [rails-i18n repository at GitHub](https://github.com/svenfuchs/rails-i18n/tree/master/rails/locale) for an archive of various locale files. When you put such file(s) in `config/locales/` directory, they will automatically be ready for use.
421
437
 
422
438
  ### Inflection Rules For Other Locales
423
439
 
424
- Rails 4.0 allows you to define inflection rules (such as rules for singularization and pluralization) for locales other than English. In `config/initializers/inflections.rb`, you can define these rules for multiple locales. The initializer contains a default example for specifying additional rules for English; follow that format for other locales as you see fit.
440
+ Rails allows you to define inflection rules (such as rules for singularization and pluralization) for locales other than English. In `config/initializers/inflections.rb`, you can define these rules for multiple locales. The initializer contains a default example for specifying additional rules for English; follow that format for other locales as you see fit.
425
441
 
426
442
  ### Localized Views
427
443
 
428
- Rails 2.3 introduces another convenient localization feature: localized views (templates). Let's say you have a _BooksController_ in your application. Your _index_ action renders content in `app/views/books/index.html.erb` template. When you put a _localized variant_ of this template: `index.es.html.erb` in the same directory, Rails will render content in this template, when the locale is set to `:es`. When the locale is set to the default locale, the generic `index.html.erb` view will be used. (Future Rails versions may well bring this _automagic_ localization to assets in `public`, etc.)
444
+ Let's say you have a _BooksController_ in your application. Your _index_ action renders content in `app/views/books/index.html.erb` template. When you put a _localized variant_ of this template: `index.es.html.erb` in the same directory, Rails will render content in this template, when the locale is set to `:es`. When the locale is set to the default locale, the generic `index.html.erb` view will be used. (Future Rails versions may well bring this _automagic_ localization to assets in `public`, etc.)
429
445
 
430
446
  You can make use of this feature, e.g. when working with a large amount of static content, which would be clumsy to put inside YAML or Ruby dictionaries. Bear in mind, though, that any change you would like to do later to the template must be propagated to all of them.
431
447
 
@@ -468,19 +484,19 @@ NOTE: The default locale loading mechanism in Rails does not load locale files i
468
484
 
469
485
  ```
470
486
 
471
- Do check the [Rails i18n Wiki](http://rails-i18n.org/wiki) for list of tools available for managing translations.
472
-
473
487
  Overview of the I18n API Features
474
488
  ---------------------------------
475
489
 
476
490
  You should have good understanding of using the i18n library now, knowing all necessary aspects of internationalizing a basic Rails application. In the following chapters, we'll cover it's features in more depth.
477
491
 
492
+ These chapters will show examples using both the `I18n.translate` method as well as the [`translate` view helper method](http://api.rubyonrails.org/classes/ActionView/Helpers/TranslationHelper.html#method-i-translate) (noting the additional feature provide by the view helper method).
493
+
478
494
  Covered are features like these:
479
495
 
480
496
  * looking up translations
481
497
  * interpolating data into translations
482
498
  * pluralizing translations
483
- * using safe HTML translations
499
+ * using safe HTML translations (view helper method only)
484
500
  * localizing dates, numbers, currency, etc.
485
501
 
486
502
  ### Looking up Translations
@@ -494,7 +510,7 @@ I18n.t :message
494
510
  I18n.t 'message'
495
511
  ```
496
512
 
497
- The `translate` method also takes a `:scope` option which can contain one or more additional keys that will be used to specify a namespace or scope for a translation key:
513
+ The `translate` method also takes a `:scope` option which can contain one or more additional keys that will be used to specify a "namespace" or scope for a translation key:
498
514
 
499
515
  ```ruby
500
516
  I18n.t :record_invalid, scope: [:activerecord, :errors, :messages]
@@ -568,6 +584,8 @@ you can look up the `books.index.title` value **inside** `app/views/books/index.
568
584
  <%= t '.title' %>
569
585
  ```
570
586
 
587
+ NOTE: Automatic translation scoping by partial is only available from the `translate` view helper method.
588
+
571
589
  ### Interpolation
572
590
 
573
591
  In many cases you want to abstract your translations so that **variables can be interpolated into the translation**. For this reason the I18n API provides an interpolation feature.
@@ -637,7 +655,7 @@ I18n.default_locale = :de
637
655
 
638
656
  ### Using Safe HTML Translations
639
657
 
640
- Keys with a '_html' suffix and keys named 'html' are marked as HTML safe. Use them in views without escaping.
658
+ Keys with a '_html' suffix and keys named 'html' are marked as HTML safe. When you use them in views the HTML will not be escaped.
641
659
 
642
660
  ```yaml
643
661
  # config/locales/en.yml
@@ -656,56 +674,25 @@ en:
656
674
  <div><%= t('title.html') %></div>
657
675
  ```
658
676
 
659
- ![i18n demo html safe](images/i18n/demo_html_safe.png)
660
-
661
- How to Store your Custom Translations
662
- -------------------------------------
663
-
664
- The Simple backend shipped with Active Support allows you to store translations in both plain Ruby and YAML format.[^2]
665
-
666
- For example a Ruby Hash providing translations can look like this:
667
-
668
- ```ruby
669
- {
670
- pt: {
671
- foo: {
672
- bar: "baz"
673
- }
674
- }
675
- }
676
- ```
677
+ Interpolation escapes as needed though. For example, given:
677
678
 
678
- The equivalent YAML file would look like this:
679
-
680
- ```ruby
681
- pt:
682
- foo:
683
- bar: baz
679
+ ```yaml
680
+ en:
681
+ welcome_html: "<b>Welcome %{username}!</b>"
684
682
  ```
685
683
 
686
- As you see, in both cases the top level key is the locale. `:foo` is a namespace key and `:bar` is the key for the translation "baz".
684
+ you can safely pass the username as set by the user:
687
685
 
688
- Here is a "real" example from the Active Support `en.yml` translations YAML file:
689
-
690
- ```ruby
691
- en:
692
- date:
693
- formats:
694
- default: "%Y-%m-%d"
695
- short: "%b %d"
696
- long: "%B %d, %Y"
686
+ ```erb
687
+ <%# This is safe, it is going to be escaped if needed. %>
688
+ <%= t('welcome_html', username: @current_user.username) %>
697
689
  ```
698
690
 
699
- So, all of the following equivalent lookups will return the `:short` date format `"%b %d"`:
691
+ Safe strings on the other hand are interpolated verbatim.
700
692
 
701
- ```ruby
702
- I18n.t 'date.formats.short'
703
- I18n.t 'formats.short', scope: :date
704
- I18n.t :short, scope: 'date.formats'
705
- I18n.t :short, scope: [:date, :formats]
706
- ```
693
+ NOTE: Automatic conversion to HTML safe translate text is only available from the `translate` view helper method.
707
694
 
708
- Generally we recommend using YAML as a format for storing translations. There are cases, though, where you want to store Ruby lambdas as part of your locale data, e.g. for special date formats.
695
+ ![i18n demo html safe](images/i18n/demo_html_safe.png)
709
696
 
710
697
  ### Translations for Active Record Models
711
698
 
@@ -713,7 +700,7 @@ You can use the methods `Model.model_name.human` and `Model.human_attribute_name
713
700
 
714
701
  For example when you add the following translations:
715
702
 
716
- ```ruby
703
+ ```yaml
717
704
  en:
718
705
  activerecord:
719
706
  models:
@@ -726,6 +713,32 @@ en:
726
713
 
727
714
  Then `User.model_name.human` will return "Dude" and `User.human_attribute_name("login")` will return "Handle".
728
715
 
716
+ You can also set a plural form for model names, adding as following:
717
+
718
+ ```yaml
719
+ en:
720
+ activerecord:
721
+ models:
722
+ user:
723
+ one: Dude
724
+ other: Dudes
725
+ ```
726
+
727
+ Then `User.model_name.human(count: 2)` will return "Dudes". With `count: 1` or without params will return "Dude".
728
+
729
+ In the event you need to access nested attributes within a given model, you should nest these under `model/attribute` at the model level of your translation file:
730
+
731
+ ```yaml
732
+ en:
733
+ activerecord:
734
+ attributes:
735
+ user/gender:
736
+ female: "Female"
737
+ male: "Male"
738
+ ```
739
+
740
+ Then `User.human_attribute_name("gender.female")` will return "Female".
741
+
729
742
  #### Error Message Scopes
730
743
 
731
744
  Active Record validation error messages can also be translated easily. Active Record gives you a couple of namespaces where you can place your message translations in order to provide different messages and translation for certain models, attributes, and/or validations. It also transparently takes single table inheritance into account.
@@ -788,15 +801,16 @@ This way you can provide special translations for various error messages at diff
788
801
 
789
802
  The translated model name, translated attribute name, and value are always available for interpolation.
790
803
 
791
- So, for example, instead of the default error message `"can not be blank"` you could use the attribute name like this : `"Please fill in your %{attribute}"`.
804
+ So, for example, instead of the default error message `"cannot be blank"` you could use the attribute name like this : `"Please fill in your %{attribute}"`.
792
805
 
793
806
  * `count`, where available, can be used for pluralization if present:
794
807
 
795
808
  | validation | with option | message | interpolation |
796
809
  | ------------ | ------------------------- | ------------------------- | ------------- |
797
- | confirmation | - | :confirmation | - |
810
+ | confirmation | - | :confirmation | attribute |
798
811
  | acceptance | - | :accepted | - |
799
812
  | presence | - | :blank | - |
813
+ | absence | - | :present | - |
800
814
  | length | :within, :in | :too_short | count |
801
815
  | length | :within, :in | :too_long | count |
802
816
  | length | :is | :wrong_length | count |
@@ -813,6 +827,8 @@ So, for example, instead of the default error message `"can not be blank"` you c
813
827
  | numericality | :equal_to | :equal_to | count |
814
828
  | numericality | :less_than | :less_than | count |
815
829
  | numericality | :less_than_or_equal_to | :less_than_or_equal_to | count |
830
+ | numericality | :other_than | :other_than | count |
831
+ | numericality | :only_integer | :not_an_integer | - |
816
832
  | numericality | :odd | :odd | - |
817
833
  | numericality | :even | :even | - |
818
834
 
@@ -859,21 +875,39 @@ en:
859
875
  subject: "Welcome to Rails Guides!"
860
876
  ```
861
877
 
878
+ To send parameters to interpolation use the `default_i18n_subject` method on the mailer.
879
+
880
+ ```ruby
881
+ # user_mailer.rb
882
+ class UserMailer < ActionMailer::Base
883
+ def welcome(user)
884
+ mail(to: user.email, subject: default_i18n_subject(user: user.name))
885
+ end
886
+ end
887
+ ```
888
+
889
+ ```yaml
890
+ en:
891
+ user_mailer:
892
+ welcome:
893
+ subject: "%{user}, welcome to Rails Guides!"
894
+ ```
895
+
862
896
  ### Overview of Other Built-In Methods that Provide I18n Support
863
897
 
864
898
  Rails uses fixed strings and other localizations, such as format strings and other format information in a couple of helpers. Here's a brief overview.
865
899
 
866
900
  #### Action View Helper Methods
867
901
 
868
- * `distance_of_time_in_words` translates and pluralizes its result and interpolates the number of seconds, minutes, hours, and so on. See [datetime.distance_in_words](https://github.com/rails/rails/blob/master/actionpack/lib/action_view/locale/en.yml#L51) translations.
902
+ * `distance_of_time_in_words` translates and pluralizes its result and interpolates the number of seconds, minutes, hours, and so on. See [datetime.distance_in_words](https://github.com/rails/rails/blob/master/actionview/lib/action_view/locale/en.yml#L4) translations.
869
903
 
870
- * `datetime_select` and `select_month` use translated month names for populating the resulting select tag. See [date.month_names](https://github.com/rails/rails/blob/master/activesupport/lib/active_support/locale/en.yml#L15) for translations. `datetime_select` also looks up the order option from [date.order](https://github.com/rails/rails/blob/master/activesupport/lib/active_support/locale/en.yml#L18) (unless you pass the option explicitly). All date selection helpers translate the prompt using the translations in the [datetime.prompts](https://github.com/rails/rails/blob/master/actionpack/lib/action_view/locale/en.yml#L83) scope if applicable.
904
+ * `datetime_select` and `select_month` use translated month names for populating the resulting select tag. See [date.month_names](https://github.com/rails/rails/blob/master/activesupport/lib/active_support/locale/en.yml#L15) for translations. `datetime_select` also looks up the order option from [date.order](https://github.com/rails/rails/blob/master/activesupport/lib/active_support/locale/en.yml#L18) (unless you pass the option explicitly). All date selection helpers translate the prompt using the translations in the [datetime.prompts](https://github.com/rails/rails/blob/master/actionview/lib/action_view/locale/en.yml#L39) scope if applicable.
871
905
 
872
- * The `number_to_currency`, `number_with_precision`, `number_to_percentage`, `number_with_delimiter`, and `number_to_human_size` helpers use the number format settings located in the [number](https://github.com/rails/rails/blob/master/actionpack/lib/action_view/locale/en.yml#L2) scope.
906
+ * The `number_to_currency`, `number_with_precision`, `number_to_percentage`, `number_with_delimiter`, and `number_to_human_size` helpers use the number format settings located in the [number](https://github.com/rails/rails/blob/master/activesupport/lib/active_support/locale/en.yml#L37) scope.
873
907
 
874
908
  #### Active Model Methods
875
909
 
876
- * `model_name.human` and `human_attribute_name` use translations for model names and attribute names if available in the [activerecord.models](https://github.com/rails/rails/blob/master/activerecord/lib/active_record/locale/en.yml#L29) scope. They also support translations for inherited class names (e.g. for use with STI) as explained above in "Error message scopes".
910
+ * `model_name.human` and `human_attribute_name` use translations for model names and attribute names if available in the [activerecord.models](https://github.com/rails/rails/blob/master/activerecord/lib/active_record/locale/en.yml#L36) scope. They also support translations for inherited class names (e.g. for use with STI) as explained above in "Error message scopes".
877
911
 
878
912
  * `ActiveModel::Errors#generate_message` (which is used by Active Model validations but may also be used manually) uses `model_name.human` and `human_attribute_name` (see above). It also translates the error message and supports translations for inherited class names as explained above in "Error message scopes".
879
913
 
@@ -881,14 +915,63 @@ Rails uses fixed strings and other localizations, such as format strings and oth
881
915
 
882
916
  #### Active Support Methods
883
917
 
884
- * `Array#to_sentence` uses format settings as given in the [support.array](https://github.com/rails/rails/blob/master/activesupport/lib/active_support/locale/en.yml#L30) scope.
918
+ * `Array#to_sentence` uses format settings as given in the [support.array](https://github.com/rails/rails/blob/master/activesupport/lib/active_support/locale/en.yml#L33) scope.
919
+
920
+ How to Store your Custom Translations
921
+ -------------------------------------
922
+
923
+ The Simple backend shipped with Active Support allows you to store translations in both plain Ruby and YAML format.[^2]
924
+
925
+ For example a Ruby Hash providing translations can look like this:
926
+
927
+ ```yaml
928
+ {
929
+ pt: {
930
+ foo: {
931
+ bar: "baz"
932
+ }
933
+ }
934
+ }
935
+ ```
936
+
937
+ The equivalent YAML file would look like this:
938
+
939
+ ```yaml
940
+ pt:
941
+ foo:
942
+ bar: baz
943
+ ```
944
+
945
+ As you see, in both cases the top level key is the locale. `:foo` is a namespace key and `:bar` is the key for the translation "baz".
946
+
947
+ Here is a "real" example from the Active Support `en.yml` translations YAML file:
948
+
949
+ ```yaml
950
+ en:
951
+ date:
952
+ formats:
953
+ default: "%Y-%m-%d"
954
+ short: "%b %d"
955
+ long: "%B %d, %Y"
956
+ ```
957
+
958
+ So, all of the following equivalent lookups will return the `:short` date format `"%b %d"`:
959
+
960
+ ```ruby
961
+ I18n.t 'date.formats.short'
962
+ I18n.t 'formats.short', scope: :date
963
+ I18n.t :short, scope: 'date.formats'
964
+ I18n.t :short, scope: [:date, :formats]
965
+ ```
966
+
967
+ Generally we recommend using YAML as a format for storing translations. There are cases, though, where you want to store Ruby lambdas as part of your locale data, e.g. for special date formats.
885
968
 
886
969
  Customize your I18n Setup
887
970
  -------------------------
888
971
 
889
972
  ### Using Different Backends
890
973
 
891
- For several reasons the Simple backend shipped with Active Support only does the "simplest thing that could possibly work" _for Ruby on Rails_[^3] ... which means that it is only guaranteed to work for English and, as a side effect, languages that are very similar to English. Also, the simple backend is only capable of reading translations but can not dynamically store them to any format.
974
+ For several reasons the Simple backend shipped with Active Support only does the "simplest thing that could possibly work" _for Ruby on Rails_[^3] ... which means that it is only guaranteed to work for English and, as a side effect, languages that are very similar to English. Also, the simple backend is only capable of reading translations but cannot dynamically store them to any format.
892
975
 
893
976
  That does not mean you're stuck with these limitations, though. The Ruby I18n gem makes it very easy to exchange the Simple backend implementation with something else that fits better for your needs. E.g. you could exchange it with Globalize's Static backend:
894
977
 
@@ -915,7 +998,7 @@ ReservedInterpolationKey # the translation contains a reserved interpolation
915
998
  UnknownFileType # the backend does not know how to handle a file type that was added to I18n.load_path
916
999
  ```
917
1000
 
918
- The I18n API will catch all of these exceptions when they are thrown in the backend and pass them to the default_exception_handler method. This method will re-raise all exceptions except for `MissingTranslationData` exceptions. When a `MissingTranslationData` exception has been caught, it will return the exceptions error message string containing the missing key/scope.
1001
+ The I18n API will catch all of these exceptions when they are thrown in the backend and pass them to the default_exception_handler method. This method will re-raise all exceptions except for `MissingTranslationData` exceptions. When a `MissingTranslationData` exception has been caught, it will return the exception's error message string containing the missing key/scope.
919
1002
 
920
1003
  The reason for this is that during development you'd usually want your views to still render even though a translation is missing.
921
1004
 
@@ -968,9 +1051,9 @@ If you find anything missing or wrong in this guide, please file a ticket on our
968
1051
  Contributing to Rails I18n
969
1052
  --------------------------
970
1053
 
971
- I18n support in Ruby on Rails was introduced in the release 2.2 and is still evolving. The project follows the good Ruby on Rails development tradition of evolving solutions in plugins and real applications first, and only then cherry-picking the best-of-breed of most widely useful features for inclusion in the core.
1054
+ I18n support in Ruby on Rails was introduced in the release 2.2 and is still evolving. The project follows the good Ruby on Rails development tradition of evolving solutions in gems and real applications first, and only then cherry-picking the best-of-breed of most widely useful features for inclusion in the core.
972
1055
 
973
- Thus we encourage everybody to experiment with new ideas and features in plugins or other libraries and make them available to the community. (Don't forget to announce your work on our [mailing list](http://groups.google.com/group/rails-i18n!))
1056
+ Thus we encourage everybody to experiment with new ideas and features in gems or other libraries and make them available to the community. (Don't forget to announce your work on our [mailing list](http://groups.google.com/group/rails-i18n!))
974
1057
 
975
1058
  If you find your own locale (language) missing from our [example translations data](https://github.com/svenfuchs/rails-i18n/tree/master/rails/locale) repository for Ruby on Rails, please [_fork_](https://github.com/guides/fork-a-project-and-submit-your-modifications) the repository, add your data and send a [pull request](https://github.com/guides/pull-requests).
976
1059
 
@@ -978,10 +1061,9 @@ If you find your own locale (language) missing from our [example translations da
978
1061
  Resources
979
1062
  ---------
980
1063
 
981
- * [rails-i18n.org](http://rails-i18n.org) - Homepage of the rails-i18n project. You can find lots of useful resources on the [wiki](http://rails-i18n.org/wiki).
982
1064
  * [Google group: rails-i18n](http://groups.google.com/group/rails-i18n) - The project's mailing list.
983
- * [Github: rails-i18n](https://github.com/svenfuchs/rails-i18n/tree/master) - Code repository for the rails-i18n project. Most importantly you can find lots of [example translations](https://github.com/svenfuchs/rails-i18n/tree/master/rails/locale) for Rails that should work for your application in most cases.
984
- * [Github: i18n](https://github.com/svenfuchs/i18n/tree/master) - Code repository for the i18n gem.
1065
+ * [GitHub: rails-i18n](https://github.com/svenfuchs/rails-i18n/tree/master) - Code repository for the rails-i18n project. Most importantly you can find lots of [example translations](https://github.com/svenfuchs/rails-i18n/tree/master/rails/locale) for Rails that should work for your application in most cases.
1066
+ * [GitHub: i18n](https://github.com/svenfuchs/i18n/tree/master) - Code repository for the i18n gem.
985
1067
  * [Lighthouse: rails-i18n](http://i18n.lighthouseapp.com/projects/14948-rails-i18n/overview) - Issue tracker for the rails-i18n project.
986
1068
  * [Lighthouse: i18n](http://i18n.lighthouseapp.com/projects/14947-ruby-i18n/overview) - Issue tracker for the i18n gem.
987
1069
 
@@ -998,7 +1080,7 @@ If you found this guide useful, please consider recommending its authors on [wor
998
1080
  Footnotes
999
1081
  ---------
1000
1082
 
1001
- [^1]: Or, to quote [Wikipedia](http://en.wikipedia.org/wiki/Internationalization_and_localization:) _"Internationalization is the process of designing a software application so that it can be adapted to various languages and regions without engineering changes. Localization is the process of adapting software for a specific region or language by adding locale-specific components and translating text."_
1083
+ [^1]: Or, to quote [Wikipedia](http://en.wikipedia.org/wiki/Internationalization_and_localization): _"Internationalization is the process of designing a software application so that it can be adapted to various languages and regions without engineering changes. Localization is the process of adapting software for a specific region or language by adding locale-specific components and translating text."_
1002
1084
 
1003
1085
  [^2]: Other backends might allow or require to use other formats, e.g. a GetText backend might allow to read GetText files.
1004
1086