Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails problem using I18n in views but not in console

I have to show a translation in a view in a locale different from the current one. I use this code to force the locale for one translation :

I18n.t :what_ever, :locale => 'es'

It works in the rails console but not in the view! I have try many things but I cannot find a solution. The view tell this error :

translation missing: es.what_ever

So, I was thinking it was a trouble from the YAML but exactly the same code works well in rails console....

Any Ideas ?

like image 277
Hartator Avatar asked Feb 02 '26 11:02

Hartator


1 Answers

This seems like answered, but I will give you the solution anyway:

Instead of doing:

I18n.t :what_ever, :locale => 'es'

Do this:

I18n.t 'what_ever', :locale => 'es'
like image 67
dimitarvp Avatar answered Feb 05 '26 07:02

dimitarvp



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!