Rails does not permit changing locale Rails does not permit changing locale ruby-on-rails ruby-on-rails

Rails does not permit changing locale


Did you add the new locale in application.rb ?

config.i18n.enforce_available_locales = falseconfig.i18n.available_locales = [:en, :es, :de]config.i18n.default_locale = :de

You also have to create the files en.yml , es.yml and de.yml in your config/locale folder.


Thanks! When I looked in that file, I realized that in addition to the answer you gave, Rails provides it's own solution commented out -

# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]

So basically it takes a translation file such as pt-br.yml and adds that to the list of valid locales.


Make sure you have added es.yml and de.yml to the config/locales folder.