My config/locales/pl.yml
file (sampled from here):
pl:
date:
day_names: [Niedziela, Poniedziałek, Wtorek, Środa, Czwartek, Piątek, Sobota]
month_names: [~, Styczeń, Luty, Marzec, Kwiecień, Maj, Czerwiec, Lipiec, Sierpień, Wrzesień, Październik, Listopad, Grudzień]
In script/console
:
I18n.locale = 'pl'
=> "pl"
Time.now.strftime("%A, %B")
=> "Tuesday, August"
Why? Or put it another way - how can I get translated month names? I'll also note that the locale file is definitely read as it includes a bunch of other translations, which all work.
That depends on which rails version you are using. There's a helper to translate that, on rails 3.0.0 (I don't know from which version it was made available).
In a view, you can write
localize Time.now, :format => '%A, %B'
in script/console (or rails console), try typing:
controller.localize Time.now, :format => '%A, %B'
and see if it works.
There's also the l
helper (lowercase L), which is a shorthand for localize
:
controller.l Time.now, :format => '%A, %B'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With