2

I would like to know if it is possible to use fast_gettext the translate a short paragraph which contains a url link. I'm using a combination of padrino, haml and fast_gettext.

For example:

Please visit our home page.

Inside the .haml file, the code looks like this:

%p
  = _('Please visit our %{home_url} page') % {:home_url => link_to(_("home"), '/home') }

However this will print out the html tag, the output I'm getting look like this

当社の <a href="/home">ホーム</a> ページをご覧ください。

And finally the .po file looks like the following:

msgid ""
"Please visit our %{home_url} page"
msgstr "当社の %{home_url} ページをご覧ください。"

msgid ""
"home"
msgstr "ホーム"

What did I miss?

carbotex
  • 569
  • 1
  • 6
  • 16

1 Answers1

1

You have to put .html_safe at the end of the function call. Rails 4 escapes all HTML.

http://apidock.com/rails/String/html_safe

http://apidock.com/rails/ActionView/Helpers/OutputSafetyHelper/raw

= 'Please visit out <a href="/">home</a> page'.html_safe
Chloe
  • 25,162
  • 40
  • 190
  • 357
  • 1
    I forgot to follow up my own question since I got the answer. This is a correct answer. My solution was: = (_('Please visit our %{home_url} page') % {:home_url => link_to(_("home"), '/home') }).html_safe – carbotex Jan 27 '14 at 03:13