Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails does not permit changing locale

I'm trying to change the locale that my rails (4.1.4) application is using, but every time I try to change it in the console using commands such as

I18n.locale = :es
I18n.default_locale = :de

an I18n::InvalidLocale error is brought up. This is the case for every locale I test, including regional ones such as :en-US. This is true even if I have a *.yml file set up for that locale. The only one that works is :en, which is the default for me.

I feel like this should be something pretty basic as all the resources I find seem to skip past this as a given, but it's not working for me and I can't figure out where to look for the problem source.

like image 346
Anrothan Avatar asked Jul 10 '14 23:07

Anrothan


1 Answers

Did you add the new locale in application.rb ?

config.i18n.enforce_available_locales = false
config.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.

like image 169
Mkou Avatar answered Sep 25 '22 12:09

Mkou