I18n - Internationalization

suggest change

Versions

Rails 4.0 through 5.0

Syntax

I18n.t("key")
I18n.translate("key") # equivalent to I18n.t("key")
I18n.t("key", count: 4)
I18n.t("key", param1: "Something", param2: "Else")
I18n.t("doesnt_exist", default: "key") # literal default if the key is missing
I18n.locale #=> :en
I18n.locale = :en
I18n.default_locale #=> :en
I18n.default_locale = :en

In a view or controller, t(".key") is scoped to the current template or action. It is not the same as I18n.t("key"). From app/views/page/users.html.erb, t(".key") looks up page.users.key.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents