9 * <http://guides.rubyonrails.org/i18n.html>
10 * <http://rails-i18n.org/wiki>
11 * <https://github.com/svenfuchs/i18n>
12 * <https://github.com/svenfuchs/rails-i18n/blob/master/rails/locale/en.yml>
17 t('my.messages.hello')
19 # same as 'my.messages.hello'
20 t(:hello, scope: 'my.messages')
21 t(:hello, scope: [:my, :messages])
23 t('my.messages.hello', default: "Hello")
38 t('hello', name: "John")
44 hello: "Hello %{name}"
50 # from the 'books/index' view
66 t(:inbox, count: 1) #=> 'one message'
67 t(:inbox, count: 2) #=> '2 messages'
75 other: '%{count} messages'
84 l(Time.now, format: :short)
93 default: "%a, %d %b %Y %H:%M:%S %z"
94 long: "%B %d, %Y %H:%M"
110 default: "%Y-%m-%d" # 2015-06-25
111 long: "%B %d, %Y" # June 25, 2015
112 short: "%b %d" # Jun 25
120 User.model_name.human #=> "User"
121 Child.model_name.human(count: 2) #=> "Children"
139 User.human_attribute_for :name #=> "Name"
149 # activerecord.attributes.<model>.<field>
157 error_messages_for(...)
169 blank: "Please enter a name."
174 Possible scopes (in order):
177 activerecord.errors.models.[model_name].attributes.[attribute_name].[error]
178 activerecord.errors.models.[model_name].[error]
179 activerecord.errors.messages.[error]
180 errors.attributes.[attribute_name].[error]
181 errors.messages.[error]
184 Where `[error]` can be:
188 confirmation - :confirmation
189 acceptance - :accepted
191 length - :too_short (%{count})
192 length - :too_long (%{count})
193 length - :wrong_length (%{count})
196 numericality - :not_a_number
210 # helpers.label.<model>.<field>
213 body: "Your body text"
228 # helpers.submit.<action>
229 create: "Create a %{model}"
230 update: "Confirm changes to %{model}"
232 # helpers.submit.<model>.<action>
234 create: "Publish article"
235 update: "Update article"
242 number_to_delimited(2000) #=> "2,000"
243 number_to_currency(12.3) #=> "$12.30"
244 number_to_percentage(0.3) #=> "30%"
245 number_to_rounded(3.14, precision: 0) #=> "3"
246 number_to_human(12_000) #=> "12 Thousand"
247 number_to_human_size(12345) #=> "12.3 kb"
253 number_to_delimited(n)
265 strip_insignificant_zeroes: false
271 number_to_currency(n)
279 format: "%u%n" # %u = unit, %n = number
284 # (see number.format)
290 number_to_percentage(n)
300 # (see number.format)
303 ## Programmatic access
305 ### Programmatic access
308 I18n.backend.store_translations :en, ok: "Ok"
310 I18n.default_locale = :en
312 I18n.available_locales
314 I18n.translate :ok # aka, I18n.t
315 I18n.localize date # aka, I18n.l