--Install gem'rails-i18n' --Addition of description to config / application.rb --Create and describe files under config / locales
Add the following Gem to Gemfile
. (It will be used in both production and development environments, so let's write it at the bottom.)
Gemfile
gem 'rails-i18n'
Terminal
bundle install
Open config / application.rb
and add the two lines that say Add.
module application name
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 6.0
config.i18n.default_locale = :ja #add to
config.time_zone = 'Tokyo' #add to
#Omission
Next, let's create a file called ja.yml
under config / locales
.
Write as follows there.
ja:
time:
formats:
default: "%Y/%m/%d %H:%M:%S"
This should have changed to the Japanese time notation.
I think it is displayed like this.
Y is Year, m is month, d is day, and so on. If you want to change the notation, you can rewrite the default of ja.yml
, so please rewrite it to the form you want to display.
Recommended Posts