ruby 2.5.7 Rails 5.2.4.3 OS: macOS Catalina
[Ruby on Rails] Individual display of error messages It is easy to understand if you look at it while comparing it with this article.
Introduction of 1 gem 2 Edit config / application.rb 3 Create and edit config / locales / ja.yml
Gemfile
gem 'rails-i18n'
Terminal
$ bundle install
Added the following two lines.
config/application.rb
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.2
config.i18n.default_locale = :ja #← Add
config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] #← Add
# Settings in config/environments/* take precedence over those specified here.
# Application configuration can go into files in config/initializers
# -- all .rb files in that directory are automatically loaded after loading
# the framework and any gems in your application.
end
config/locales/ja.yml
config/locales/ja.yml
ja:
activerecord:
attributes:
user:
email: 'mail address'
password: 'password'
password_confirmation: 'password(For confirmation)'
name: 'name'
Recommended Posts