开发者

Rails 2.3.5 I18n month/day name translation problem

My config/locales/pl.yml file (sampled from here):

pl:
  date:
    day_names: [Niedziela, Poniedz开发者_如何学JAVAiał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 lhelper (lowercase L), which is a shorthand for localize:

controller.l Time.now, :format => '%A, %B'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜