Search code examples
ruby-on-railslocale

Rails 3 set locale for date


I'm under rails 3.2.1 and I have a problem by show the localized month name from

date.strftime("%d %B %Y")

I always get the english version even if I set the locale in application.rb

config.i18n.default_locale = :it

and from console app I get this output

> I18n.locale
=> :it 

any hint? Thank you


Solution

  • Check out the Rails Internationalization API Guide

    First, make sure you have the translation files for your language. You need a .yml file which describes your language. Section 3.3 describes how to set up a localization file dealing with date and time formats.

    Now, load up your localization. (It appears that you've already done this.) It seems that there are several places where you can set up your locale. Section 2.2 f the guide talks about loading up a locale manually.

    Finally, this question has more on Ruby Date Internationalization.