开发者

Rails problem using I18n in views but not in console

开发者 https://www.devze.com 2023-03-11 16:52 出处:网络
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 :

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 ?


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'
0

精彩评论

暂无评论...
验证码 换一张
取 消