jacob1992
jacob1992

Reputation: 141

Linking when using I18n Ruby on Rails

I'm very new with Ruby on Rails and I spent the night trying to get my translation with I18n to work. I got 2 locale, swedish(sv) and english(en). I finally got the url working with the /en and /sv working like this: domain/en/services. But the problem appears in my nav menu where I'm trying to have a link_to and at the same time have the t to be able to translate the nav menu item.

<li><%= link_to "t :NavTjänster", tjanster_path %></a></li>.

This is the only way to make the link work correctly with the /en/ or /sv/. t:NavTjänster is used for the translation but the link should say Tjänster in swedish or Services in english, now it appears as t:NavTjänster in the nav menu. How can I do both the link_to and the t:NavTjänster at the same time?

Thanks a lot in advance! I would appreciate if there is someone could guide me on this one!

Upvotes: 0

Views: 74

Answers (1)

Taryn East
Taryn East

Reputation: 27747

using "t :NavTjänster" will literally display that string exactly as you typed it. You will need to rewrite the string as ruby code eg try:

<li><%= link_to t(:NavTjänster), tjanster_path %></li>.

Upvotes: 2

Related Questions