Rails: How to make Date strftime aware of the default locale?

前端 未结 3 2188
北海茫月
北海茫月 2020-12-23 18:53

I have my default locale set in the environment.rb as de (German).

I also see all the error messages in German, so the locale is picked up

3条回答
  •  没有蜡笔的小新
    2020-12-23 19:48

    Use the l (alias for localize) method instead of raw strftime, like this:

    l(date, format: '%B %d, in the year %Y')
    

    See here for more information, hope that helps.

    You can also define 'named' formats, a couple of them (short, long) are already predefined.

提交回复
热议问题