Papadeltasierra
Papadeltasierra

Reputation: 243

Rails: How is `translate` exposed to ActionController?

Can anyone explain how I18n.translate is exposed to the ActionController class and can be used as plain translate or t? I would like to tweak the translate code but can't understand how it is exposed - for example calling translate.source_location throws an error indicating that there is no method translate in class ActionController.

Upvotes: 4

Views: 205

Answers (1)

Andrey Deineko
Andrey Deineko

Reputation: 52357

In views and controllers you have access to t helper. Everywhere else you should be using I18n.t.

Here is where ActionController::Base includes AbstractController::Translation with two methods:

Upvotes: 2

Related Questions