ruby 2.5.7 Rails 5.2.4.3 OS: macOS Catalina
[Ruby on Rails] Affichage individuel des messages d'erreur Il est facile à comprendre si vous le regardez en le comparant à cet article.
Présentation de 1 gemme 2 Modifiez config / application.rb 3 Créez et modifiez config / locales / ja.yml
Gemfile
gem 'rails-i18n'
Terminal
$ bundle install
Ajout des deux lignes suivantes.
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 #← Ajouter
config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] #← Ajouter
# 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: 'adresse mail'
password: 'mot de passe'
password_confirmation: 'mot de passe(Pour confirmation)'
name: 'Nom'
Recommended Posts