Strange I18n date output with rails

前端 未结 3 758
长情又很酷
长情又很酷 2020-12-20 15:10

I\'ve got a strange problem with date translations in my Ruby On Rails 3 application, and I really don\'t understand why...

Here are my en.yml and

3条回答
  •  轮回少年
    2020-12-20 15:26

    Type in your console

    I18n.t(:"date") 
    

    to check if you are getting the translations you defined in your translation .yml file.

    Compare the structure with the standard EN locale

    I18n.t(:"date", locale:'en')
    

    That made me notice I was declaring the date: attribute twice in my .yml, and the first part was being overwritten by the second declaration.

    You should get the abbr_month_names that you declared when calling

    I18n.t(:"date.abbr_month_names")
    

    These are the ones that will be used when calling %b.

    If not, check your locale .yml file to make sure they are properly declared, and not being declared twice.

    You may also call I18n.locale to check if the .yml file you are editing is the one being used by rails

提交回复
热议问题