ruby - rails generate set default locale -


i need set default locale spanish on application.

these lines of file application.rb:

  class application < rails::application     # settings in config/environments/* take precedence on specified here.     # application configuration should go files in config/initializers     # -- .rb files in directory automatically loaded.      # set time.zone default specified zone , make active record auto-convert zone.     # run "rake -d time" list of tasks finding time zone names. default utc.     # config.time_zone = 'central time (us & canada)'      # default locale :en , translations config/locales/*.rb,yml auto loaded.     config.i18n.load_path += dir[rails.root.join('config', 'locales', '**', '*.{rb,yml}')]     rails.application.config.i18n.default_locale = :es    end 

but, when generate scaffold inflection wrong. it´s english locale.

rails g scaffold preparado nombre:string

i wrong plural: preparadoes, must be: preparados.

on console tried this:

irb(main):015:0> i18n.locale = 'es' => "es" irb(main):016:0> 'preparado'.pluralize() => "preparadoes" irb(main):017:0> 'preparado'.pluralize(:es) => "preparados" irb(main):018:0> 

my gemfile contains:

gem 'inflections' 

in summary, need create scaffold correct pluralization.

sorry english. know ´s not best.

thanks.

i18n not affect pluralization here, rails uses inflections it, , there 1 method know customize it:

activesupport::inflector.inflections |inflect|     inflect.irregular 'preparado', 'preparados'  end 

to config/initializers/inflections.rb

there spanish locale #pluralize, need set explicitly every time call it. , generator calls without parameters.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -