# Localizing dates

**URL:** <https://www.ruby-forum.com/t/localizing-dates/193833>\
**Category:** Rails I18n\
**Created:** [August 25, 2010, 10:00am UTC](https://www.ruby-forum.com/t/localizing-dates/193833 "2010-08-25T10:00:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![marmolin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/71e660/32.png) [@marmolin](https://www.ruby-forum.com/u/marmolin)\
**Post date:** [August 25, 2010, 10:00am UTC](https://www.ruby-forum.com/t/localizing-dates/193833/1 "2010-08-25T10:00:12Z")

</div>

Hi

How to localize the different methods in e.g. Date ?

Tries to use Date.parse(str) with str in any language.  
I have a fix for my current problem, where str is a swedish date of  
the form 12 MAJ 1983; Date.parse(str.gsub(‘MAJ’,‘MAY’),  
but is there a more generic solution?

How to use the different localzed date format as e.g  
date.abbr\_month\_names ?  
Tried I18n.l(Date.today) and  
I18n.l(Date.today.strftime("%d %b %Y")) and  
I18n.l(y.wday).to\_s and  
I18n.l(y).wday  
but without any success !!

The problem is that I do not understand this part of I18n and the  
guides give no information about the more complex use of localize?

Would appreciate any help

---

<div class="post-metadata">

**Author:** ![marmolin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/71e660/32.png) [@marmolin](https://www.ruby-forum.com/u/marmolin)\
**Post date:** [August 25, 2010, 10:48am UTC](https://www.ruby-forum.com/t/localizing-dates/193833/2 "2010-08-25T10:48:12Z")

</div>

Hi Hans,

you could use my delocalize plugin for that:  
[GitHub - clemens/delocalize: Date/time and number parsing for Rails. · GitHub](http://github.com/clemens/delocalize).

- Clemens

On Aug 25, 2010, at 9:59 AM, Hans M. wrote:

> I18n.l(Date.today.strftime(“%d %b %Y”)) and  
> Phone: +46708371202  
> To unsubscribe from this group, send email to [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid).  
> For more options, visit this group at [http://groups.google.com/group/rails-i18n?hl=en](http://groups.google.com/group/rails-i18n?hl=en).

Clemens K.

> **[railway.at](http://www.railway.at)**

[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

railway - welcome aboard!

---

<div class="post-metadata">

**Author:** ![marmolin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/71e660/32.png) [@marmolin](https://www.ruby-forum.com/u/marmolin)\
**Post date:** [August 25, 2010, 5:49pm UTC](https://www.ruby-forum.com/t/localizing-dates/193833/3 "2010-08-25T17:49:44Z")

</div>

For the second question:

You pass the :format parameter, like this:

I18n.l(Date.today, :format =\> :long)

The default available formats are :default, :short and :long but you can  
add  
more to your locale file:

> <https://github.com/svenfuchs/rails-i18n/blob/master/rails/locale/sv-SE.yml#L164>

---

<div class="post-metadata">

**Author:** ![marmolin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/71e660/32.png) [@marmolin](https://www.ruby-forum.com/u/marmolin)\
**Post date:** [August 25, 2010, 6:00pm UTC](https://www.ruby-forum.com/t/localizing-dates/193833/4 "2010-08-25T18:00:17Z")

</div>

Thanks Clemens  
It solved all my problems! Just what I needed.  
However the plugin should be listed in the i18n guide

Next I need a plugin for inverse translations if existing ?  
There is some suggestions in earlier discussion of this problem, but  
as Sven remarked – these solutions are really hacks  
Any news regarding this problem

* * *

Hans M.  
St: Larsgatan 50, 58224 Linköping, Sweden  
Phone: +46708371202

25 aug 2010 kl. 10.47 skrev Clemens K.:

---

<div class="post-metadata">

**Author:** ![marmolin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/71e660/32.png) [@marmolin](https://www.ruby-forum.com/u/marmolin)\
**Post date:** [August 25, 2010, 6:03pm UTC](https://www.ruby-forum.com/t/localizing-dates/193833/5 "2010-08-25T18:03:48Z")

</div>

Hi MejÃ­a Â¨  
Thanks for the suggestions. I now think that I understand this area  
better

Regarding Mitchell question  
A also use separate html files for longer texts (more than one sentence)

* * *

Hans M.  
St: Larsgatan 50, 58224 LinkÃ¶ping, Sweden  
Phone: +46708371202

25 aug 2010 kl. 17.48 skrev AndrÃ©s MejÃ­a:
