:s)) %> I want t...">

Using translation in link_to in ROR

Hi

In ROR, I m has a line like

<%= link_to("NAME (#{@name})", user_path(@user, :in => :s)) %> 

I want to change the string NAME to t (: str_name) ..

how to change it. when i change it i get errors ..

+4
source share
1 answer

Put your translation in the corresponding .yml files in / config / locales For example, in /config/locales/en.yml

 en: link_text: name: "Name (%{:name})" 

Then from your views:

 <%= link_to(t('link_text.name', :name => @name), user_path(@user, :in => :s)) %> 
+4
source

All Articles