[ rails ] i18n

Example : Active Record validation messages ( https://github.com/rails/rails/blob/master/activemodel/lib/active_model/locale/en.yml ) , time and date formats ( https://github.com/rails/rails/blob/master/activesupport/lib/active_support/locale/en.yml )

config/locales/en.yml

en:
hello: "Hello World"

To use a locale use translate ( or t alias )

I18n.t 'hello

In views, use t aliased.

<%= t('views.hello', test: 'can also input params') %>

To use a different locale, set it with ‘I18n.locale’.

I18n.locale = :en

ActiveRecord i18n

config/locale/en.yml

en:
activerecord:

errors:

models:

views:

hello: "Hello World %{test}"

thatModel:

hello: "Hello World"

ref : http://guides.rubyonrails.org/i18n.html

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s