Reputation: 2028
I am generating days like this:
(1..days_in_month(year, month)).each do |day|
calendar << Day.new(day, day_from_date(format_day(day), month, year))
end
And then I access their names in the show page:
<% @calendar.each_with_index do |d, i| %>
<tr>
<td><%= d.name %></td>
<% end %>
The days are in English despite having set the default language in French.
application.rb
config.i18n.default_locale = :fr
config/locales/fr.yml
fr:
date:
abbr_day_names:
- dim
- lun
- mar
- mer
- jeu
- ven
etc.
Console output:
2.1.5 :001 > I18n.locale
=> :fr
Why aren't the days translated in French?
EDIT:
Since it's a project I had to take over, I tried to look for a documentation for the Day
class. I found a local
documentation page that explains that Day
"represents a day as a number and a name". It doesn't seem to be coming from an official documentation.
Upvotes: 1
Views: 190
Reputation: 54882
You can eventually translate the day names like this:
<% @calendar.each_with_index do |d, i| %>
<tr>
<td><%= t('date.abbr_day_names')[d.number] %></td>
<% end %>
This implies that the attribute number
of the Day
records represent the "day index" in a 7 days week.
Upvotes: 1