开发者

rails 3 internationalization / localization - embeddings links in translated text

开发者 https://www.devze.com 2023-02-28 07:12 出处:网络
I need to embed links in my translated texts.I followed this post, but it doesn\'t seem to work in rails 3 anymore as the html tags don\'t get rendered properly.

I need to embed links in my translated texts. I followed this post, but it doesn't seem to work in rails 3 anymore as the html tags don't get rendered properly.

Anyone knows how to get this done in rails 3?

Update: Apparently, the html tags can be escaped by using the html_safe method. But does anyone know if there's another way to solve this probl开发者_StackOverflow社区em without using html_safe?

I would like to avoid unescaping my html tags if possible, b/c I've encountered a situation where I have to pass in a text field into my translation, and I would like to avoid unescaping any strings that are user inputted.


Change {{url}} to %{url} and you should be good to go.

Update

Ok, thanks, that's important information about what "doesn't work" means :) So, you need to call the html_safe method on your call to link_to, eg.

link_to(t("log_in_href"), login_path).html_safe

This will tell Rails to render the HTML, not escaped.

0

精彩评论

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