Forum: Rails I18n String.to_datetime doesn't translate the monthname

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
F2b113a55e42f840085008edd2938d57?d=identicon&s=25 Jeroen van Ingen (jeroen_v)
on 2012-01-04 11:45
For example I have this translation file:
And I've set:
I18n.locale = :it

This works fine:
I18n.localize -> "Mer 04 Gen 2012, 11:26:17 +0100"
"02 Novembre 2012".to_datetime => Fri, 02 Nov 2012 00:00:00 +0000

But this gives an invalid date:
"02 Gennaio 2012".to_datetime

Date::MONTHNAMES returns:
[nil, "January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December"]

The fastest way to solve this problem is to add the months to the YAML
file and translate them into English months. Like this:
Gennaio: January
Then I do:
"02 #{I18n.t(Gennaio)} 2012".to_datetime => Mon, 02 Jan 2012 00:00:00

But I was wondering if there is a more cleaner way so I can get it to
work like this:
"02 Gennaio 2012".to_datetime
4becbaa02e73aaff17653afc7256460d?d=identicon&s=25 Christopher Dell (tigrish)
on 2012-01-04 11:52
(Received via mailing list)
The question is "how to get a DateTime object from an Italian date
F2b113a55e42f840085008edd2938d57?d=identicon&s=25 Jeroen van Ingen (jeroen_v)
on 2012-01-04 12:12
Yup, that's right

But even better: how to get a DateTime object from a date string where
the  language is other then English?
A90eafae2938a3bfe42286065149bc57?d=identicon&s=25 unknown (Guest)
on 2013-09-12 15:08
(Received via mailing list)
Basically you are looking for something like Chronic
(, but for Italien not English?

As far as I know Chronic only supports English, but if you are
we could work on making it available to multiple languages. I think many
Ruby devs would need something similar.
This topic is locked and can not be replied to.