Shuffling Month Names in Rails I18n

I would like to use different month names in Polish. For example, it now works as follows:

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

but I would like to specify a different format for the month:

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

The names of the translated months are in my pl.yml file in pl.date.month_names. And I do not want to change it. I can add pl.date.another_month_namesin another case, but I do not know how to make a method I18n.lto use it.

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

+5
source share
2 answers

Since no one answered my question, I found one solution.

, alt_pl.yml, , :

>> I18n.l Time.now, :format => "%e %Q", :locale => :alt_pl
=> "15 stycznia"
+5

. locale.yml, , :

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
+3

All Articles