Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Localize month names - Calendar Railscasts #213

i'm try tutorial calendar from railscasts episode #213. i have add es.yml but not worked. i try localize month names with replace word on en.yml such as

en:
  date:

    month_names: [~, Enero, Febrero, Marzo, Abril, Mayo, Junio, Julio, Agosto, Septiembre, Octubre, Noviembre, Diciembre]
    abbr_month_names: [~, Ene, Feb, Mar, Abr, May, Jun, Jul, Ago, Sep, Oct, Nov, Dic]

not working too

on html.erb

<h2 id="month"><%= @date.strftime("%B %Y") %></h2>

i want change this

enter image description here

anyone help me?

thank's

like image 786
GeekToL Avatar asked Dec 14 '12 17:12

GeekToL


1 Answers

You should use the localize method of I18n (shortened as l):

<h2 id="month"><%= l(@date) %></h2>

Then you can set different formats on your own: http://guides.rubyonrails.org/i18n.html#adding-date-time-formats

# config/locales/es.yml
es:
  date:
    formats:
      short: "%B %Y"
      default: "%D %m, %Y"

And use it like this:

<h2 id="month"><%= l(@date, format: :short) %></h2>
like image 101
MrYoshiji Avatar answered Nov 11 '22 15:11

MrYoshiji