Skip to content

Rails I18n

Teddy Wing edited this page Apr 3, 2018 · 2 revisions

Enables the following syntax in views, controllers and models:

syntax description
"foo.bar".t equivalent to I18n.t("foo.bar")
Catalog.t gets the human name of the Catalog model (plural by default)
Catalog.ts gets the human name of the Catalog model (singular)
Catalog.tmf('name') gets the human name of the Catalog model's name attribute
Catalog.t_action('new') gets the human name of the Catalog model's new action label (falls back on generic action labels)

Furthermore, all these methods get the following features:

  • fallback on the default key: if the lookup for foo.bar.baz.bat is unsucessful, we'll look for foo.bar.default.bat, then foo.default.bat, etc.
  • missing keys display + logging: in development mode, missing keys are signaled in the UI and logged in log/missing_keys.log
Clone this wiki locally