--I want to replace the parts written in English such as error messages with Japanese. --When displaying DB column names and class attributes, I want to display the ones that have been replaced with Japanese in advance.
--Introduce gem's rails-i18n
--Set the word you want to convert in the ja.yml
file
--Introduce gem's rails-i18n
Gemfile
#The place to write is at the bottom of the file or group:development, group :development, :Described in a place other than test
gem 'rails-i18n'
--Install gem
--Set the ** default locale in config / application.rb
to ja **
application.rb
#↑ Codes above this are omitted
module App
class Application < Rails::Application
config.i18n.default_locale = :ja
config.time_zone = 'Tokyo'
end
end
--Create a file of config / locales / ja.yml
--In ja.yml
, describe the settings you want to convert to Japanese in yml format
Example: Characters related to DB columns → ʻactiverecord: attributes: Model name: <br /> Characters related to view →
views: resource name:`
ja.yml
ja:
activerecord:
attributes:
user:
name:username
email:Email
password:password
password_confirmation:Password confirmation)
tweet:
name:name
title:title
body:Text
comment:
name:name
comment:comment
views:
pagination:
first:the first
last:last
previous:Before
next:Next
truncate: ...
--When the settings are complete, restart the server (because it will not be reflected unless you do this)
Recommended Posts