Switch only view to Japanese display
■ Improvement of UI ■ Because it is in Japanese, readability is improved and development efficiency is improved.
■ Mac OS catalina ■ Ruby on Rails (5.2.4.2) ■ Virtual Box:6.1 ■ Vagrant: 2.2.7
mac.terminal
$ rails new japoanese
$ rails g controller homes index
$ cd config/locale
$ touch ja.yml
gemfile.add to
gem 'rails-i18n', '~> 5.1'
routes.rb
root 'homes#index'
locale/ja.yml
ja:
homes:
index:
title: 'Title'
name:'name'
text:‘Sentence’
##The writing style changes a little when the model is related. It looks like the following. .. ..
activerecord:
models:
user: "user"
attributes:
user:
name: "name"
age: "age"
*** The following important **
config/application.rb
config.i18n.default_locale = :ja #add to
homes/index.htmnl.erb
<h2><%= t '.title'%></h2>
<h2><%= t '.name'%></h2>
<h2><%= t '.text'%></h2>
that's all! !!
■ More detailed articles https://qiita.com/shimadama/items/7e5c3d75c9a9f51abdd5
■ Error message https://qiita.com/tanaka-yu3/items/63b189d3f15653cae263
■ rails method for beginners https://qiita.com/tanaka-yu3/items/89abad875187494bec53
Recommended Posts