9 # same as 'my.messages.hello'
10 t(:hello, scope: 'my.messages')
11 t(:hello, scope: [:my, :messages])
13 t('my.messages.hello', default: "Hello")
27 t('hello', name: "John")
32 hello: "Hello %{name}"
38 # from the 'books/index' view
53 t(:inbox, count: 1) #=> 'one message'
54 t(:inbox, count: 2) #=> '2 messages'
61 other: '%{count} messages'
70 l(Time.now, format: :short)
78 default: "%a, %d %b %Y %H:%M:%S %z"
79 long: "%B %d, %Y %H:%M"
94 default: "%Y-%m-%d" # 2015-06-25
95 long: "%B %d, %Y" # June 25, 2015
96 short: "%b %d" # Jun 25
104 User.model_name.human #=> "User"
105 Child.model_name.human(count: 2) #=> "Children"
122 User.human_attribute_for :name #=> "Name"
131 # activerecord.attributes.<model>.<field>
139 error_messages_for(...)
150 blank: "Please enter a name."
153 Possible scopes (in order):
156 activerecord.errors.models.[model_name].attributes.[attribute_name].[error]
157 activerecord.errors.models.[model_name].[error]
158 activerecord.errors.messages.[error]
159 errors.attributes.[attribute_name].[error]
160 errors.messages.[error]
163 Where `[error]` can be:
167 confirmation - :confirmation
168 acceptance - :accepted
170 length - :too_short (%{count})
171 length - :too_long (%{count})
172 length - :wrong_length (%{count})
175 numericality - :not_a_number
188 # helpers.label.<model>.<field>
191 body: "Your body text"
205 # helpers.submit.<action>
206 create: "Create a %{model}"
207 update: "Confirm changes to %{model}"
209 # helpers.submit.<model>.<action>
211 create: "Publish article"
212 update: "Update article"
219 number_to_delimited(2000) #=> "2,000"
220 number_to_currency(12.3) #=> "$12.30"
221 number_to_percentage(0.3) #=> "30%"
222 number_to_rounded(3.14, precision: 0) #=> "3"
223 number_to_human(12_000) #=> "12 Thousand"
224 number_to_human_size(12345) #=> "12.3 kb"
231 number_to_delimited(n)
242 strip_insignificant_zeroes: false
248 number_to_currency(n)
256 format: "%u%n" # %u = unit, %n = number
261 # (see number.format)
267 number_to_percentage(n)
276 # (see number.format)
279 ## Programmatic access
282 I18n.backend.store_translations :en, ok: "Ok"
284 I18n.default_locale = :en
286 I18n.available_locales
288 I18n.translate :ok # aka, I18n.t
289 I18n.localize date # aka, I18n.l
295 * http://guides.rubyonrails.org/i18n.html
296 * http://rails-i18n.org/wiki
297 * https://github.com/svenfuchs/i18n
298 * https://github.com/svenfuchs/rails-i18n/blob/master/rails/locale/en.yml