I18n - Internationalization
suggest changeVersions
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.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents