# Using translation variable in link\_to

**URL:** <https://www.ruby-forum.com/t/using-translation-variable-in-link-to/195066>\
**Category:** Ruby\
**Created:** [September 16, 2010, 8:39am UTC](https://www.ruby-forum.com/t/using-translation-variable-in-link-to/195066 "2010-09-16T08:39:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![arunachandu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d6d6ee/32.png) [@arunachandu](https://www.ruby-forum.com/u/arunachandu)\
**Post date:** [September 16, 2010, 8:39am UTC](https://www.ruby-forum.com/t/using-translation-variable-in-link-to/195066/1 "2010-09-16T08:39:24Z")

</div>

HI ,

In ROR , i m having 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 am getting errors…

---

<div class="post-metadata">

**Author:** ![arunachandu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d6d6ee/32.png) [@arunachandu](https://www.ruby-forum.com/u/arunachandu)\
**Post date:** [September 16, 2010, 9:03am UTC](https://www.ruby-forum.com/t/using-translation-variable-in-link-to/195066/2 "2010-09-16T09:03:43Z")

</div>

On Sep 15, 2010, at 23:39 , Aruna C. wrote:

> how to change it . when i change it , i am getting errors…  
> you should ask on the rubyonrails forum instead.

---

<div class="post-metadata">

**Author:** ![arunachandu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d6d6ee/32.png) [@arunachandu](https://www.ruby-forum.com/u/arunachandu)\
**Post date:** [September 16, 2010, 5:39pm UTC](https://www.ruby-forum.com/t/using-translation-variable-in-link-to/195066/3 "2010-09-16T17:39:27Z")

</div>

On Sep 16, 2010, at 2:39 AM, Aruna C. wrote:

> In ROR , i m having 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 am getting errors…

Without the actual error message I’m guessing but you probably want  
something like:

\<%= link\_to("#{t(:str\_name)} (#{@name})", user\_path(@user, :in =\> :s))  
%\>

And if that fixes your problem then, ruby-talk was an appropriate place  
for the  
question since it is just a language issue and not a Rails issue.

Gary W.

---

<div class="post-metadata">

**Author:** ![arunachandu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d6d6ee/32.png) [@arunachandu](https://www.ruby-forum.com/u/arunachandu)\
**Post date:** [September 17, 2010, 7:30am UTC](https://www.ruby-forum.com/t/using-translation-variable-in-link-to/195066/4 "2010-09-17T07:30:35Z")

</div>

Gary W. wrote:

> On Sep 16, 2010, at 2:39 AM, Aruna C. wrote:
> 
> > In ROR , i m having 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 am getting errors…
> 
> Without the actual error message I’m guessing but you probably want  
> something like:
> 
> \<%= link\_to("#{t(:str\_name)} (#{@name})", user\_path(@user, :in =\> :s))  
> %\>
> 
> And if that fixes your problem then, ruby-talk was an appropriate place  
> for the  
> question since it is just a language issue and not a Rails issue.
> 
> Gary W.

Thanks Gary .  
Its worked for me…
