【发布时间】:2013-02-04 10:46:13
【问题描述】:
我想在我的日期中添加“th”、“nd”后缀。这个问题解决了一部分问题:In Ruby on Rails, how do I format a date with the "th" suffix, as in, "Sun Oct 5th"?
但我需要将它添加到 /config/en.yml 中。怎么做?
【问题讨论】:
标签: ruby-on-rails ruby ruby-on-rails-3.2
我想在我的日期中添加“th”、“nd”后缀。这个问题解决了一部分问题:In Ruby on Rails, how do I format a date with the "th" suffix, as in, "Sun Oct 5th"?
但我需要将它添加到 /config/en.yml 中。怎么做?
【问题讨论】:
标签: ruby-on-rails ruby ruby-on-rails-3.2
您可以将字符串传递给语言环境
en:
foo: "it is the %{day} of %{month} today"
I18n.t('foo', day: Date.today.day.ordinalize, month: Date::MONTHNAMES[Date.today.month] )
【讨论】: