# Distance\_of\_time\_in\_words hardcoded strings should be separa

**URL:** <https://www.ruby-forum.com/t/distance-of-time-in-words-hardcoded-strings-should-be-separa/114894>\
**Category:** Rails\
**Created:** [September 18, 2007, 4:51pm UTC](https://www.ruby-forum.com/t/distance-of-time-in-words-hardcoded-strings-should-be-separa/114894 "2007-09-18T16:51:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jesper\_RSSSSnn-Jens](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/96bed5/32.png) [@Jesper\_RSSSSnn-Jens](https://www.ruby-forum.com/u/Jesper_RSSSSnn-Jens)\
**Post date:** [September 18, 2007, 4:51pm UTC](https://www.ruby-forum.com/t/distance-of-time-in-words-hardcoded-strings-should-be-separa/114894/1 "2007-09-18T16:51:31Z")

</div>

Hi everybody.  
After DHHs talk at RailsConf yesterday, it’s essential that some of  
you can rectify this patch for ruby on Rails

Please help me an have a look at

[http://dev.rubyonrails.org/ticket/9587](http://dev.rubyonrails.org/ticket/9587)  
Thanks!

Jesper Rønn-Jensen  
blog: www.justaddwater.dk

=====  
ActiveRecord::Errors has a placeholder (@@default\_error\_messages) for  
messages that can be overridden.

Just the same way, the hardcoded time strings should be easily  
overridden without breaking or re-implementing the logic in  
distance\_of\_time\_in\_words.

This patch creates a new placeholder for the hardcoded strings:

@@time\_messages = {  
:less\_than\_x\_seconds =\> “less than %d seconds”,  
:half\_a\_minute =\> “half a minute”,  
…  
}

Now you are able to overwrite with

Helpers::DateHelpers::time\_messages[:less\_than\_x\_seconds] = “an  
instant”

or similar. I also added some lines of documentation for overriding,  
as well as ran the tests which pass.

Please

```
a) verify that this works for you

b) vote +1 for it

c) try it out in your environment

```
