I am building a site in rails and I have a date selector with a drop down menu that Rails generate automatically. The problem is that my site is in spanish and the values of the dropdown for the months are in English, is there a way to change the language to spanish?
I tried adding some lines of codes to the config/environment.rb that I found here
The code is basically this:
require 'date'
class Date
MONTHNAMES = [nil] + %w(Enero Febrero Marzo Abril Mayo Junio Julio Agosto Septiembre Octubre Noviembre Diciembre)
module Format
MONTHS = {
'Enero' => 1, 'Febrero' => 2, 'Marzo' => 3, 'Abril' => 4,
'Mayo' => 5, 'Junio' => 6, 'Julio' => 7, 'Agosto' => 8,
'Septiembre'=> 9, 'Octubre' =>10, 'Noviembre' =>11, 'Diciembre'=>12
}
end
end
But nothing changed after I fired up the server again.
I hope you can help me, thanks in advance.
From the documentation:
So you can either do this:
Or, for bones internationalisation points, replace the strings with
t()method calls and use Rails’s I18n localisation files:In
config/locales/es.ymlAnd then in
config/application.rbset:Bingo! 🙂