我想在我的日期添加'th','nd'后缀。这个问题解决了问题的一部分:In Ruby on Rails, how do I format a date with the "th" suffix, as in, "Sun Oct 5th"?
但是我需要在/config/en.yml中添加它。怎么做?
答案 0 :(得分:1)
您可以将字符串传递给语言环境
en:
foo: "it is the %{day} of %{month} today"
I18n.t('foo', day: Date.today.day.ordinalize, month: Date::MONTHNAMES[Date.today.month] )