views:

238

answers:

1
<%  @recently_active_objects = Activity.find(:all, :limit => 10, :order => "id DESC")  %>

<% @recently_active_objects.group_by{ |object| object.created_at.midnight }.each do |day, objects| %>
<h3><%=  day.strftime("%A, %B %e")  %></h3>

          <% objects.each do |object| %>
          <%= activity_message_for_activity(object) %>
          <% end %>

<% end %>

How do you localize day.strftime in this case?

+1  A: 

Assuming that day is a Time instance, replace strftime by l.

<% @recently_active_objects.group_by{ |object| object.created_at.midnight }.each do |day, objects| %>
  <h3><%=l day, :format => :weekmonth %></h3>
  <% objects.each do |object| %>
    <%= activity_message_for_activity(object) %>
  <% end %>
<% end %>

Then go to your en.yml file and add the following item.

en:
  time: 
    formats: 
      weekmonth: "%A, %B %e"

Add the weekmonth definition to every language file.

Simone Carletti
uh you still have strftime in your example. Is this intentional?
Ryan Bigg
No, it's an error. Fixed. :)
Simone Carletti
i tried this and got: can't convert Array into String ..
Carlos Barbosa
It's hard to figure out the error without the stack trace. Try to use a standard value for :format instead of :weekmonth. If it works, you might have some problem in your en.yml file.
Simone Carletti