开发者

My locale is set, I can see € instead of $, but time still displays English months

开发者 https://www.devze.com 2023-04-08 02:27 出处:网络
I am doing a Rails app in French. I downloaded a fr.yml stored in config/locales and added config.i18n.default_locale = :fr to my application.rb. The .yml contains days and month开发者_如何学运维s.

I am doing a Rails app in French. I downloaded a fr.yml stored in config/locales and added config.i18n.default_locale = :fr to my application.rb. The .yml contains days and month开发者_如何学运维s.

Messages in pages generated by scaffold are in French, € is displayed instead of $, but it keep using English names for months with strftime (a Time function).

Why?


<%= I18n.localize(Time.zone.now, :format => :short) %>

You can add more formats to your fr.yml

  date:
    formats:
      default: "%d.%m.%Y"
      numeric: "%d.%m.%Y"
      short: "%e %b"
      long: "%e %B %Y, %A"
      only_day: "%e"


The strftime function isn't hooked into Rails - it's just a member of the Ruby Time class. Try using Rails localization instead - that should do what you're expecting.

Hope that helps!

0

精彩评论

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