LoginSignup
11
3

More than 5 years have passed since last update.

[Rails5]rails,deviseを日本語化する為に。そして躓いた事。

Last updated at Posted at 2018-07-02

Rails,deviseを日本語化する為に
Rails で I18n を使って日本語化
Railsで日本語化対応にする方法
railsの日本語化 deviseの日本語化
を参考にすすめていく。
すると/config/application.rbをデフォルトだと、:de でコメントアウトされているので、:jaに変更してアンコメント
/config/application.rb
config.i18n.default_locale = :ja

と書いてるが、ファイルを見るとそもそもない。だから新たに書き込んでサーバー起動するとエラーが。エラー内容は、config/application.rb:10:in ': undefined local variable or method `config' for main:Object (NameError)

解決方法

下のような位置に書くと解決しました。

module ScoutMe
  class Application < Rails::Application
    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration should go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded.

    #Railsを日本語化する為に
      config.i18n.default_locale = :ja 
      config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}').to_s]
  end
end
11
3
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
11
3