how can I perform interpolation in I18n locales?

Viewed 9617

Is there a way to do something like this:

en:
  welcome:
    hello there, #{current_user.first_name}!  It's nice to see you again.

That obviously won't work, and apparently "#{" is invalid characters in yaml, because that string shows up as just "hello there, " when I pull it out.

The best I could do was something like:

en:
  welcome:
    hello there, (name)!  It's nice to see you again.

....

t(:welcome).gsub("(name)", current_user.first_name)

But I am not crazy about that... There must be a better way to do this sort of thing.

1 Answers
Related