Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between I18n.t and t in Rails

I have a strange problem. I have en.yml file that looks like this:

en:
  no_notifiaction: No Notification 
  active_notification: Active notification


t('.active_notification') == "Active notification" #false
I18n.t('.active_notification') == "Active notification" #true?

Why is that?

like image 641
Mateusz Urbański Avatar asked Sep 13 '25 07:09

Mateusz Urbański


1 Answers

Have a look at the documentation under "Lazy Lookups". t('.active_notification') is only available within the corresponding view and controller. Not if you call it, let's say in a javascript file or any other view...

like image 70
Tom Avatar answered Sep 14 '25 21:09

Tom