21
16

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rails5のdefault localeをjaに設定する

Posted at

以前までは config/application.rb にデフォルトの設定を書いていましたが、initializers/locale.rb に書くようになったみたいです。

ただ普通にI18n.default_locale = :jaと書くだけだと

I18n::InvalidLocale:
  :ja is not a valid locale
# ./config/initializers/locale.rb:2:in `<top (required)>'
# ./config/environment.rb:5:in `<top (required)>'

と怒られてしまうので

config/initializers/locale.rb
I18n.config.available_locales = :ja
I18n.default_locale = :ja

として、利用可能なlocaleを明示する必要があります。

21
16
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
21
16

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?