Forum: Ruby on Rails date_select problem with i18n

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jeba M. (Guest)
on 2009-03-17 12:57
Hi,
I'm localizing my rails 2.2.2 application using i18n.
In my form(view) I have:
<%= date_select :range,:start_date,:order => [:month,:day,:year]%>
In environment.rb I have:
I18n.default_locale = 'en-US'
and in en-US.rb its:
I18n.backend.store_translations 'en-US',
  :date => {
    :order => [:month, :day, :year],
    :month_names => %w[Jan Feb Mar Apr May Jun Jul Aug Spt Oct Nov Dec]
  }

My problem is that the date select options are not proper.
Instead of month names in the drop down I get some 12 numeric
values...!!!!! as 110,32,111,115..etc...
How should I solve this???
Please help...
Thank You...
Sylv G. (Guest)
on 2009-07-14 21:52
Jeba M. wrote:
> Hi,
> I'm localizing my rails 2.2.2 application using i18n.
> In my form(view) I have:
> <%= date_select :range,:start_date,:order => [:month,:day,:year]%>
> In environment.rb I have:
> I18n.default_locale = 'en-US'
> and in en-US.rb its:
> I18n.backend.store_translations 'en-US',
>   :date => {
>     :order => [:month, :day, :year],
>     :month_names => %w[Jan Feb Mar Apr May Jun Jul Aug Spt Oct Nov Dec]
>   }
>
> My problem is that the date select options are not proper.
> Instead of month names in the drop down I get some 12 numeric
> values...!!!!! as 110,32,111,115..etc...
> How should I solve this???
> Please help...
> Thank You...

Hi Jeba!
I'm using Rails 2.3.2 and I'm developing a simple application with i18n
features. I have put theese lines in a config/locales/fr.yml file:
  date:
    formats:
      default: "%d/%M/%Y"
      long: "%e %B %Y"
      short: "%d/%M/%y"

    order: [ :day, :month, :year ]

    month_names: [~, Janvier, Février, Mars, Avril, Mai, Juin, Juillet,
Août, Septembre, Octobre, Novembre, Décembre]

And my application is working out as I expect. For your information, I
had tried on a first step without defining month_names array and had
same result than you describe.

Good luck!
This topic is locked and can not be replied to.