rails 4.2.0.beta4 → 4.2.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (230) hide show
  1. checksums.yaml +4 -4
  2. data/guides/Rakefile +3 -1
  3. data/guides/bug_report_templates/action_controller_gem.rb +2 -2
  4. data/guides/bug_report_templates/action_controller_master.rb +2 -2
  5. data/guides/source/3_0_release_notes.md +2 -2
  6. data/guides/source/4_1_release_notes.md +1 -1
  7. data/guides/source/4_2_release_notes.md +250 -225
  8. data/guides/source/_welcome.html.erb +1 -1
  9. data/guides/source/action_controller_overview.md +6 -6
  10. data/guides/source/action_mailer_basics.md +26 -11
  11. data/guides/source/action_view_overview.md +0 -1
  12. data/guides/source/active_job_basics.md +29 -23
  13. data/guides/source/active_record_postgresql.md +2 -7
  14. data/guides/source/active_record_validations.md +1 -0
  15. data/guides/source/active_support_core_extensions.md +1 -1
  16. data/guides/source/active_support_instrumentation.md +5 -5
  17. data/guides/source/asset_pipeline.md +2 -2
  18. data/guides/source/association_basics.md +0 -2
  19. data/guides/source/command_line.md +6 -15
  20. data/guides/source/configuring.md +4 -4
  21. data/guides/source/documents.yaml +0 -1
  22. data/guides/source/engines.md +26 -15
  23. data/guides/source/form_helpers.md +10 -2
  24. data/guides/source/getting_started.md +9 -9
  25. data/guides/source/rails_on_rack.md +2 -2
  26. data/guides/source/ruby_on_rails_guides_guidelines.md +1 -0
  27. data/guides/source/security.md +1 -1
  28. data/guides/source/testing.md +80 -13
  29. data/guides/source/upgrading_ruby_on_rails.md +23 -20
  30. metadata +29 -229
  31. data/guides/output/2_2_release_notes.html +0 -724
  32. data/guides/output/2_3_release_notes.html +0 -870
  33. data/guides/output/3_0_release_notes.html +0 -773
  34. data/guides/output/3_1_release_notes.html +0 -740
  35. data/guides/output/3_2_release_notes.html +0 -797
  36. data/guides/output/4_0_release_notes.html +0 -523
  37. data/guides/output/4_1_release_notes.html +0 -806
  38. data/guides/output/4_2_release_notes.html +0 -728
  39. data/guides/output/Gemfile +0 -6
  40. data/guides/output/_license.html +0 -226
  41. data/guides/output/_welcome.html +0 -233
  42. data/guides/output/action_controller_overview.html +0 -1335
  43. data/guides/output/action_mailer_basics.html +0 -928
  44. data/guides/output/action_view_overview.html +0 -1509
  45. data/guides/output/active_job_basics.html +0 -546
  46. data/guides/output/active_model_basics.html +0 -438
  47. data/guides/output/active_record_basics.html +0 -594
  48. data/guides/output/active_record_callbacks.html +0 -592
  49. data/guides/output/active_record_migrations.html +0 -1123
  50. data/guides/output/active_record_postgresql.html +0 -675
  51. data/guides/output/active_record_querying.html +0 -1796
  52. data/guides/output/active_record_validations.html +0 -1301
  53. data/guides/output/active_support_core_extensions.html +0 -3450
  54. data/guides/output/active_support_instrumentation.html +0 -1121
  55. data/guides/output/api_documentation_guidelines.html +0 -498
  56. data/guides/output/asset_pipeline.html +0 -1167
  57. data/guides/output/association_basics.html +0 -2086
  58. data/guides/output/caching_with_rails.html +0 -553
  59. data/guides/output/command_line.html +0 -791
  60. data/guides/output/configuring.html +0 -1055
  61. data/guides/output/contributing_to_ruby_on_rails.html +0 -657
  62. data/guides/output/credits.html +0 -284
  63. data/guides/output/debugging_rails_applications.html +0 -1014
  64. data/guides/output/development_dependencies_install.html +0 -478
  65. data/guides/output/engines.html +0 -1438
  66. data/guides/output/form_helpers.html +0 -1074
  67. data/guides/output/generators.html +0 -838
  68. data/guides/output/getting_started.html +0 -2092
  69. data/guides/output/i18n.html +0 -1198
  70. data/guides/output/images/akshaysurve.jpg +0 -0
  71. data/guides/output/images/belongs_to.png +0 -0
  72. data/guides/output/images/book_icon.gif +0 -0
  73. data/guides/output/images/bullet.gif +0 -0
  74. data/guides/output/images/chapters_icon.gif +0 -0
  75. data/guides/output/images/check_bullet.gif +0 -0
  76. data/guides/output/images/credits_pic_blank.gif +0 -0
  77. data/guides/output/images/csrf.png +0 -0
  78. data/guides/output/images/edge_badge.png +0 -0
  79. data/guides/output/images/favicon.ico +0 -0
  80. data/guides/output/images/feature_tile.gif +0 -0
  81. data/guides/output/images/footer_tile.gif +0 -0
  82. data/guides/output/images/fxn.png +0 -0
  83. data/guides/output/images/getting_started/article_with_comments.png +0 -0
  84. data/guides/output/images/getting_started/challenge.png +0 -0
  85. data/guides/output/images/getting_started/confirm_dialog.png +0 -0
  86. data/guides/output/images/getting_started/forbidden_attributes_for_new_article.png +0 -0
  87. data/guides/output/images/getting_started/forbidden_attributes_for_new_post.png +0 -0
  88. data/guides/output/images/getting_started/form_with_errors.png +0 -0
  89. data/guides/output/images/getting_started/index_action_with_edit_link.png +0 -0
  90. data/guides/output/images/getting_started/new_article.png +0 -0
  91. data/guides/output/images/getting_started/new_post.png +0 -0
  92. data/guides/output/images/getting_started/post_with_comments.png +0 -0
  93. data/guides/output/images/getting_started/rails_welcome.png +0 -0
  94. data/guides/output/images/getting_started/routing_error_no_controller.png +0 -0
  95. data/guides/output/images/getting_started/routing_error_no_route_matches.png +0 -0
  96. data/guides/output/images/getting_started/show_action_for_articles.png +0 -0
  97. data/guides/output/images/getting_started/show_action_for_posts.png +0 -0
  98. data/guides/output/images/getting_started/template_is_missing_articles_new.png +0 -0
  99. data/guides/output/images/getting_started/template_is_missing_posts_new.png +0 -0
  100. data/guides/output/images/getting_started/undefined_method_post_path.png +0 -0
  101. data/guides/output/images/getting_started/unknown_action_create_for_articles.png +0 -0
  102. data/guides/output/images/getting_started/unknown_action_create_for_posts.png +0 -0
  103. data/guides/output/images/getting_started/unknown_action_new_for_articles.png +0 -0
  104. data/guides/output/images/getting_started/unknown_action_new_for_posts.png +0 -0
  105. data/guides/output/images/grey_bullet.gif +0 -0
  106. data/guides/output/images/habtm.png +0 -0
  107. data/guides/output/images/has_many.png +0 -0
  108. data/guides/output/images/has_many_through.png +0 -0
  109. data/guides/output/images/has_one.png +0 -0
  110. data/guides/output/images/has_one_through.png +0 -0
  111. data/guides/output/images/header_backdrop.png +0 -0
  112. data/guides/output/images/header_tile.gif +0 -0
  113. data/guides/output/images/i18n/demo_html_safe.png +0 -0
  114. data/guides/output/images/i18n/demo_localized_pirate.png +0 -0
  115. data/guides/output/images/i18n/demo_translated_en.png +0 -0
  116. data/guides/output/images/i18n/demo_translated_pirate.png +0 -0
  117. data/guides/output/images/i18n/demo_translation_missing.png +0 -0
  118. data/guides/output/images/i18n/demo_untranslated.png +0 -0
  119. data/guides/output/images/icons/README +0 -5
  120. data/guides/output/images/icons/callouts/1.png +0 -0
  121. data/guides/output/images/icons/callouts/10.png +0 -0
  122. data/guides/output/images/icons/callouts/11.png +0 -0
  123. data/guides/output/images/icons/callouts/12.png +0 -0
  124. data/guides/output/images/icons/callouts/13.png +0 -0
  125. data/guides/output/images/icons/callouts/14.png +0 -0
  126. data/guides/output/images/icons/callouts/15.png +0 -0
  127. data/guides/output/images/icons/callouts/2.png +0 -0
  128. data/guides/output/images/icons/callouts/3.png +0 -0
  129. data/guides/output/images/icons/callouts/4.png +0 -0
  130. data/guides/output/images/icons/callouts/5.png +0 -0
  131. data/guides/output/images/icons/callouts/6.png +0 -0
  132. data/guides/output/images/icons/callouts/7.png +0 -0
  133. data/guides/output/images/icons/callouts/8.png +0 -0
  134. data/guides/output/images/icons/callouts/9.png +0 -0
  135. data/guides/output/images/icons/caution.png +0 -0
  136. data/guides/output/images/icons/example.png +0 -0
  137. data/guides/output/images/icons/home.png +0 -0
  138. data/guides/output/images/icons/important.png +0 -0
  139. data/guides/output/images/icons/next.png +0 -0
  140. data/guides/output/images/icons/note.png +0 -0
  141. data/guides/output/images/icons/prev.png +0 -0
  142. data/guides/output/images/icons/tip.png +0 -0
  143. data/guides/output/images/icons/up.png +0 -0
  144. data/guides/output/images/icons/warning.png +0 -0
  145. data/guides/output/images/nav_arrow.gif +0 -0
  146. data/guides/output/images/oscardelben.jpg +0 -0
  147. data/guides/output/images/polymorphic.png +0 -0
  148. data/guides/output/images/radar.png +0 -0
  149. data/guides/output/images/rails4_features.png +0 -0
  150. data/guides/output/images/rails_guides_kindle_cover.jpg +0 -0
  151. data/guides/output/images/rails_guides_logo.gif +0 -0
  152. data/guides/output/images/rails_logo_remix.gif +0 -0
  153. data/guides/output/images/session_fixation.png +0 -0
  154. data/guides/output/images/tab_grey.gif +0 -0
  155. data/guides/output/images/tab_info.gif +0 -0
  156. data/guides/output/images/tab_note.gif +0 -0
  157. data/guides/output/images/tab_red.gif +0 -0
  158. data/guides/output/images/tab_yellow.gif +0 -0
  159. data/guides/output/images/tab_yellow.png +0 -0
  160. data/guides/output/images/vijaydev.jpg +0 -0
  161. data/guides/output/index.html +0 -354
  162. data/guides/output/initialization.html +0 -876
  163. data/guides/output/javascripts/guides.js +0 -59
  164. data/guides/output/javascripts/jquery.min.js +0 -4
  165. data/guides/output/javascripts/responsive-tables.js +0 -43
  166. data/guides/output/javascripts/syntaxhighlighter/shBrushAS3.js +0 -59
  167. data/guides/output/javascripts/syntaxhighlighter/shBrushAppleScript.js +0 -75
  168. data/guides/output/javascripts/syntaxhighlighter/shBrushBash.js +0 -59
  169. data/guides/output/javascripts/syntaxhighlighter/shBrushCSharp.js +0 -65
  170. data/guides/output/javascripts/syntaxhighlighter/shBrushColdFusion.js +0 -100
  171. data/guides/output/javascripts/syntaxhighlighter/shBrushCpp.js +0 -97
  172. data/guides/output/javascripts/syntaxhighlighter/shBrushCss.js +0 -91
  173. data/guides/output/javascripts/syntaxhighlighter/shBrushDelphi.js +0 -55
  174. data/guides/output/javascripts/syntaxhighlighter/shBrushDiff.js +0 -41
  175. data/guides/output/javascripts/syntaxhighlighter/shBrushErlang.js +0 -52
  176. data/guides/output/javascripts/syntaxhighlighter/shBrushGroovy.js +0 -67
  177. data/guides/output/javascripts/syntaxhighlighter/shBrushJScript.js +0 -52
  178. data/guides/output/javascripts/syntaxhighlighter/shBrushJava.js +0 -57
  179. data/guides/output/javascripts/syntaxhighlighter/shBrushJavaFX.js +0 -58
  180. data/guides/output/javascripts/syntaxhighlighter/shBrushPerl.js +0 -72
  181. data/guides/output/javascripts/syntaxhighlighter/shBrushPhp.js +0 -88
  182. data/guides/output/javascripts/syntaxhighlighter/shBrushPlain.js +0 -33
  183. data/guides/output/javascripts/syntaxhighlighter/shBrushPowerShell.js +0 -74
  184. data/guides/output/javascripts/syntaxhighlighter/shBrushPython.js +0 -64
  185. data/guides/output/javascripts/syntaxhighlighter/shBrushRuby.js +0 -55
  186. data/guides/output/javascripts/syntaxhighlighter/shBrushSass.js +0 -94
  187. data/guides/output/javascripts/syntaxhighlighter/shBrushScala.js +0 -51
  188. data/guides/output/javascripts/syntaxhighlighter/shBrushSql.js +0 -66
  189. data/guides/output/javascripts/syntaxhighlighter/shBrushVb.js +0 -56
  190. data/guides/output/javascripts/syntaxhighlighter/shBrushXml.js +0 -69
  191. data/guides/output/javascripts/syntaxhighlighter/shCore.js +0 -17
  192. data/guides/output/layout.html +0 -448
  193. data/guides/output/layouts_and_rendering.html +0 -1541
  194. data/guides/output/maintenance_policy.html +0 -257
  195. data/guides/output/migrations.html +0 -1360
  196. data/guides/output/nested_model_forms.html +0 -412
  197. data/guides/output/plugins.html +0 -644
  198. data/guides/output/rails_application_templates.html +0 -450
  199. data/guides/output/rails_on_rack.html +0 -547
  200. data/guides/output/routing.html +0 -1631
  201. data/guides/output/ruby_on_rails_guides_guidelines.html +0 -329
  202. data/guides/output/security.html +0 -935
  203. data/guides/output/stylesheets/fixes.css +0 -16
  204. data/guides/output/stylesheets/kindle.css +0 -11
  205. data/guides/output/stylesheets/main.css +0 -713
  206. data/guides/output/stylesheets/print.css +0 -52
  207. data/guides/output/stylesheets/reset.css +0 -43
  208. data/guides/output/stylesheets/responsive-tables.css +0 -50
  209. data/guides/output/stylesheets/style.css +0 -13
  210. data/guides/output/stylesheets/syntaxhighlighter/shCore.css +0 -226
  211. data/guides/output/stylesheets/syntaxhighlighter/shCoreDefault.css +0 -328
  212. data/guides/output/stylesheets/syntaxhighlighter/shCoreDjango.css +0 -331
  213. data/guides/output/stylesheets/syntaxhighlighter/shCoreEclipse.css +0 -339
  214. data/guides/output/stylesheets/syntaxhighlighter/shCoreEmacs.css +0 -324
  215. data/guides/output/stylesheets/syntaxhighlighter/shCoreFadeToGrey.css +0 -328
  216. data/guides/output/stylesheets/syntaxhighlighter/shCoreMDUltra.css +0 -324
  217. data/guides/output/stylesheets/syntaxhighlighter/shCoreMidnight.css +0 -324
  218. data/guides/output/stylesheets/syntaxhighlighter/shCoreRDark.css +0 -324
  219. data/guides/output/stylesheets/syntaxhighlighter/shThemeDefault.css +0 -117
  220. data/guides/output/stylesheets/syntaxhighlighter/shThemeDjango.css +0 -120
  221. data/guides/output/stylesheets/syntaxhighlighter/shThemeEclipse.css +0 -128
  222. data/guides/output/stylesheets/syntaxhighlighter/shThemeEmacs.css +0 -113
  223. data/guides/output/stylesheets/syntaxhighlighter/shThemeFadeToGrey.css +0 -117
  224. data/guides/output/stylesheets/syntaxhighlighter/shThemeMDUltra.css +0 -113
  225. data/guides/output/stylesheets/syntaxhighlighter/shThemeMidnight.css +0 -113
  226. data/guides/output/stylesheets/syntaxhighlighter/shThemeRDark.css +0 -113
  227. data/guides/output/stylesheets/syntaxhighlighter/shThemeRailsGuides.css +0 -116
  228. data/guides/output/testing.html +0 -1350
  229. data/guides/output/upgrading_ruby_on_rails.html +0 -1135
  230. data/guides/output/working_with_javascript_in_rails.html +0 -587
@@ -1,1198 +0,0 @@
1
- <!DOCTYPE html>
2
-
3
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
- <head>
5
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
6
- <meta name="viewport" content="width=device-width, initial-scale=1"/>
7
-
8
- <title>Rails Internationalization (I18n) API — Ruby on Rails Guides</title>
9
- <link rel="stylesheet" type="text/css" href="stylesheets/style.css" />
10
- <link rel="stylesheet" type="text/css" href="stylesheets/print.css" media="print" />
11
-
12
- <link rel="stylesheet" type="text/css" href="stylesheets/syntaxhighlighter/shCore.css" />
13
- <link rel="stylesheet" type="text/css" href="stylesheets/syntaxhighlighter/shThemeRailsGuides.css" />
14
-
15
- <link rel="stylesheet" type="text/css" href="stylesheets/fixes.css" />
16
-
17
- <link href="images/favicon.ico" rel="shortcut icon" type="image/x-icon" />
18
- </head>
19
- <body class="guide">
20
- <div id="topNav">
21
- <div class="wrapper">
22
- <strong class="more-info-label">More at <a href="http://rubyonrails.org/">rubyonrails.org:</a> </strong>
23
- <span class="red-button more-info-button">
24
- More Ruby on Rails
25
- </span>
26
- <ul class="more-info-links s-hidden">
27
- <li class="more-info"><a href="http://rubyonrails.org/">Overview</a></li>
28
- <li class="more-info"><a href="http://rubyonrails.org/download">Download</a></li>
29
- <li class="more-info"><a href="http://rubyonrails.org/deploy">Deploy</a></li>
30
- <li class="more-info"><a href="https://github.com/rails/rails">Code</a></li>
31
- <li class="more-info"><a href="http://rubyonrails.org/screencasts">Screencasts</a></li>
32
- <li class="more-info"><a href="http://rubyonrails.org/documentation">Documentation</a></li>
33
- <li class="more-info"><a href="http://rubyonrails.org/community">Community</a></li>
34
- <li class="more-info"><a href="http://weblog.rubyonrails.org/">Blog</a></li>
35
- </ul>
36
- </div>
37
- </div>
38
- <div id="header">
39
- <div class="wrapper clearfix">
40
- <h1><a href="index.html" title="Return to home page">Guides.rubyonrails.org</a></h1>
41
- <ul class="nav">
42
- <li><a class="nav-item" href="index.html">Home</a></li>
43
- <li class="guides-index guides-index-large">
44
- <a href="index.html" id="guidesMenu" class="guides-index-item nav-item">Guides Index</a>
45
- <div id="guides" class="clearfix" style="display: none;">
46
- <hr />
47
- <dl class="L">
48
- <dt>Start Here</dt>
49
- <dd><a href="getting_started.html">Getting Started with Rails</a></dd>
50
- <dt>Models</dt>
51
- <dd><a href="active_record_basics.html">Active Record Basics</a></dd>
52
- <dd><a href="active_record_migrations.html">Active Record Migrations</a></dd>
53
- <dd><a href="active_record_validations.html">Active Record Validations</a></dd>
54
- <dd><a href="active_record_callbacks.html">Active Record Callbacks</a></dd>
55
- <dd><a href="association_basics.html">Active Record Associations</a></dd>
56
- <dd><a href="active_record_querying.html">Active Record Query Interface</a></dd>
57
- <dt>Views</dt>
58
- <dd><a href="layouts_and_rendering.html">Layouts and Rendering in Rails</a></dd>
59
- <dd><a href="form_helpers.html">Action View Form Helpers</a></dd>
60
- <dt>Controllers</dt>
61
- <dd><a href="action_controller_overview.html">Action Controller Overview</a></dd>
62
- <dd><a href="routing.html">Rails Routing from the Outside In</a></dd>
63
- </dl>
64
- <dl class="R">
65
- <dt>Digging Deeper</dt>
66
- <dd><a href="active_support_core_extensions.html">Active Support Core Extensions</a></dd>
67
- <dd><a href="i18n.html">Rails Internationalization API</a></dd>
68
- <dd><a href="action_mailer_basics.html">Action Mailer Basics</a></dd>
69
- <dd><a href="active_job_basics.html">Active Job Basics</a></dd>
70
- <dd><a href="security.html">Securing Rails Applications</a></dd>
71
- <dd><a href="debugging_rails_applications.html">Debugging Rails Applications</a></dd>
72
- <dd><a href="configuring.html">Configuring Rails Applications</a></dd>
73
- <dd><a href="command_line.html">Rails Command Line Tools and Rake Tasks</a></dd>
74
- <dd><a href="asset_pipeline.html">Asset Pipeline</a></dd>
75
- <dd><a href="working_with_javascript_in_rails.html">Working with JavaScript in Rails</a></dd>
76
- <dt>Extending Rails</dt>
77
- <dd><a href="rails_on_rack.html">Rails on Rack</a></dd>
78
- <dd><a href="generators.html">Creating and Customizing Rails Generators</a></dd>
79
- <dt>Contributing to Ruby on Rails</dt>
80
- <dd><a href="contributing_to_ruby_on_rails.html">Contributing to Ruby on Rails</a></dd>
81
- <dd><a href="api_documentation_guidelines.html">API Documentation Guidelines</a></dd>
82
- <dd><a href="ruby_on_rails_guides_guidelines.html">Ruby on Rails Guides Guidelines</a></dd>
83
- <dt>Maintenance Policy</dt>
84
- <dd><a href="maintenance_policy.html">Maintenance Policy</a></dd>
85
- <dt>Release Notes</dt>
86
- <dd><a href="upgrading_ruby_on_rails.html">Upgrading Ruby on Rails</a></dd>
87
- <dd><a href="4_1_release_notes.html">Ruby on Rails 4.1 Release Notes</a></dd>
88
- <dd><a href="4_0_release_notes.html">Ruby on Rails 4.0 Release Notes</a></dd>
89
- <dd><a href="3_2_release_notes.html">Ruby on Rails 3.2 Release Notes</a></dd>
90
- <dd><a href="3_1_release_notes.html">Ruby on Rails 3.1 Release Notes</a></dd>
91
- <dd><a href="3_0_release_notes.html">Ruby on Rails 3.0 Release Notes</a></dd>
92
- <dd><a href="2_3_release_notes.html">Ruby on Rails 2.3 Release Notes</a></dd>
93
- <dd><a href="2_2_release_notes.html">Ruby on Rails 2.2 Release Notes</a></dd>
94
- </dl>
95
- </div>
96
- </li>
97
- <li><a class="nav-item" href="contributing_to_ruby_on_rails.html">Contribute</a></li>
98
- <li><a class="nav-item" href="credits.html">Credits</a></li>
99
- <li class="guides-index guides-index-small">
100
- <select class="guides-index-item nav-item">
101
- <option value="index.html">Guides Index</option>
102
- <optgroup label="Start Here">
103
- <option value="getting_started.html">Getting Started with Rails</option>
104
- </optgroup>
105
- <optgroup label="Models">
106
- <option value="active_record_basics.html">Active Record Basics</option>
107
- <option value="active_record_migrations.html">Active Record Migrations</option>
108
- <option value="active_record_validations.html">Active Record Validations</option>
109
- <option value="active_record_callbacks.html">Active Record Callbacks</option>
110
- <option value="association_basics.html">Active Record Associations</option>
111
- <option value="active_record_querying.html">Active Record Query Interface</option>
112
- </optgroup>
113
- <optgroup label="Views">
114
- <option value="layouts_and_rendering.html">Layouts and Rendering in Rails</option>
115
- <option value="form_helpers.html">Action View Form Helpers</option>
116
- </optgroup>
117
- <optgroup label="Controllers">
118
- <option value="action_controller_overview.html">Action Controller Overview</option>
119
- <option value="routing.html">Rails Routing from the Outside In</option>
120
- </optgroup>
121
- <optgroup label="Digging Deeper">
122
- <option value="active_support_core_extensions.html">Active Support Core Extensions</option>
123
- <option value="i18n.html">Rails Internationalization API</option>
124
- <option value="action_mailer_basics.html">Action Mailer Basics</option>
125
- <option value="active_job_basics.html">Active Job Basics</option>
126
- <option value="security.html">Securing Rails Applications</option>
127
- <option value="debugging_rails_applications.html">Debugging Rails Applications</option>
128
- <option value="configuring.html">Configuring Rails Applications</option>
129
- <option value="command_line.html">Rails Command Line Tools and Rake Tasks</option>
130
- <option value="asset_pipeline.html">Asset Pipeline</option>
131
- <option value="working_with_javascript_in_rails.html">Working with JavaScript in Rails</option>
132
- </optgroup>
133
- <optgroup label="Extending Rails">
134
- <option value="rails_on_rack.html">Rails on Rack</option>
135
- <option value="generators.html">Creating and Customizing Rails Generators</option>
136
- </optgroup>
137
- <optgroup label="Contributing to Ruby on Rails">
138
- <option value="contributing_to_ruby_on_rails.html">Contributing to Ruby on Rails</option>
139
- <option value="api_documentation_guidelines.html">API Documentation Guidelines</option>
140
- <option value="ruby_on_rails_guides_guidelines.html">Ruby on Rails Guides Guidelines</option>
141
- </optgroup>
142
- <optgroup label="Maintenance Policy">
143
- <option value="maintenance_policy.html">Maintenance Policy</option>
144
- </optgroup>
145
- <optgroup label="Release Notes">
146
- <option value="upgrading_ruby_on_rails.html">Upgrading Ruby on Rails</option>
147
- <option value="4_1_release_notes.html">Ruby on Rails 4.1 Release Notes</option>
148
- <option value="4_0_release_notes.html">Ruby on Rails 4.0 Release Notes</option>
149
- <option value="3_2_release_notes.html">Ruby on Rails 3.2 Release Notes</option>
150
- <option value="3_1_release_notes.html">Ruby on Rails 3.1 Release Notes</option>
151
- <option value="3_0_release_notes.html">Ruby on Rails 3.0 Release Notes</option>
152
- <option value="2_3_release_notes.html">Ruby on Rails 2.3 Release Notes</option>
153
- <option value="2_2_release_notes.html">Ruby on Rails 2.2 Release Notes</option>
154
- </optgroup>
155
- </select>
156
- </li>
157
- </ul>
158
- </div>
159
- </div>
160
- <hr class="hide" />
161
-
162
- <div id="feature">
163
- <div class="wrapper">
164
- <h2>Rails Internationalization (I18n) API</h2><p>The Ruby I18n (shorthand for <em>internationalization</em>) gem which is shipped with Ruby on Rails (starting from Rails 2.2) provides an easy-to-use and extensible framework for <strong>translating your application to a single custom language</strong> other than English or for <strong>providing multi-language support</strong> in your application.</p><p>The process of &quot;internationalization&quot; usually means to abstract all strings and other locale specific bits (such as date or currency formats) out of your application. The process of &quot;localization&quot; means to provide translations and localized formats for these bits.<sup class="footnote" id="footnote-1-ref"><a href="#footnote-1">1</a></sup></p><p>So, in the process of <em>internationalizing</em> your Rails application you have to:</p>
165
- <ul>
166
- <li>Ensure you have support for i18n.</li>
167
- <li>Tell Rails where to find locale dictionaries.</li>
168
- <li>Tell Rails how to set, preserve and switch locales.</li>
169
- </ul>
170
- <p>In the process of <em>localizing</em> your application you&#39;ll probably want to do the following three things:</p>
171
- <ul>
172
- <li>Replace or supplement Rails&#39; default locale - e.g. date and time formats, month names, Active Record model names, etc.</li>
173
- <li>Abstract strings in your application into keyed dictionaries - e.g. flash messages, static text in your views, etc.</li>
174
- <li>Store the resulting dictionaries somewhere.</li>
175
- </ul>
176
- <p>This guide will walk you through the I18n API and contains a tutorial on how to internationalize a Rails application from the start.</p><p>After reading this guide, you will know:</p>
177
- <ul>
178
- <li>How I18n works in Ruby on Rails</li>
179
- <li>How to correctly use I18n into a RESTful application in various ways</li>
180
- <li>How to use I18n to translate ActiveRecord errors or ActionMailer E-mail subjects</li>
181
- <li>Some other tools to go further with the translation process of your application</li>
182
- </ul>
183
-
184
-
185
- <div id="subCol">
186
- <h3 class="chapter"><img src="images/chapters_icon.gif" alt="" />Chapters</h3>
187
- <ol class="chapters">
188
- <li>
189
- <a href="#how-i18n-in-ruby-on-rails-works">How I18n in Ruby on Rails Works</a>
190
-
191
- <ul>
192
- <li><a href="#the-overall-architecture-of-the-library">The Overall Architecture of the Library</a></li>
193
- <li><a href="#the-public-i18n-api">The Public I18n API</a></li>
194
- </ul>
195
- </li>
196
- <li>
197
- <a href="#setup-the-rails-application-for-internationalization">Setup the Rails Application for Internationalization</a>
198
-
199
- <ul>
200
- <li><a href="#configure-the-i18n-module">Configure the I18n Module</a></li>
201
- <li><a href="#optional:-custom-i18n-configuration-setup">Optional: Custom I18n Configuration Setup</a></li>
202
- <li><a href="#setting-and-passing-the-locale">Setting and Passing the Locale</a></li>
203
- <li><a href="#setting-the-locale-from-the-domain-name">Setting the Locale from the Domain Name</a></li>
204
- <li><a href="#setting-the-locale-from-the-url-params">Setting the Locale from the URL Params</a></li>
205
- <li><a href="#setting-the-locale-from-the-client-supplied-information">Setting the Locale from the Client Supplied Information</a></li>
206
- </ul>
207
- </li>
208
- <li>
209
- <a href="#internationalizing-your-application">Internationalizing your Application</a>
210
-
211
- <ul>
212
- <li><a href="#adding-translations">Adding Translations</a></li>
213
- <li><a href="#passing-variables-to-translations">Passing variables to translations</a></li>
214
- <li><a href="#adding-date/time-formats">Adding Date/Time Formats</a></li>
215
- <li><a href="#inflection-rules-for-other-locales">Inflection Rules For Other Locales</a></li>
216
- <li><a href="#localized-views">Localized Views</a></li>
217
- <li><a href="#organization-of-locale-files">Organization of Locale Files</a></li>
218
- </ul>
219
- </li>
220
- <li>
221
- <a href="#overview-of-the-i18n-api-features">Overview of the I18n API Features</a>
222
-
223
- <ul>
224
- <li><a href="#looking-up-translations">Looking up Translations</a></li>
225
- <li><a href="#interpolation">Interpolation</a></li>
226
- <li><a href="#pluralization">Pluralization</a></li>
227
- <li><a href="#setting-and-passing-a-locale">Setting and Passing a Locale</a></li>
228
- <li><a href="#using-safe-html-translations">Using Safe HTML Translations</a></li>
229
- <li><a href="#translations-for-active-record-models">Translations for Active Record Models</a></li>
230
- <li><a href="#translations-for-action-mailer-e-mail-subjects">Translations for Action Mailer E-Mail Subjects</a></li>
231
- <li><a href="#overview-of-other-built-in-methods-that-provide-i18n-support">Overview of Other Built-In Methods that Provide I18n Support</a></li>
232
- </ul>
233
- </li>
234
- <li><a href="#how-to-store-your-custom-translations">How to Store your Custom Translations</a></li>
235
- <li>
236
- <a href="#customize-your-i18n-setup">Customize your I18n Setup</a>
237
-
238
- <ul>
239
- <li><a href="#using-different-backends">Using Different Backends</a></li>
240
- <li><a href="#using-different-exception-handlers">Using Different Exception Handlers</a></li>
241
- </ul>
242
- </li>
243
- <li><a href="#conclusion">Conclusion</a></li>
244
- <li><a href="#contributing-to-rails-i18n">Contributing to Rails I18n</a></li>
245
- <li><a href="#resources">Resources</a></li>
246
- <li><a href="#authors">Authors</a></li>
247
- <li><a href="#footnotes">Footnotes</a></li>
248
- </ol>
249
-
250
- </div>
251
-
252
- </div>
253
- </div>
254
-
255
- <div id="container">
256
- <div class="wrapper">
257
- <div id="mainCol">
258
- <div class="note"><p>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 Ruby <a href="http://ruby-i18n.org/wiki">I18n Wiki</a> for more information.</p></div><h3 id="how-i18n-in-ruby-on-rails-works">1 How I18n in Ruby on Rails Works</h3><p>Internationalization is a complex problem. Natural languages differ in so many ways (e.g. in pluralization rules) that it is hard to provide tools for solving all problems at once. For that reason the Rails I18n API focuses on:</p>
259
- <ul>
260
- <li>providing support for English and similar languages out of the box</li>
261
- <li>making it easy to customize and extend everything for other languages</li>
262
- </ul>
263
- <p>As part of this solution, <strong>every static string in the Rails framework</strong> - e.g. Active Record validation messages, time and date formats - <strong>has been internationalized</strong>, so <em>localization</em> of a Rails application means "over-riding" these defaults.</p><h4 id="the-overall-architecture-of-the-library">1.1 The Overall Architecture of the Library</h4><p>Thus, the Ruby I18n gem is split into two parts:</p>
264
- <ul>
265
- <li>The public API of the i18n framework - a Ruby module with public methods that define how the library works</li>
266
- <li>A default backend (which is intentionally named <em>Simple</em> backend) that implements these methods</li>
267
- </ul>
268
- <p>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.</p><div class="note"><p>It is possible (or even desirable) to swap the shipped Simple backend with a more powerful one, which would store translation data in a relational database, GetText dictionary, or similar. See section <a href="#using-different-backends">Using different backends</a> below.</p></div><h4 id="the-public-i18n-api">1.2 The Public I18n API</h4><p>The most important methods of the I18n API are:</p><div class="code_container">
269
- <pre class="brush: ruby; gutter: false; toolbar: false">
270
- translate # Lookup text translations
271
- localize # Localize Date and Time objects to local formats
272
-
273
- </pre>
274
- </div>
275
- <p>These have the aliases #t and #l so you can use them like this:</p><div class="code_container">
276
- <pre class="brush: ruby; gutter: false; toolbar: false">
277
- I18n.t 'store.title'
278
- I18n.l Time.now
279
-
280
- </pre>
281
- </div>
282
- <p>There are also attribute readers and writers for the following attributes:</p><div class="code_container">
283
- <pre class="brush: ruby; gutter: false; toolbar: false">
284
- load_path # Announce your custom translation files
285
- locale # Get and set the current locale
286
- default_locale # Get and set the default locale
287
- exception_handler # Use a different exception_handler
288
- backend # Use a different backend
289
-
290
- </pre>
291
- </div>
292
- <p>So, let's internationalize a simple Rails application from the ground up in the next chapters!</p><h3 id="setup-the-rails-application-for-internationalization">2 Setup the Rails Application for Internationalization</h3><p>There are just a few simple steps to get up and running with I18n support for your application.</p><h4 id="configure-the-i18n-module">2.1 Configure the I18n Module</h4><p>Following the <em>convention over configuration</em> philosophy, Rails will set up your application with reasonable defaults. If you need different settings, you can overwrite them easily.</p><p>Rails adds all <code>.rb</code> and <code>.yml</code> files from the <code>config/locales</code> directory to your <strong>translations load path</strong>, automatically.</p><p>The default <code>en.yml</code> locale in this directory contains a sample pair of translation strings:</p><div class="code_container">
293
- <pre class="brush: plain; gutter: false; toolbar: false">
294
- en:
295
- hello: "Hello world"
296
-
297
- </pre>
298
- </div>
299
- <p>This means, that in the <code>:en</code> locale, the key <em>hello</em> will map to the <em>Hello world</em> string. Every string inside Rails is internationalized in this way, see for instance Active Model validation messages in the <a href="https://github.com/rails/rails/blob/master/activemodel/lib/active_model/locale/en.yml"><code>activemodel/lib/active_model/locale/en.yml</code></a> file or time and date formats in the <a href="https://github.com/rails/rails/blob/master/activesupport/lib/active_support/locale/en.yml"><code>activesupport/lib/active_support/locale/en.yml</code></a> file. You can use YAML or standard Ruby Hashes to store translations in the default (Simple) backend.</p><p>The I18n library will use <strong>English</strong> as a <strong>default locale</strong>, i.e. if you don't set a different locale, <code>:en</code> will be used for looking up translations.</p><div class="note"><p>The i18n library takes a <strong>pragmatic approach</strong> to locale keys (after <a href="http://groups.google.com/group/rails-i18n/browse_thread/thread/14dede2c7dbe9470/80eec34395f64f3c?hl=en">some discussion</a>), including only the <em>locale</em> ("language") part, like <code>:en</code>, <code>:pl</code>, not the <em>region</em> part, like <code>:en-US</code> or <code>:en-GB</code>, 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 <code>:cs</code>, <code>:th</code> or <code>:es</code> (for Czech, Thai and Spanish). However, there are also regional differences within different language groups that may be important. For instance, in the <code>:en-US</code> locale you would have $ as a currency symbol, while in <code>:en-GB</code>, 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 <code>:en-GB</code> dictionary. Various <a href="http://rails-i18n.org/wiki">Rails I18n plugins</a> such as <a href="https://github.com/globalize/globalize">Globalize3</a> may help you implement it.</p></div><p>The <strong>translations load path</strong> (<code>I18n.load_path</code>) 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.</p><div class="note"><p>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.</p></div><p>The default <code>application.rb</code> 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.</p><div class="code_container">
300
- <pre class="brush: ruby; gutter: false; toolbar: false">
301
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
302
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
303
- # config.i18n.default_locale = :de
304
-
305
- </pre>
306
- </div>
307
- <h4 id="optional:-custom-i18n-configuration-setup">2.2 Optional: Custom I18n Configuration Setup</h4><p>For the sake of completeness, let's mention that if you do not want to use the <code>application.rb</code> file for some reason, you can always wire up things manually, too.</p><p>To tell the I18n library where it can find your custom translation files you can specify the load path anywhere in your application - just make sure it gets run before any translations are actually looked up. You might also want to change the default locale. The simplest thing possible is to put the following into an initializer:</p><div class="code_container">
308
- <pre class="brush: ruby; gutter: false; toolbar: false">
309
- # in config/initializers/locale.rb
310
-
311
- # tell the I18n library where to find your translations
312
- I18n.load_path += Dir[Rails.root.join('lib', 'locale', '*.{rb,yml}')]
313
-
314
- # set default locale to something other than :en
315
- I18n.default_locale = :pt
316
-
317
- </pre>
318
- </div>
319
- <h4 id="setting-and-passing-the-locale">2.3 Setting and Passing the Locale</h4><p>If you want to translate your Rails application to a <strong>single language other than English</strong> (the default locale), you can set I18n.default_locale to your locale in <code>application.rb</code> or an initializer as shown above, and it will persist through the requests.</p><p>However, you would probably like to <strong>provide support for more locales</strong> in your application. In such case, you need to set and pass the locale between requests.</p><div class="warning"><p>You may be tempted to store the chosen locale in a <em>session</em> or a <em>cookie</em>. However, <strong>do not do this</strong>. 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 <a href="http://en.wikipedia.org/wiki/Representational_State_Transfer"><em>RESTful</em></a>. Read more about the RESTful approach in <a href="http://www.infoq.com/articles/rest-introduction">Stefan Tilkov's articles</a>. Sometimes there are exceptions to this rule and those are discussed below.</p></div><p>The <em>setting part</em> is easy. You can set the locale in a <code>before_action</code> in the <code>ApplicationController</code> like this:</p><div class="code_container">
320
- <pre class="brush: ruby; gutter: false; toolbar: false">
321
- before_action :set_locale
322
-
323
- def set_locale
324
- I18n.locale = params[:locale] || I18n.default_locale
325
- end
326
-
327
- </pre>
328
- </div>
329
- <p>This requires you to pass the locale as a URL query parameter as in <code>http://example.com/books?locale=pt</code>. (This is, for example, Google's approach.) So <code>http://localhost:3000?locale=pt</code> will load the Portuguese localization, whereas <code>http://localhost:3000?locale=de</code> would load the German localization, and so on. You may skip the next section and head over to the <strong>Internationalize your application</strong> section, if you want to try things out by manually placing the locale in the URL and reloading the page.</p><p>Of course, you probably don't want to manually include the locale in every URL all over your application, or want the URLs look differently, e.g. the usual <code>http://example.com/pt/books</code> versus <code>http://example.com/en/books</code>. Let's discuss the different options you have.</p><h4 id="setting-the-locale-from-the-domain-name">2.4 Setting the Locale from the Domain Name</h4><p>One option you have is to set the locale from the domain name where your application runs. For example, we want <code>www.example.com</code> to load the English (or default) locale, and <code>www.example.es</code> to load the Spanish locale. Thus the <em>top-level domain name</em> is used for locale setting. This has several advantages:</p>
330
- <ul>
331
- <li>The locale is an <em>obvious</em> part of the URL.</li>
332
- <li>People intuitively grasp in which language the content will be displayed.</li>
333
- <li>It is very trivial to implement in Rails.</li>
334
- <li>Search engines seem to like that content in different languages lives at different, inter-linked domains.</li>
335
- </ul>
336
- <p>You can implement it like this in your <code>ApplicationController</code>:</p><div class="code_container">
337
- <pre class="brush: ruby; gutter: false; toolbar: false">
338
- before_action :set_locale
339
-
340
- def set_locale
341
- I18n.locale = extract_locale_from_tld || I18n.default_locale
342
- end
343
-
344
- # Get locale from top-level domain or return nil if such locale is not available
345
- # You have to put something like:
346
- # 127.0.0.1 application.com
347
- # 127.0.0.1 application.it
348
- # 127.0.0.1 application.pl
349
- # in your /etc/hosts file to try this out locally
350
- def extract_locale_from_tld
351
- parsed_locale = request.host.split('.').last
352
- I18n.available_locales.map(&amp;:to_s).include?(parsed_locale) ? parsed_locale : nil
353
- end
354
-
355
- </pre>
356
- </div>
357
- <p>We can also set the locale from the <em>subdomain</em> in a very similar way:</p><div class="code_container">
358
- <pre class="brush: ruby; gutter: false; toolbar: false">
359
- # Get locale code from request subdomain (like http://it.application.local:3000)
360
- # You have to put something like:
361
- # 127.0.0.1 gr.application.local
362
- # in your /etc/hosts file to try this out locally
363
- def extract_locale_from_subdomain
364
- parsed_locale = request.subdomains.first
365
- I18n.available_locales.map(&amp;:to_s).include?(parsed_locale) ? parsed_locale : nil
366
- end
367
-
368
- </pre>
369
- </div>
370
- <p>If your application includes a locale switching menu, you would then have something like this in it:</p><div class="code_container">
371
- <pre class="brush: ruby; gutter: false; toolbar: false">
372
- link_to("Deutsch", "#{APP_CONFIG[:deutsch_website_url]}#{request.env['REQUEST_URI']}")
373
-
374
- </pre>
375
- </div>
376
- <p>assuming you would set <code>APP_CONFIG[:deutsch_website_url]</code> to some value like <code>http://www.application.de</code>.</p><p>This solution has aforementioned advantages, however, you may not be able or may not want to provide different localizations ("language versions") on different domains. The most obvious solution would be to include locale code in the URL params (or request path).</p><h4 id="setting-the-locale-from-the-url-params">2.5 Setting the Locale from the URL Params</h4><p>The most usual way of setting (and passing) the locale would be to include it in URL params, as we did in the <code>I18n.locale = params[:locale]</code> <em>before_action</em> in the first example. We would like to have URLs like <code>www.example.com/books?locale=ja</code> or <code>www.example.com/ja/books</code> in this case.</p><p>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.</p><p>Getting the locale from <code>params</code> and setting it accordingly is not hard; including it in every URL and thus <strong>passing it through the requests</strong> is. To include an explicit option in every URL, e.g. <code>link_to(books_url(locale: I18n.locale))</code>, would be tedious and probably impossible, of course.</p><p>Rails contains infrastructure for "centralizing dynamic decisions about the URLs" in its <a href="http://api.rubyonrails.org/classes/ActionDispatch/Routing/Mapper/Base.html#method-i-default_url_options"><code>ApplicationController#default_url_options</code></a>, which is useful precisely in this scenario: it enables us to set "defaults" for <a href="http://api.rubyonrails.org/classes/ActionDispatch/Routing/UrlFor.html#method-i-url_for"><code>url_for</code></a> and helper methods dependent on it (by implementing/overriding this method).</p><p>We can include something like this in our <code>ApplicationController</code> then:</p><div class="code_container">
377
- <pre class="brush: ruby; gutter: false; toolbar: false">
378
- # app/controllers/application_controller.rb
379
- def default_url_options(options = {})
380
- { locale: I18n.locale }.merge options
381
- end
382
-
383
- </pre>
384
- </div>
385
- <p>Every helper method dependent on <code>url_for</code> (e.g. helpers for named routes like <code>root_path</code> or <code>root_url</code>, resource routes like <code>books_path</code> or <code>books_url</code>, etc.) will now <strong>automatically include the locale in the query string</strong>, like this: <code>http://localhost:3001/?locale=ja</code>.</p><p>You may be satisfied with this. It does impact the readability of URLs, though, when the locale "hangs" at the end of every URL in your application. Moreover, from the architectural standpoint, locale is usually hierarchically above the other parts of the application domain: and URLs should reflect this.</p><p>You probably want URLs to look like this: <code>www.example.com/en/books</code> (which loads the English locale) and <code>www.example.com/nl/books</code> (which loads the Dutch locale). This is achievable with the "over-riding <code>default_url_options</code>" strategy from above: you just have to set up your routes with <a href="http://api.rubyonrails.org/classes/ActionDispatch/Routing/Mapper/Scoping.html"><code>scoping</code></a> option in this way:</p><div class="code_container">
386
- <pre class="brush: ruby; gutter: false; toolbar: false">
387
- # config/routes.rb
388
- scope "/:locale" do
389
- resources :books
390
- end
391
-
392
- </pre>
393
- </div>
394
- <p>Now, when you call the <code>books_path</code> method you should get <code>"/en/books"</code> (for the default locale). An URL like <code>http://localhost:3001/nl/books</code> should load the Dutch locale, then, and following calls to <code>books_path</code> should return <code>"/nl/books"</code> (because the locale changed).</p><p>If you don't want to force the use of a locale in your routes you can use an optional path scope (denoted by the parentheses) like so:</p><div class="code_container">
395
- <pre class="brush: ruby; gutter: false; toolbar: false">
396
- # config/routes.rb
397
- scope "(:locale)", locale: /en|nl/ do
398
- resources :books
399
- end
400
-
401
- </pre>
402
- </div>
403
- <p>With this approach you will not get a <code>Routing Error</code> when accessing your resources such as <code>http://localhost:3001/books</code> without a locale. This is useful for when you want to use the default locale when one is not specified.</p><p>Of course, you need to take special care of the root URL (usually "homepage" or "dashboard") of your application. An URL like <code>http://localhost:3001/nl</code> will not work automatically, because the <code>root to: "books#index"</code> declaration in your <code>routes.rb</code> doesn't take locale into account. (And rightly so: there's only one "root" URL.)</p><p>You would probably need to map URLs like these:</p><div class="code_container">
404
- <pre class="brush: ruby; gutter: false; toolbar: false">
405
- # config/routes.rb
406
- get '/:locale' =&gt; 'dashboard#index'
407
-
408
- </pre>
409
- </div>
410
- <p>Do take special care about the <strong>order of your routes</strong>, so this route declaration does not "eat" other ones. (You may want to add it directly before the <code>root :to</code> declaration.)</p><div class="note"><p>Have a look at two plugins which simplify working with routes in this way: Sven Fuchs's <a href="https://github.com/svenfuchs/routing-filter/tree/master">routing_filter</a> and Raul Murciano's <a href="https://github.com/raul/translate_routes/tree/master">translate_routes</a>.</p></div><h4 id="setting-the-locale-from-the-client-supplied-information">2.6 Setting the Locale from the Client Supplied Information</h4><p>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 <em>sessions</em>, <em>cookies</em> and RESTful architecture above.</p><h5 id="using-accept-language">2.6.1 Using <code>Accept-Language</code>
411
- </h5><p>One source of client supplied information would be an <code>Accept-Language</code> HTTP header. People may <a href="http://www.w3.org/International/questions/qa-lang-priorities">set this in their browser</a> or other clients (such as <em>curl</em>).</p><p>A trivial implementation of using an <code>Accept-Language</code> header would be:</p><div class="code_container">
412
- <pre class="brush: ruby; gutter: false; toolbar: false">
413
- def set_locale
414
- logger.debug "* Accept-Language: #{request.env['HTTP_ACCEPT_LANGUAGE']}"
415
- I18n.locale = extract_locale_from_accept_language_header
416
- logger.debug "* Locale set to '#{I18n.locale}'"
417
- end
418
-
419
- private
420
- def extract_locale_from_accept_language_header
421
- request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first
422
- end
423
-
424
- </pre>
425
- </div>
426
- <p>Of course, in a production environment you would need much more robust code, and could use a plugin such as Iain Hecker's <a href="https://github.com/iain/http_accept_language/tree/master">http_accept_language</a> or even Rack middleware such as Ryan Tomayko's <a href="https://github.com/rack/rack-contrib/blob/master/lib/rack/contrib/locale.rb">locale</a>.</p><h5 id="using-geoip-(or-similar)-database">2.6.2 Using GeoIP (or Similar) Database</h5><p>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 <a href="http://www.maxmind.com/app/geolitecountry">GeoIP Lite Country</a>. 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.</p><h5 id="user-profile">2.6.3 User Profile</h5><p>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.</p><h3 id="internationalizing-your-application">3 Internationalizing your Application</h3><p>OK! Now you've initialized I18n support for your Ruby on Rails application and told it which locale to use and how to preserve it between requests. With that in place, you're now ready for the really interesting stuff.</p><p>Let's <em>internationalize</em> our application, i.e. abstract every locale-specific parts, and then <em>localize</em> it, i.e. provide necessary translations for these abstracts.</p><p>You most probably have something like this in one of your applications:</p><div class="code_container">
427
- <pre class="brush: ruby; gutter: false; toolbar: false">
428
- # config/routes.rb
429
- Rails.application.routes.draw do
430
- root to: "home#index"
431
- end
432
-
433
- </pre>
434
- </div>
435
- <div class="code_container">
436
- <pre class="brush: ruby; gutter: false; toolbar: false">
437
- # app/controllers/application_controller.rb
438
- class ApplicationController &lt; ActionController::Base
439
- before_action :set_locale
440
-
441
- def set_locale
442
- I18n.locale = params[:locale] || I18n.default_locale
443
- end
444
- end
445
-
446
- </pre>
447
- </div>
448
- <div class="code_container">
449
- <pre class="brush: ruby; gutter: false; toolbar: false">
450
- # app/controllers/home_controller.rb
451
- class HomeController &lt; ApplicationController
452
- def index
453
- flash[:notice] = "Hello Flash"
454
- end
455
- end
456
-
457
- </pre>
458
- </div>
459
- <div class="code_container">
460
- <pre class="brush: plain; gutter: false; toolbar: false">
461
- # app/views/home/index.html.erb
462
- &lt;h1&gt;Hello World&lt;/h1&gt;
463
- &lt;p&gt;&lt;%= flash[:notice] %&gt;&lt;/p&gt;
464
-
465
- </pre>
466
- </div>
467
- <p><img src="images/i18n/demo_untranslated.png" alt="rails i18n demo untranslated"></p><h4 id="adding-translations">3.1 Adding Translations</h4><p>Obviously there are <strong>two strings that are localized to English</strong>. In order to internationalize this code, <strong>replace these strings</strong> with calls to Rails' <code>#t</code> helper with a key that makes sense for the translation:</p><div class="code_container">
468
- <pre class="brush: ruby; gutter: false; toolbar: false">
469
- # app/controllers/home_controller.rb
470
- class HomeController &lt; ApplicationController
471
- def index
472
- flash[:notice] = t(:hello_flash)
473
- end
474
- end
475
-
476
- </pre>
477
- </div>
478
- <div class="code_container">
479
- <pre class="brush: plain; gutter: false; toolbar: false">
480
- # app/views/home/index.html.erb
481
- &lt;h1&gt;&lt;%=t :hello_world %&gt;&lt;/h1&gt;
482
- &lt;p&gt;&lt;%= flash[:notice] %&gt;&lt;/p&gt;
483
-
484
- </pre>
485
- </div>
486
- <p>When you now render this view, it will show an error message which tells you that the translations for the keys <code>:hello_world</code> and <code>:hello_flash</code> are missing.</p><p><img src="images/i18n/demo_translation_missing.png" alt="rails i18n demo translation missing"></p><div class="note"><p>Rails adds a <code>t</code> (<code>translate</code>) helper method to your views so that you do not need to spell out <code>I18n.t</code> all the time. Additionally this helper will catch missing translations and wrap the resulting error message into a <code>&lt;span class="translation_missing"&gt;</code>.</p></div><p>So let's add the missing translations into the dictionary files (i.e. do the "localization" part):</p><div class="code_container">
487
- <pre class="brush: plain; gutter: false; toolbar: false">
488
- # config/locales/en.yml
489
- en:
490
- hello_world: Hello world!
491
- hello_flash: Hello flash!
492
-
493
- # config/locales/pirate.yml
494
- pirate:
495
- hello_world: Ahoy World
496
- hello_flash: Ahoy Flash
497
-
498
- </pre>
499
- </div>
500
- <p>There you go. Because you haven't changed the default_locale, I18n will use English. Your application now shows:</p><p><img src="images/i18n/demo_translated_en.png" alt="rails i18n demo translated to English"></p><p>And when you change the URL to pass the pirate locale (<code>http://localhost:3000?locale=pirate</code>), you'll get:</p><p><img src="images/i18n/demo_translated_pirate.png" alt="rails i18n demo translated to pirate"></p><div class="note"><p>You need to restart the server when you add new locale files.</p></div><p>You may use YAML (<code>.yml</code>) or plain Ruby (<code>.rb</code>) files for storing your translations in SimpleStore. YAML is the preferred option among Rails developers. However, it has one big disadvantage. YAML is very sensitive to whitespace and special characters, so the application may not load your dictionary properly. Ruby files will crash your application on first request, so you may easily find what's wrong. (If you encounter any "weird issues" with YAML dictionaries, try putting the relevant portion of your dictionary into a Ruby file.)</p><h4 id="passing-variables-to-translations">3.2 Passing variables to translations</h4><p>You can use variables in the translation messages and pass their values from the view.</p><div class="code_container">
501
- <pre class="brush: ruby; html-script: true; gutter: false; toolbar: false">
502
- # app/views/home/index.html.erb
503
- &lt;%=t 'greet_username', user: "Bill", message: "Goodbye" %&gt;
504
-
505
- </pre>
506
- </div>
507
- <div class="code_container">
508
- <pre class="brush: plain; gutter: false; toolbar: false">
509
- # config/locales/en.yml
510
- en:
511
- greet_username: "%{message}, %{user}!"
512
-
513
- </pre>
514
- </div>
515
- <h4 id="adding-date/time-formats">3.3 Adding Date/Time Formats</h4><p>OK! Now let's add a timestamp to the view, so we can demo the <strong>date/time localization</strong> feature as well. To localize the time format you pass the Time object to <code>I18n.l</code> or (preferably) use Rails' <code>#l</code> helper. You can pick a format by passing the <code>:format</code> option - by default the <code>:default</code> format is used.</p><div class="code_container">
516
- <pre class="brush: ruby; html-script: true; gutter: false; toolbar: false">
517
- # app/views/home/index.html.erb
518
- &lt;h1&gt;&lt;%=t :hello_world %&gt;&lt;/h1&gt;
519
- &lt;p&gt;&lt;%= flash[:notice] %&gt;&lt;/p
520
- &lt;p&gt;&lt;%= l Time.now, format: :short %&gt;&lt;/p&gt;
521
-
522
- </pre>
523
- </div>
524
- <p>And in our pirate translations file let's add a time format (it's already there in Rails' defaults for English):</p><div class="code_container">
525
- <pre class="brush: plain; gutter: false; toolbar: false">
526
- # config/locales/pirate.yml
527
- pirate:
528
- time:
529
- formats:
530
- short: "arrrround %H'ish"
531
-
532
- </pre>
533
- </div>
534
- <p>So that would give you:</p><p><img src="images/i18n/demo_localized_pirate.png" alt="rails i18n demo localized time to pirate"></p><div class="info"><p>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 <strong>translating Rails' defaults for your locale</strong>. See the <a href="https://github.com/svenfuchs/rails-i18n/tree/master/rails/locale">rails-i18n repository at GitHub</a> for an archive of various locale files. When you put such file(s) in <code>config/locales/</code> directory, they will automatically be ready for use.</p></div><h4 id="inflection-rules-for-other-locales">3.4 Inflection Rules For Other Locales</h4><p>Rails allows you to define inflection rules (such as rules for singularization and pluralization) for locales other than English. In <code>config/initializers/inflections.rb</code>, 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.</p><h4 id="localized-views">3.5 Localized Views</h4><p>Let's say you have a <em>BooksController</em> in your application. Your <em>index</em> action renders content in <code>app/views/books/index.html.erb</code> template. When you put a <em>localized variant</em> of this template: <code>index.es.html.erb</code> in the same directory, Rails will render content in this template, when the locale is set to <code>:es</code>. When the locale is set to the default locale, the generic <code>index.html.erb</code> view will be used. (Future Rails versions may well bring this <em>automagic</em> localization to assets in <code>public</code>, etc.)</p><p>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.</p><h4 id="organization-of-locale-files">3.6 Organization of Locale Files</h4><p>When you are using the default SimpleStore shipped with the i18n library, dictionaries are stored in plain-text files on the disc. Putting translations for all parts of your application in one file per locale could be hard to manage. You can store these files in a hierarchy which makes sense to you.</p><p>For example, your <code>config/locales</code> directory could look like this:</p><div class="code_container">
535
- <pre class="brush: plain; gutter: false; toolbar: false">
536
- |-defaults
537
- |---es.rb
538
- |---en.rb
539
- |-models
540
- |---book
541
- |-----es.rb
542
- |-----en.rb
543
- |-views
544
- |---defaults
545
- |-----es.rb
546
- |-----en.rb
547
- |---books
548
- |-----es.rb
549
- |-----en.rb
550
- |---users
551
- |-----es.rb
552
- |-----en.rb
553
- |---navigation
554
- |-----es.rb
555
- |-----en.rb
556
-
557
- </pre>
558
- </div>
559
- <p>This way, you can separate model and model attribute names from text inside views, and all of this from the "defaults" (e.g. date and time formats). Other stores for the i18n library could provide different means of such separation.</p><div class="note"><p>The default locale loading mechanism in Rails does not load locale files in nested dictionaries, like we have here. So, for this to work, we must explicitly tell Rails to look further:</p></div><div class="code_container">
560
- <pre class="brush: ruby; gutter: false; toolbar: false">
561
- # config/application.rb
562
- config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]
563
-
564
-
565
- </pre>
566
- </div>
567
- <p>Do check the <a href="http://rails-i18n.org/wiki">Rails i18n Wiki</a> for list of tools available for managing translations.</p><h3 id="overview-of-the-i18n-api-features">4 Overview of the I18n API Features</h3><p>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.</p><p>These chapters will show examples using both the <code>I18n.translate</code> method as well as the <a href="http://api.rubyonrails.org/classes/ActionView/Helpers/TranslationHelper.html#method-i-translate"><code>translate</code> view helper method</a> (noting the additional feature provide by the view helper method).</p><p>Covered are features like these:</p>
568
- <ul>
569
- <li>looking up translations</li>
570
- <li>interpolating data into translations</li>
571
- <li>pluralizing translations</li>
572
- <li>using safe HTML translations (view helper method only)</li>
573
- <li>localizing dates, numbers, currency, etc.</li>
574
- </ul>
575
- <h4 id="looking-up-translations">4.1 Looking up Translations</h4><h5 id="basic-lookup,-scopes-and-nested-keys">4.1.1 Basic Lookup, Scopes and Nested Keys</h5><p>Translations are looked up by keys which can be both Symbols or Strings, so these calls are equivalent:</p><div class="code_container">
576
- <pre class="brush: ruby; gutter: false; toolbar: false">
577
- I18n.t :message
578
- I18n.t 'message'
579
-
580
- </pre>
581
- </div>
582
- <p>The <code>translate</code> method also takes a <code>:scope</code> option which can contain one or more additional keys that will be used to specify a "namespace" or scope for a translation key:</p><div class="code_container">
583
- <pre class="brush: ruby; gutter: false; toolbar: false">
584
- I18n.t :record_invalid, scope: [:activerecord, :errors, :messages]
585
-
586
- </pre>
587
- </div>
588
- <p>This looks up the <code>:record_invalid</code> message in the Active Record error messages.</p><p>Additionally, both the key and scopes can be specified as dot-separated keys as in:</p><div class="code_container">
589
- <pre class="brush: ruby; gutter: false; toolbar: false">
590
- I18n.translate "activerecord.errors.messages.record_invalid"
591
-
592
- </pre>
593
- </div>
594
- <p>Thus the following calls are equivalent:</p><div class="code_container">
595
- <pre class="brush: ruby; gutter: false; toolbar: false">
596
- I18n.t 'activerecord.errors.messages.record_invalid'
597
- I18n.t 'errors.messages.record_invalid', scope: :active_record
598
- I18n.t :record_invalid, scope: 'activerecord.errors.messages'
599
- I18n.t :record_invalid, scope: [:activerecord, :errors, :messages]
600
-
601
- </pre>
602
- </div>
603
- <h5 id="defaults">4.1.2 Defaults</h5><p>When a <code>:default</code> option is given, its value will be returned if the translation is missing:</p><div class="code_container">
604
- <pre class="brush: ruby; gutter: false; toolbar: false">
605
- I18n.t :missing, default: 'Not here'
606
- # =&gt; 'Not here'
607
-
608
- </pre>
609
- </div>
610
- <p>If the <code>:default</code> value is a Symbol, it will be used as a key and translated. One can provide multiple values as default. The first one that results in a value will be returned.</p><p>E.g., the following first tries to translate the key <code>:missing</code> and then the key <code>:also_missing.</code> As both do not yield a result, the string "Not here" will be returned:</p><div class="code_container">
611
- <pre class="brush: ruby; gutter: false; toolbar: false">
612
- I18n.t :missing, default: [:also_missing, 'Not here']
613
- # =&gt; 'Not here'
614
-
615
- </pre>
616
- </div>
617
- <h5 id="bulk-and-namespace-lookup">4.1.3 Bulk and Namespace Lookup</h5><p>To look up multiple translations at once, an array of keys can be passed:</p><div class="code_container">
618
- <pre class="brush: ruby; gutter: false; toolbar: false">
619
- I18n.t [:odd, :even], scope: 'errors.messages'
620
- # =&gt; ["must be odd", "must be even"]
621
-
622
- </pre>
623
- </div>
624
- <p>Also, a key can translate to a (potentially nested) hash of grouped translations. E.g., one can receive <em>all</em> Active Record error messages as a Hash with:</p><div class="code_container">
625
- <pre class="brush: ruby; gutter: false; toolbar: false">
626
- I18n.t 'activerecord.errors.messages'
627
- # =&gt; {:inclusion=&gt;"is not included in the list", :exclusion=&gt; ... }
628
-
629
- </pre>
630
- </div>
631
- <h5 id='"lazy"-lookup'>4.1.4 "Lazy" Lookup</h5><p>Rails implements a convenient way to look up the locale inside <em>views</em>. When you have the following dictionary:</p><div class="code_container">
632
- <pre class="brush: plain; gutter: false; toolbar: false">
633
- es:
634
- books:
635
- index:
636
- title: "Título"
637
-
638
- </pre>
639
- </div>
640
- <p>you can look up the <code>books.index.title</code> value <strong>inside</strong> <code>app/views/books/index.html.erb</code> template like this (note the dot):</p><div class="code_container">
641
- <pre class="brush: ruby; html-script: true; gutter: false; toolbar: false">
642
- &lt;%= t '.title' %&gt;
643
-
644
- </pre>
645
- </div>
646
- <div class="note"><p>Automatic translation scoping by partial is only available from the <code>translate</code> view helper method.</p></div><h4 id="interpolation">4.2 Interpolation</h4><p>In many cases you want to abstract your translations so that <strong>variables can be interpolated into the translation</strong>. For this reason the I18n API provides an interpolation feature.</p><p>All options besides <code>:default</code> and <code>:scope</code> that are passed to <code>#translate</code> will be interpolated to the translation:</p><div class="code_container">
647
- <pre class="brush: ruby; gutter: false; toolbar: false">
648
- I18n.backend.store_translations :en, thanks: 'Thanks %{name}!'
649
- I18n.translate :thanks, name: 'Jeremy'
650
- # =&gt; 'Thanks Jeremy!'
651
-
652
- </pre>
653
- </div>
654
- <p>If a translation uses <code>:default</code> or <code>:scope</code> as an interpolation variable, an <code>I18n::ReservedInterpolationKey</code> exception is raised. If a translation expects an interpolation variable, but this has not been passed to <code>#translate</code>, an <code>I18n::MissingInterpolationArgument</code> exception is raised.</p><h4 id="pluralization">4.3 Pluralization</h4><p>In English there are only one singular and one plural form for a given string, e.g. "1 message" and "2 messages". Other languages (<a href="http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#ar">Arabic</a>, <a href="http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#ja">Japanese</a>, <a href="http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#ru">Russian</a> and many more) have different grammars that have additional or fewer <a href="http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html">plural forms</a>. Thus, the I18n API provides a flexible pluralization feature.</p><p>The <code>:count</code> interpolation variable has a special role in that it both is interpolated to the translation and used to pick a pluralization from the translations according to the pluralization rules defined by CLDR:</p><div class="code_container">
655
- <pre class="brush: ruby; gutter: false; toolbar: false">
656
- I18n.backend.store_translations :en, inbox: {
657
- one: 'one message',
658
- other: '%{count} messages'
659
- }
660
- I18n.translate :inbox, count: 2
661
- # =&gt; '2 messages'
662
-
663
- I18n.translate :inbox, count: 1
664
- # =&gt; 'one message'
665
-
666
- </pre>
667
- </div>
668
- <p>The algorithm for pluralizations in <code>:en</code> is as simple as:</p><div class="code_container">
669
- <pre class="brush: ruby; gutter: false; toolbar: false">
670
- entry[count == 1 ? 0 : 1]
671
-
672
- </pre>
673
- </div>
674
- <p>I.e. the translation denoted as <code>:one</code> is regarded as singular, the other is used as plural (including the count being zero).</p><p>If the lookup for the key does not return a Hash suitable for pluralization, an <code>18n::InvalidPluralizationData</code> exception is raised.</p><h4 id="setting-and-passing-a-locale">4.4 Setting and Passing a Locale</h4><p>The locale can be either set pseudo-globally to <code>I18n.locale</code> (which uses <code>Thread.current</code> like, e.g., <code>Time.zone</code>) or can be passed as an option to <code>#translate</code> and <code>#localize</code>.</p><p>If no locale is passed, <code>I18n.locale</code> is used:</p><div class="code_container">
675
- <pre class="brush: ruby; gutter: false; toolbar: false">
676
- I18n.locale = :de
677
- I18n.t :foo
678
- I18n.l Time.now
679
-
680
- </pre>
681
- </div>
682
- <p>Explicitly passing a locale:</p><div class="code_container">
683
- <pre class="brush: ruby; gutter: false; toolbar: false">
684
- I18n.t :foo, locale: :de
685
- I18n.l Time.now, locale: :de
686
-
687
- </pre>
688
- </div>
689
- <p>The <code>I18n.locale</code> defaults to <code>I18n.default_locale</code> which defaults to :<code>en</code>. The default locale can be set like this:</p><div class="code_container">
690
- <pre class="brush: ruby; gutter: false; toolbar: false">
691
- I18n.default_locale = :de
692
-
693
- </pre>
694
- </div>
695
- <h4 id="using-safe-html-translations">4.5 Using Safe HTML Translations</h4><p>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.</p><div class="code_container">
696
- <pre class="brush: plain; gutter: false; toolbar: false">
697
- # config/locales/en.yml
698
- en:
699
- welcome: &lt;b&gt;welcome!&lt;/b&gt;
700
- hello_html: &lt;b&gt;hello!&lt;/b&gt;
701
- title:
702
- html: &lt;b&gt;title!&lt;/b&gt;
703
-
704
- </pre>
705
- </div>
706
- <div class="code_container">
707
- <pre class="brush: plain; gutter: false; toolbar: false">
708
- # app/views/home/index.html.erb
709
- &lt;div&gt;&lt;%= t('welcome') %&gt;&lt;/div&gt;
710
- &lt;div&gt;&lt;%= raw t('welcome') %&gt;&lt;/div&gt;
711
- &lt;div&gt;&lt;%= t('hello_html') %&gt;&lt;/div&gt;
712
- &lt;div&gt;&lt;%= t('title.html') %&gt;&lt;/div&gt;
713
-
714
- </pre>
715
- </div>
716
- <div class="note"><p>Automatic conversion to HTML safe translate text is only available from the <code>translate</code> view helper method.</p></div><p><img src="images/i18n/demo_html_safe.png" alt="i18n demo html safe"></p><h4 id="translations-for-active-record-models">4.6 Translations for Active Record Models</h4><p>You can use the methods <code>Model.model_name.human</code> and <code>Model.human_attribute_name(attribute)</code> to transparently look up translations for your model and attribute names.</p><p>For example when you add the following translations:</p><div class="code_container">
717
- <pre class="brush: plain; gutter: false; toolbar: false">
718
- en:
719
- activerecord:
720
- models:
721
- user: Dude
722
- attributes:
723
- user:
724
- login: "Handle"
725
- # will translate User attribute "login" as "Handle"
726
-
727
- </pre>
728
- </div>
729
- <p>Then <code>User.model_name.human</code> will return "Dude" and <code>User.human_attribute_name("login")</code> will return "Handle".</p><p>You can also set a plural form for model names, adding as following:</p><div class="code_container">
730
- <pre class="brush: plain; gutter: false; toolbar: false">
731
- en:
732
- activerecord:
733
- models:
734
- user:
735
- one: Dude
736
- other: Dudes
737
-
738
- </pre>
739
- </div>
740
- <p>Then <code>User.model_name.human(count: 2)</code> will return "Dudes". With <code>count: 1</code> or without params will return "Dude".</p><p>In the event you need to access nested attributes within a given model, you should nest these under <code>model/attribute</code> at the model level of your translation file:</p><div class="code_container">
741
- <pre class="brush: plain; gutter: false; toolbar: false">
742
- en:
743
- activerecord:
744
- attributes:
745
- user/gender:
746
- female: "Female"
747
- male: "Male"
748
-
749
- </pre>
750
- </div>
751
- <p>Then <code>User.human_attribute_name("gender.female")</code> will return "Female".</p><h5 id="error-message-scopes">4.6.1 Error Message Scopes</h5><p>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.</p><p>This gives you quite powerful means to flexibly adjust your messages to your application's needs.</p><p>Consider a User model with a validation for the name attribute like this:</p><div class="code_container">
752
- <pre class="brush: ruby; gutter: false; toolbar: false">
753
- class User &lt; ActiveRecord::Base
754
- validates :name, presence: true
755
- end
756
-
757
- </pre>
758
- </div>
759
- <p>The key for the error message in this case is <code>:blank</code>. Active Record will look up this key in the namespaces:</p><div class="code_container">
760
- <pre class="brush: ruby; gutter: false; toolbar: false">
761
- activerecord.errors.models.[model_name].attributes.[attribute_name]
762
- activerecord.errors.models.[model_name]
763
- activerecord.errors.messages
764
- errors.attributes.[attribute_name]
765
- errors.messages
766
-
767
- </pre>
768
- </div>
769
- <p>Thus, in our example it will try the following keys in this order and return the first result:</p><div class="code_container">
770
- <pre class="brush: ruby; gutter: false; toolbar: false">
771
- activerecord.errors.models.user.attributes.name.blank
772
- activerecord.errors.models.user.blank
773
- activerecord.errors.messages.blank
774
- errors.attributes.name.blank
775
- errors.messages.blank
776
-
777
- </pre>
778
- </div>
779
- <p>When your models are additionally using inheritance then the messages are looked up in the inheritance chain.</p><p>For example, you might have an Admin model inheriting from User:</p><div class="code_container">
780
- <pre class="brush: ruby; gutter: false; toolbar: false">
781
- class Admin &lt; User
782
- validates :name, presence: true
783
- end
784
-
785
- </pre>
786
- </div>
787
- <p>Then Active Record will look for messages in this order:</p><div class="code_container">
788
- <pre class="brush: ruby; gutter: false; toolbar: false">
789
- activerecord.errors.models.admin.attributes.name.blank
790
- activerecord.errors.models.admin.blank
791
- activerecord.errors.models.user.attributes.name.blank
792
- activerecord.errors.models.user.blank
793
- activerecord.errors.messages.blank
794
- errors.attributes.name.blank
795
- errors.messages.blank
796
-
797
- </pre>
798
- </div>
799
- <p>This way you can provide special translations for various error messages at different points in your models inheritance chain and in the attributes, models, or default scopes.</p><h5 id="error-message-interpolation">4.6.2 Error Message Interpolation</h5><p>The translated model name, translated attribute name, and value are always available for interpolation.</p><p>So, for example, instead of the default error message <code>"cannot be blank"</code> you could use the attribute name like this : <code>"Please fill in your %{attribute}"</code>.</p>
800
- <ul>
801
- <li>
802
- <code>count</code>, where available, can be used for pluralization if present:</li>
803
- </ul>
804
-
805
- <table>
806
- <thead>
807
- <tr>
808
- <th>validation</th>
809
- <th>with option</th>
810
- <th>message</th>
811
- <th>interpolation</th>
812
- </tr>
813
- </thead>
814
- <tbody>
815
- <tr>
816
- <td>confirmation</td>
817
- <td>-</td>
818
- <td>:confirmation</td>
819
- <td>-</td>
820
- </tr>
821
- <tr>
822
- <td>acceptance</td>
823
- <td>-</td>
824
- <td>:accepted</td>
825
- <td>-</td>
826
- </tr>
827
- <tr>
828
- <td>presence</td>
829
- <td>-</td>
830
- <td>:blank</td>
831
- <td>-</td>
832
- </tr>
833
- <tr>
834
- <td>absence</td>
835
- <td>-</td>
836
- <td>:present</td>
837
- <td>-</td>
838
- </tr>
839
- <tr>
840
- <td>length</td>
841
- <td>:within, :in</td>
842
- <td>:too_short</td>
843
- <td>count</td>
844
- </tr>
845
- <tr>
846
- <td>length</td>
847
- <td>:within, :in</td>
848
- <td>:too_long</td>
849
- <td>count</td>
850
- </tr>
851
- <tr>
852
- <td>length</td>
853
- <td>:is</td>
854
- <td>:wrong_length</td>
855
- <td>count</td>
856
- </tr>
857
- <tr>
858
- <td>length</td>
859
- <td>:minimum</td>
860
- <td>:too_short</td>
861
- <td>count</td>
862
- </tr>
863
- <tr>
864
- <td>length</td>
865
- <td>:maximum</td>
866
- <td>:too_long</td>
867
- <td>count</td>
868
- </tr>
869
- <tr>
870
- <td>uniqueness</td>
871
- <td>-</td>
872
- <td>:taken</td>
873
- <td>-</td>
874
- </tr>
875
- <tr>
876
- <td>format</td>
877
- <td>-</td>
878
- <td>:invalid</td>
879
- <td>-</td>
880
- </tr>
881
- <tr>
882
- <td>inclusion</td>
883
- <td>-</td>
884
- <td>:inclusion</td>
885
- <td>-</td>
886
- </tr>
887
- <tr>
888
- <td>exclusion</td>
889
- <td>-</td>
890
- <td>:exclusion</td>
891
- <td>-</td>
892
- </tr>
893
- <tr>
894
- <td>associated</td>
895
- <td>-</td>
896
- <td>:invalid</td>
897
- <td>-</td>
898
- </tr>
899
- <tr>
900
- <td>numericality</td>
901
- <td>-</td>
902
- <td>:not_a_number</td>
903
- <td>-</td>
904
- </tr>
905
- <tr>
906
- <td>numericality</td>
907
- <td>:greater_than</td>
908
- <td>:greater_than</td>
909
- <td>count</td>
910
- </tr>
911
- <tr>
912
- <td>numericality</td>
913
- <td>:greater_than_or_equal_to</td>
914
- <td>:greater_than_or_equal_to</td>
915
- <td>count</td>
916
- </tr>
917
- <tr>
918
- <td>numericality</td>
919
- <td>:equal_to</td>
920
- <td>:equal_to</td>
921
- <td>count</td>
922
- </tr>
923
- <tr>
924
- <td>numericality</td>
925
- <td>:less_than</td>
926
- <td>:less_than</td>
927
- <td>count</td>
928
- </tr>
929
- <tr>
930
- <td>numericality</td>
931
- <td>:less_than_or_equal_to</td>
932
- <td>:less_than_or_equal_to</td>
933
- <td>count</td>
934
- </tr>
935
- <tr>
936
- <td>numericality</td>
937
- <td>:only_integer</td>
938
- <td>:not_an_integer</td>
939
- <td>-</td>
940
- </tr>
941
- <tr>
942
- <td>numericality</td>
943
- <td>:odd</td>
944
- <td>:odd</td>
945
- <td>-</td>
946
- </tr>
947
- <tr>
948
- <td>numericality</td>
949
- <td>:even</td>
950
- <td>:even</td>
951
- <td>-</td>
952
- </tr>
953
- </tbody>
954
- </table>
955
- <h5 id="translations-for-the-active-record-error_messages_for-helper">4.6.3 Translations for the Active Record <code>error_messages_for</code> Helper</h5><p>If you are using the Active Record <code>error_messages_for</code> helper, you will want to add
956
- translations for it.</p><p>Rails ships with the following translations:</p><div class="code_container">
957
- <pre class="brush: plain; gutter: false; toolbar: false">
958
- en:
959
- activerecord:
960
- errors:
961
- template:
962
- header:
963
- one: "1 error prohibited this %{model} from being saved"
964
- other: "%{count} errors prohibited this %{model} from being saved"
965
- body: "There were problems with the following fields:"
966
-
967
- </pre>
968
- </div>
969
- <div class="note"><p>In order to use this helper, you need to install <a href="https://github.com/joelmoss/dynamic_form">DynamicForm</a>
970
- gem by adding this line to your Gemfile: <code>gem 'dynamic_form'</code>.</p></div><h4 id="translations-for-action-mailer-e-mail-subjects">4.7 Translations for Action Mailer E-Mail Subjects</h4><p>If you don't pass a subject to the <code>mail</code> method, Action Mailer will try to find
971
- it in your translations. The performed lookup will use the pattern
972
- <code>&lt;mailer_scope&gt;.&lt;action_name&gt;.subject</code> to construct the key.</p><div class="code_container">
973
- <pre class="brush: ruby; gutter: false; toolbar: false">
974
- # user_mailer.rb
975
- class UserMailer &lt; ActionMailer::Base
976
- def welcome(user)
977
- #...
978
- end
979
- end
980
-
981
- </pre>
982
- </div>
983
- <div class="code_container">
984
- <pre class="brush: plain; gutter: false; toolbar: false">
985
- en:
986
- user_mailer:
987
- welcome:
988
- subject: "Welcome to Rails Guides!"
989
-
990
- </pre>
991
- </div>
992
- <p>To send parameters to interpolation use the <code>default_i18n_subject</code> method on the mailer.</p><div class="code_container">
993
- <pre class="brush: ruby; gutter: false; toolbar: false">
994
- # user_mailer.rb
995
- class UserMailer &lt; ActionMailer::Base
996
- def welcome(user)
997
- mail(to: user.email, subject: default_i18n_subject(user: user.name))
998
- end
999
- end
1000
-
1001
- </pre>
1002
- </div>
1003
- <div class="code_container">
1004
- <pre class="brush: plain; gutter: false; toolbar: false">
1005
- en:
1006
- user_mailer:
1007
- welcome:
1008
- subject: "%{user}, welcome to Rails Guides!"
1009
-
1010
- </pre>
1011
- </div>
1012
- <h4 id="overview-of-other-built-in-methods-that-provide-i18n-support">4.8 Overview of Other Built-In Methods that Provide I18n Support</h4><p>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.</p><h5 id="action-view-helper-methods">4.8.1 Action View Helper Methods</h5>
1013
- <ul>
1014
- <li><p><code>distance_of_time_in_words</code> translates and pluralizes its result and interpolates the number of seconds, minutes, hours, and so on. See <a href="https://github.com/rails/rails/blob/master/actionview/lib/action_view/locale/en.yml#L4">datetime.distance_in_words</a> translations.</p></li>
1015
- <li><p><code>datetime_select</code> and <code>select_month</code> use translated month names for populating the resulting select tag. See <a href="https://github.com/rails/rails/blob/master/activesupport/lib/active_support/locale/en.yml#L15">date.month_names</a> for translations. <code>datetime_select</code> also looks up the order option from <a href="https://github.com/rails/rails/blob/master/activesupport/lib/active_support/locale/en.yml#L18">date.order</a> (unless you pass the option explicitly). All date selection helpers translate the prompt using the translations in the <a href="https://github.com/rails/rails/blob/master/actionview/lib/action_view/locale/en.yml#L39">datetime.prompts</a> scope if applicable.</p></li>
1016
- <li><p>The <code>number_to_currency</code>, <code>number_with_precision</code>, <code>number_to_percentage</code>, <code>number_with_delimiter</code>, and <code>number_to_human_size</code> helpers use the number format settings located in the <a href="https://github.com/rails/rails/blob/master/activesupport/lib/active_support/locale/en.yml#L37">number</a> scope.</p></li>
1017
- </ul>
1018
- <h5 id="active-model-methods">4.8.2 Active Model Methods</h5>
1019
- <ul>
1020
- <li><p><code>model_name.human</code> and <code>human_attribute_name</code> use translations for model names and attribute names if available in the <a href="https://github.com/rails/rails/blob/master/activerecord/lib/active_record/locale/en.yml#L36">activerecord.models</a> scope. They also support translations for inherited class names (e.g. for use with STI) as explained above in "Error message scopes".</p></li>
1021
- <li><p><code>ActiveModel::Errors#generate_message</code> (which is used by Active Model validations but may also be used manually) uses <code>model_name.human</code> and <code>human_attribute_name</code> (see above). It also translates the error message and supports translations for inherited class names as explained above in "Error message scopes".</p></li>
1022
- <li><p><code>ActiveModel::Errors#full_messages</code> prepends the attribute name to the error message using a separator that will be looked up from <a href="https://github.com/rails/rails/blob/master/activemodel/lib/active_model/locale/en.yml#L4">errors.format</a> (and which defaults to <code>"%{attribute} %{message}"</code>).</p></li>
1023
- </ul>
1024
- <h5 id="active-support-methods">4.8.3 Active Support Methods</h5>
1025
- <ul>
1026
- <li>
1027
- <code>Array#to_sentence</code> uses format settings as given in the <a href="https://github.com/rails/rails/blob/master/activesupport/lib/active_support/locale/en.yml#L33">support.array</a> scope.</li>
1028
- </ul>
1029
- <h3 id="how-to-store-your-custom-translations">5 How to Store your Custom Translations</h3><p>The Simple backend shipped with Active Support allows you to store translations in both plain Ruby and YAML format.<sup class="footnote" id="footnote-2-ref"><a href="#footnote-2">2</a></sup></p><p>For example a Ruby Hash providing translations can look like this:</p><div class="code_container">
1030
- <pre class="brush: plain; gutter: false; toolbar: false">
1031
- {
1032
- pt: {
1033
- foo: {
1034
- bar: "baz"
1035
- }
1036
- }
1037
- }
1038
-
1039
- </pre>
1040
- </div>
1041
- <p>The equivalent YAML file would look like this:</p><div class="code_container">
1042
- <pre class="brush: plain; gutter: false; toolbar: false">
1043
- pt:
1044
- foo:
1045
- bar: baz
1046
-
1047
- </pre>
1048
- </div>
1049
- <p>As you see, in both cases the top level key is the locale. <code>:foo</code> is a namespace key and <code>:bar</code> is the key for the translation "baz".</p><p>Here is a "real" example from the Active Support <code>en.yml</code> translations YAML file:</p><div class="code_container">
1050
- <pre class="brush: plain; gutter: false; toolbar: false">
1051
- en:
1052
- date:
1053
- formats:
1054
- default: "%Y-%m-%d"
1055
- short: "%b %d"
1056
- long: "%B %d, %Y"
1057
-
1058
- </pre>
1059
- </div>
1060
- <p>So, all of the following equivalent lookups will return the <code>:short</code> date format <code>"%b %d"</code>:</p><div class="code_container">
1061
- <pre class="brush: ruby; gutter: false; toolbar: false">
1062
- I18n.t 'date.formats.short'
1063
- I18n.t 'formats.short', scope: :date
1064
- I18n.t :short, scope: 'date.formats'
1065
- I18n.t :short, scope: [:date, :formats]
1066
-
1067
- </pre>
1068
- </div>
1069
- <p>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.</p><h3 id="customize-your-i18n-setup">6 Customize your I18n Setup</h3><h4 id="using-different-backends">6.1 Using Different Backends</h4><p>For several reasons the Simple backend shipped with Active Support only does the "simplest thing that could possibly work" <em>for Ruby on Rails</em><sup class="footnote" id="footnote-3-ref"><a href="#footnote-3">3</a></sup> ... 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.</p><p>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:</p><div class="code_container">
1070
- <pre class="brush: ruby; gutter: false; toolbar: false">
1071
- I18n.backend = Globalize::Backend::Static.new
1072
-
1073
- </pre>
1074
- </div>
1075
- <p>You can also use the Chain backend to chain multiple backends together. This is useful when you want to use standard translations with a Simple backend but store custom application translations in a database or other backends. For example, you could use the Active Record backend and fall back to the (default) Simple backend:</p><div class="code_container">
1076
- <pre class="brush: ruby; gutter: false; toolbar: false">
1077
- I18n.backend = I18n::Backend::Chain.new(I18n::Backend::ActiveRecord.new, I18n.backend)
1078
-
1079
- </pre>
1080
- </div>
1081
- <h4 id="using-different-exception-handlers">6.2 Using Different Exception Handlers</h4><p>The I18n API defines the following exceptions that will be raised by backends when the corresponding unexpected conditions occur:</p><div class="code_container">
1082
- <pre class="brush: ruby; gutter: false; toolbar: false">
1083
- MissingTranslationData # no translation was found for the requested key
1084
- InvalidLocale # the locale set to I18n.locale is invalid (e.g. nil)
1085
- InvalidPluralizationData # a count option was passed but the translation data is not suitable for pluralization
1086
- MissingInterpolationArgument # the translation expects an interpolation argument that has not been passed
1087
- ReservedInterpolationKey # the translation contains a reserved interpolation variable name (i.e. one of: scope, default)
1088
- UnknownFileType # the backend does not know how to handle a file type that was added to I18n.load_path
1089
-
1090
- </pre>
1091
- </div>
1092
- <p>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 <code>MissingTranslationData</code> exceptions. When a <code>MissingTranslationData</code> exception has been caught, it will return the exception's error message string containing the missing key/scope.</p><p>The reason for this is that during development you'd usually want your views to still render even though a translation is missing.</p><p>In other contexts you might want to change this behavior, though. E.g. the default exception handling does not allow to catch missing translations during automated tests easily. For this purpose a different exception handler can be specified. The specified exception handler must be a method on the I18n module or a class with <code>#call</code> method:</p><div class="code_container">
1093
- <pre class="brush: ruby; gutter: false; toolbar: false">
1094
- module I18n
1095
- class JustRaiseExceptionHandler &lt; ExceptionHandler
1096
- def call(exception, locale, key, options)
1097
- if exception.is_a?(MissingTranslation)
1098
- raise exception.to_exception
1099
- else
1100
- super
1101
- end
1102
- end
1103
- end
1104
- end
1105
-
1106
- I18n.exception_handler = I18n::JustRaiseExceptionHandler.new
1107
-
1108
- </pre>
1109
- </div>
1110
- <p>This would re-raise only the <code>MissingTranslationData</code> exception, passing all other input to the default exception handler.</p><p>However, if you are using <code>I18n::Backend::Pluralization</code> this handler will also raise <code>I18n::MissingTranslationData: translation missing: en.i18n.plural.rule</code> exception that should normally be ignored to fall back to the default pluralization rule for English locale. To avoid this you may use additional check for translation key:</p><div class="code_container">
1111
- <pre class="brush: ruby; gutter: false; toolbar: false">
1112
- if exception.is_a?(MissingTranslation) &amp;&amp; key.to_s != 'i18n.plural.rule'
1113
- raise exception.to_exception
1114
- else
1115
- super
1116
- end
1117
-
1118
- </pre>
1119
- </div>
1120
- <p>Another example where the default behavior is less desirable is the Rails TranslationHelper which provides the method <code>#t</code> (as well as <code>#translate</code>). When a <code>MissingTranslationData</code> exception occurs in this context, the helper wraps the message into a span with the CSS class <code>translation_missing</code>.</p><p>To do so, the helper forces <code>I18n#translate</code> to raise exceptions no matter what exception handler is defined by setting the <code>:raise</code> option:</p><div class="code_container">
1121
- <pre class="brush: ruby; gutter: false; toolbar: false">
1122
- I18n.t :foo, raise: true # always re-raises exceptions from the backend
1123
-
1124
- </pre>
1125
- </div>
1126
- <h3 id="conclusion">7 Conclusion</h3><p>At this point you should have a good overview about how I18n support in Ruby on Rails works and are ready to start translating your project.</p><p>If you find anything missing or wrong in this guide, please file a ticket on our <a href="http://i18n.lighthouseapp.com/projects/14948-rails-i18n/overview">issue tracker</a>. If you want to discuss certain portions or have questions, please sign up to our <a href="http://groups.google.com/group/rails-i18n">mailing list</a>.</p><h3 id="contributing-to-rails-i18n">8 Contributing to Rails I18n</h3><p>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.</p><p>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 <a href="http://groups.google.com/group/rails-i18n!">mailing list</a>)</p><p>If you find your own locale (language) missing from our <a href="https://github.com/svenfuchs/rails-i18n/tree/master/rails/locale">example translations data</a> repository for Ruby on Rails, please <a href="https://github.com/guides/fork-a-project-and-submit-your-modifications"><em>fork</em></a> the repository, add your data and send a <a href="https://github.com/guides/pull-requests">pull request</a>.</p><h3 id="resources">9 Resources</h3>
1127
- <ul>
1128
- <li>
1129
- <a href="http://rails-i18n.org">rails-i18n.org</a> - Homepage of the rails-i18n project. You can find lots of useful resources on the <a href="http://rails-i18n.org/wiki">wiki</a>.</li>
1130
- <li>
1131
- <a href="http://groups.google.com/group/rails-i18n">Google group: rails-i18n</a> - The project's mailing list.</li>
1132
- <li>
1133
- <a href="https://github.com/svenfuchs/rails-i18n/tree/master">GitHub: rails-i18n</a> - Code repository for the rails-i18n project. Most importantly you can find lots of <a href="https://github.com/svenfuchs/rails-i18n/tree/master/rails/locale">example translations</a> for Rails that should work for your application in most cases.</li>
1134
- <li>
1135
- <a href="https://github.com/svenfuchs/i18n/tree/master">GitHub: i18n</a> - Code repository for the i18n gem.</li>
1136
- <li>
1137
- <a href="http://i18n.lighthouseapp.com/projects/14948-rails-i18n/overview">Lighthouse: rails-i18n</a> - Issue tracker for the rails-i18n project.</li>
1138
- <li>
1139
- <a href="http://i18n.lighthouseapp.com/projects/14947-ruby-i18n/overview">Lighthouse: i18n</a> - Issue tracker for the i18n gem.</li>
1140
- </ul>
1141
- <h3 id="authors">10 Authors</h3>
1142
- <ul>
1143
- <li>
1144
- <a href="http://www.workingwithrails.com/person/9963-sven-fuchs">Sven Fuchs</a> (initial author)</li>
1145
- <li><a href="http://www.workingwithrails.com/person/7476-karel-mina-k">Karel Minařík</a></li>
1146
- </ul>
1147
- <p>If you found this guide useful, please consider recommending its authors on <a href="http://www.workingwithrails.com">workingwithrails</a>.</p><h3 id="footnotes">11 Footnotes</h3><p class="footnote" id="footnote-1"><a href="#footnote-1-ref"><sup>1</sup></a> Or, to quote <a href="http://en.wikipedia.org/wiki/Internationalization_and_localization">Wikipedia</a>: <em>"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."</em></p><p class="footnote" id="footnote-2"><a href="#footnote-2-ref"><sup>2</sup></a> Other backends might allow or require to use other formats, e.g. a GetText backend might allow to read GetText files.</p><p class="footnote" id="footnote-3"><a href="#footnote-3-ref"><sup>3</sup></a> One of these reasons is that we don't want to imply any unnecessary load for applications that do not need any I18n capabilities, so we need to keep the I18n library as simple as possible for English. Another reason is that it is virtually impossible to implement a one-fits-all solution for all problems related to I18n for all existing languages. So a solution that allows us to exchange the entire implementation easily is appropriate anyway. This also makes it much easier to experiment with custom features and extensions.</p>
1148
-
1149
- <h3>Feedback</h3>
1150
- <p>
1151
- You're encouraged to help improve the quality of this guide.
1152
- </p>
1153
- <p>
1154
- Please contribute if you see any typos or factual errors.
1155
- To get started, you can read our <a href="http://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#contributing-to-the-rails-documentation">documentation contributions</a> section.
1156
- </p>
1157
- <p>
1158
- You may also find incomplete content, or stuff that is not up to date.
1159
- Please do add any missing documentation for master. Make sure to check
1160
- <a href="http://edgeguides.rubyonrails.org">Edge Guides</a> first to verify
1161
- if the issues are already fixed or not on the master branch.
1162
- Check the <a href="ruby_on_rails_guides_guidelines.html">Ruby on Rails Guides Guidelines</a>
1163
- for style and conventions.
1164
- </p>
1165
- <p>
1166
- If for whatever reason you spot something to fix but cannot patch it yourself, please
1167
- <a href="https://github.com/rails/rails/issues">open an issue</a>.
1168
- </p>
1169
- <p>And last but not least, any kind of discussion regarding Ruby on Rails
1170
- documentation is very welcome in the <a href="http://groups.google.com/group/rubyonrails-docs">rubyonrails-docs mailing list</a>.
1171
- </p>
1172
- </div>
1173
- </div>
1174
- </div>
1175
-
1176
- <hr class="hide" />
1177
- <div id="footer">
1178
- <div class="wrapper">
1179
- <p>This work is licensed under a <a href="https://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International</a> License</p>
1180
- <p>"Rails", "Ruby on Rails", and the Rails logo are trademarks of David Heinemeier Hansson. All rights reserved.</p>
1181
-
1182
- </div>
1183
- </div>
1184
-
1185
- <script type="text/javascript" src="javascripts/jquery.min.js"></script>
1186
- <script type="text/javascript" src="javascripts/responsive-tables.js"></script>
1187
- <script type="text/javascript" src="javascripts/guides.js"></script>
1188
- <script type="text/javascript" src="javascripts/syntaxhighlighter/shCore.js"></script>
1189
- <script type="text/javascript" src="javascripts/syntaxhighlighter/shBrushRuby.js"></script>
1190
- <script type="text/javascript" src="javascripts/syntaxhighlighter/shBrushXml.js"></script>
1191
- <script type="text/javascript" src="javascripts/syntaxhighlighter/shBrushSql.js"></script>
1192
- <script type="text/javascript" src="javascripts/syntaxhighlighter/shBrushPlain.js"></script>
1193
- <script type="text/javascript">
1194
- SyntaxHighlighter.all();
1195
- $(guidesIndex.bind);
1196
- </script>
1197
- </body>
1198
- </html>