Day name translation (I18n) doesn't seem to work

489 views Asked by At

I have a Rails 2.2.2 app which uses I18n v0.6.0.

I have a config/locales/da.yml file with this content:

---
da:
  date:
    abbr_day_names:
    - søn
    - man
    - tir
    - ons
    - tor
    - fre
    - lør
    abbr_month_names:
    - 
    - jan
    - feb
    - mar
    - apr
    - maj
    - jun
    - jul
    - aug
    - sep
    - okt
    - nov
    - dec
    day_names:
    - søndag
    - mandag
    - tirsdag
    - onsdag
    - torsdag
    - fredag
    - lørdag
    formats:
      default: "%d.%m.%Y"
      long: "%e. %B %Y"
      short: "%e. %b %Y"
    month_names:
    - 
    - januar
    - februar
    - marts
    - april
    - maj
    - juni
    - juli
    - august
    - september
    - oktober
    - november
    - december

So, I'm then going into the console and doing

I18n.locale = "da"
=> "da"
60.days.ago.strftime("%a %A %d %b %B %Y")
=> "Fri Friday 21 Oct October 2016"

I'd expect to get

=>  "Fre Fredag 21 Okt Oktober 2016"

It does look like I18n knows about the translation, as I can do this:

I18n.translate("date.day_names")
=> ["søndag", "mandag", "tirsdag", "onsdag", "torsdag", "fredag", "lørdag"]

But, it's just not working in strftime.

Am I misunderstanding something?

1

There are 1 answers

1
Maximilian Köstler On BEST ANSWER

Have a look at this post.

I18n.localize(some_date, :format => '%a %A %d %b %B %Y')