views:

24

answers:

1

I have set up a my application with spanish and english. On my console i am getting error messages in english if object is returning validation error. I want to set my rails console so i will get validation error message in spanish.

+1  A: 

This should work:

I18n.locale = 'es'
Shadwell
Getting this error.C:\projects\CyncErp>ruby script/consoleLoading development environment (Rails 2.3.8)>> I18.locale = 'es'NameError: uninitialized constant I18 from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:443:in `load_missing_constant' from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:80:in `const_missing' from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:92:in `const_missing' from (irb):1
krunal shah
You've missed the `n` off `I18n`
Shadwell
@Shadwell Now it's not returning error but still validation messages are coming in english.
krunal shah
Hmmm, okay, works for me I'm afraid so might not be able to help. For example `User.create!` after `I18n.locale = 'es'` gives me a load of missing translation messages like : `ActiveRecord::RecordInvalid: Validation failed: Password confirmation translation missing: es, activerecord, errors, models, user, attributes, password_confirmation, blank`
Shadwell
Just wondering: you have got spanish translations in your application, right? They won't magically appear unless you've provided them. There are a load of sample rails translations here: http://github.com/svenfuchs/rails-i18n/tree/master/rails/locale
Shadwell
@Shadwell Thanks. i missed some configuration.
krunal shah