Formatting

This commit is contained in:
Rico Sta. Cruz 2015-04-16 20:43:15 +08:00
parent e7c1204553
commit 69d636f26c
1 changed files with 21 additions and 9 deletions

View File

@ -20,6 +20,7 @@ t('my.messages.hello', default: "Hello")
```rb ```rb
t('hello', name: "John") t('hello', name: "John")
``` ```
{:.terminal}
```yml ```yml
hello: "Hello %{name}" hello: "Hello %{name}"
@ -27,6 +28,12 @@ hello: "Hello %{name}"
### Lazy lookup ### Lazy lookup
```rb
# from the 'books/index' view
t('.title')
```
{:.terminal}
```yml ```yml
en: en:
books: books:
@ -34,17 +41,13 @@ en:
title: "Título" title: "Título"
``` ```
```rb
# from the 'books/index' view
t('.title')
```
### Plural ### Plural
```rb ```rb
t(:inbox, count: 1) #=> 'one message' t(:inbox, count: 1) #=> 'one message'
t(:inbox, count: 2) #=> '2 messages' t(:inbox, count: 2) #=> '2 messages'
``` ```
{:.terminal}
```yml ```yml
inbox: inbox:
@ -60,6 +63,7 @@ inbox:
l(Time.now) l(Time.now)
l(Time.now, format: :short) l(Time.now, format: :short)
``` ```
{:.terminal}
```yml ```yml
en: en:
@ -74,6 +78,7 @@ en:
```rb ```rb
l(Date.today) l(Date.today)
``` ```
{:.terminal}
```yml ```yml
en: en:
@ -92,6 +97,7 @@ User.model_name.human #=> "User"
Child.model_name.human(count: 2) #=> "Children" Child.model_name.human(count: 2) #=> "Children"
User.human_attribute_for :name #=> "Name" User.human_attribute_for :name #=> "Name"
``` ```
{:.terminal}
```yml ```yml
en: en:
@ -110,6 +116,11 @@ en:
### Errors ### Errors
```rb
error_messages_for(...)
```
{:.terminal}
```yml ```yml
activerecord: activerecord:
errors: errors:
@ -145,10 +156,6 @@ validates
numericality - :not_a_number numericality - :not_a_number
``` ```
```rb
error_messages_for(...)
```
### Labels ### Labels
``` ```
@ -185,12 +192,14 @@ number_to_rounded(3.14, precision: 0) #=> "3"
number_to_human(12_000) #=> "12 Thousand" number_to_human(12_000) #=> "12 Thousand"
number_to_human_size(12345) #=> "12.3 kb" number_to_human_size(12345) #=> "12.3 kb"
``` ```
{:.terminal}
### Delimited ### Delimited
```rb ```rb
number_to_delimited(n) number_to_delimited(n)
``` ```
{:.terminal}
```yml ```yml
number: number:
@ -207,6 +216,7 @@ number:
```rb ```rb
number_to_currency(n) number_to_currency(n)
``` ```
{:.terminal}
```yml ```yml
number: number:
@ -225,6 +235,7 @@ number:
```rb ```rb
number_to_percentage(n) number_to_percentage(n)
``` ```
{:.terminal}
```yml ```yml
number: number:
@ -246,6 +257,7 @@ I18n.available_locales
I18n.translate :ok # aka, I18n.t I18n.translate :ok # aka, I18n.t
I18n.localize date # aka, I18n.l I18n.localize date # aka, I18n.l
``` ```
{:.terminal}
## Reference ## Reference