By using the gem called rails-i18n, error messages etc. can be translated into Japanese.
Edit application.rb.
You can set it to Japanese by setting **: ja **.
config/application.rb
module CosmeticReview
class Application < Rails::Application
config.load_defaults 6.0
#Add the following description
config.i18n.default_locale = :ja
end
end
Add the following to the gemfile. Then run bundle install with the command.
gemfile
gem 'rails-i18n'
Create a local file and create a YAML file in it for translation into Japanese. This time, the error message of the model has been translated into Japanese.
locales/ja.yml
ja:
activerecord:
attributes:
user:
nickname:nickname
gender:sex
introduce:Self-introduction
birthday:Birthday
post:
name:Product name
description:Product description
image:image
shop_name:Where to buy
evaluation:Product evaluation
price:Purchase price
category_id:Category
time:
formats:
default: "%Y/%m/%d %H:%M:%S"
Be careful as an error will occur if the hierarchy is off even a little.
https://github.com/svenfuchs/rails-i18n
Recommended Posts