Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在我的日期中添加“th”、“nd”后缀。这个问题解决了部分问题:在 Ruby on Rails 中,如何格式化带有“th”后缀的日期,例如“Sun Oct 5th”?
但我需要将它添加到 /config/en.yml 中。怎么做?
您可以将字符串传递给语言环境
en: foo: "it is the %{day} of %{month} today" I18n.t('foo', day: Date.today.day.ordinalize, month: Date::MONTHNAMES[Date.today.month] )