0

I'm using http://github.com/fnando/i18n-js gem for JavaScript translation. Here is my translation yml:

en:
  js:
    test: "<strong>%{name}</strong> created this board."

In my JS, I run with "name" param is "$&".

console.log(I18n.t('js.test', {name: "$&"}))

Unfortunately, it will show message like this: %{name} created this board, while I expect that message should be: $& created this board. Is there any problem with special character like "&" with this gem? And how to solve this?

Snow Fox
  • 389
  • 6
  • 15

1 Answers1

0

The problem in your code is, your interpolation is not working as you used %{name} in your translation file. You have to use: {{name}} instead to make the interpolation work.

So, change:

test: "<strong>%{name}</strong> created this board."

to this:

test: "<strong>{{name}}</strong> created this board."

and it should work!

K M Rakibul Islam
  • 33,760
  • 12
  • 89
  • 110