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.
Replace your en.yml like this
and your view like this
Basically it is passed as a named argument. You can find more at Rails Guides 18n Interpolation