Month names inflection in Rails I18n

klew picture klew · Jan 14, 2011 · Viewed 11.8k times · Source

I would like to use different case of month name in Polish. For example now it works like this:

>> I18n.l Time.now, :format => "%e %B"
=> "14 styczeń"

but I would like to specify another format of month:

>> I18n.l Time.now, :format => "%e %Q"
=> "14 stycznia"

Translated month names are in my pl.yml file in pl.date.month_names. And I don't want to change it. I can add pl.date.another_month_names in the other case, but I don't know how to make I18n.l method to use it.

So how can I achive that? Other solutions (helpers, custom methods etc.) are also welcome.

Answer

erotte picture erotte · Feb 11, 2013

i had a similar problem with strange month names in german translation. I had to configure the month names in my locale.yml, now it works as expected:

de:
  defaults: &defaults
    month_names:
      [~, Januar, Februar, März, April, Mai, Juni, Juli, August, September, Oktober, November, Dezember]
    formats:
       default: "%d. %B %Y"
       short: "%d.%m.%Y"
  date:
    <<: *defaults
  time:
    <<: *defaults