3

我想在我的日期中添加“th”、“nd”后缀。这个问题解决了部分问题:在 Ruby on Rails 中,如何格式化带有“th”后缀的日期,例如“Sun Oct 5th”?

但我需要将它添加到 /config/en.yml 中。怎么做?

4

1 回答 1

2

您可以将字符串传递给语言环境

en:
  foo: "it is the %{day} of %{month} today"

I18n.t('foo', day: Date.today.day.ordinalize, month: Date::MONTHNAMES[Date.today.month] )
于 2013-02-04T10:51:01.903 回答