Error to deploy in Heroku :es is not a valid locale

1.8k Views Asked by At

I have the next error and I don't know how to resolve, I'm using rails 4.1 and ruby 2.1.3 the problem is with my locale file, I have app with portuguese language for default and I translate all the file necessaries, and in my local is right no problem but when do

heroku run rake db:migrate

I have the next error:

Running rake db:migrate attached to terminal... up, run.5369 rake aborted! I18n::InvalidLocale: :es is not a valid locale /app/vendor/bundle/ruby/2.1.0/gems/i18n-0.7.0.beta1/lib/i18n.rb:284:in enforce_available_locales!' /app/vendor/bundle/ruby/2.1.0/gems/i18n-0.7.0.beta1/lib/i18n/config.rb:34:in default_locale=' /app/vendor/bundle/ruby/2.1.0/gems/i18n-0.7.0.beta1/lib/i18n.rb:35:in default_locale=' /app/config/environments/production.rb:75:inblock in '

I have a locale file and is :

I18n.load_path += Dir[Rails.root.join('lib', 'locales', '*.{rb,yml}')] I18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]

I18n.available_locales = Dir[Rails.root.join('config', 'locales', '*.{yml}')].collect {|l| locale = l.scan(/.+/(..).yml/)[0]; locale[0].to_sym unless locale.nil?}.delete_if {|locale| locale.nil?}

I18n.default_locale = [:en, :es] I18n.config.enforce_available_locales = true

also in production.rb have :

I18n.default_locale = :es

I try all the options possibles but I don't have solution Thanks for the time !!

1

There are 1 best solutions below

0
Felipe Valdivia On BEST ANSWER

the solution for this problem is really easy and you need add in your application.rb this code:

I18n.enforce_available_locales = false

Regards !