10
有沒有辦法做這樣的事情:如何在I18n語言環境中執行插值?
en:
welcome:
hello there, #{current_user.first_name}! It's nice to see you again.
這顯然是行不通的,而且顯然「#{」是YAML無效字符,因爲該字符串顯示爲只是「你好」當我把它拉出來。
我能做的最好是這樣的:
en:
welcome:
hello there, (name)! It's nice to see you again.
....
t(:welcome).gsub("(name)", current_user.first_name)
但我不是瘋了有關......必須有一個更好的方式做這樣的事情。