2

I'm trying to find a way to translate the headers of the rails date_field.

<%= form_for @foo do |f| %>
   <%= f.date_field :startdate %>
<% end %>

enter image description here

I allready have my swedish locale and it works when outputting things in the view (eg: I18n.localize(@startdate, format: "%a %e %b")), but I can't find anywhere how to translate the date helper.

I'm on Rails 4.

swelet
  • 8,192
  • 5
  • 33
  • 45

2 Answers2

2

The format is handled by the browsers because f.date_field generates an HTML5 <input type="date" ... > tag, and according to this question, the browsers do not yet support custom formats.

Community
  • 1
  • 1
Baldrick
  • 23,882
  • 6
  • 74
  • 79
  • Oh that explains it! I had my browser language set to english. I looked everywhere in the Rails documentation, but I didn't think of that. – swelet Feb 12 '14 at 20:14
  • 1
    You might check at the solution I proposed to you in my answer. It is fully functional across all browsers and supports internationalization – Ruby Racer Feb 14 '14 at 05:38
1

If you need a translated version, skip the date field and use jquery datepicker:

http://jqueryui.com/datepicker/#localization

https://github.com/joliss/jquery-ui-rails

Ruby Racer
  • 5,690
  • 1
  • 26
  • 43