Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Month names inflection in Rails I18n

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.

like image 315
klew Avatar asked Jan 14 '11 10:01

klew


1 Answers

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
like image 172
erotte Avatar answered Sep 20 '22 16:09

erotte