Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

time_ago_in_words and localize

Is it possible to use time_ago_in_words with i18n.locale?

how?

thanks

like image 635
Luca Romagnoli Avatar asked Nov 25 '09 14:11

Luca Romagnoli


2 Answers

If you are using Rails > 2.2, the helper is already locale-aware.

Just download the right localization file from the locale repository and store it into your /config/locales path. Then set your locale preferences.

like image 61
Simone Carletti Avatar answered Nov 08 '22 12:11

Simone Carletti


Avoid doing it on the server and try it on the client instead by using the jQuery timeago plugin. Timeago has support for i18n.

This turns this:

<abbr class="timeago" title="2008-07-17T09:24:17Z">July 17, 2008</abbr>

Into this:

<abbr class="timeago" title="July 17, 2008">about a year ago</abbr>

And supports language overrides.

like image 8
Ryan McGeary Avatar answered Nov 08 '22 13:11

Ryan McGeary