[RUBY] Japanese localization of error messages (rails)

rails-i18n(Gem) A Gem that can handle Japanese.

locale file

A file required to translate all error messages into Japanese, and a file that can be used in various languages. By creating a file for Japanese localization in this, you can translate English into Japanese.

Implementation method

① Japanese language setting

config/application.rb



require_relative 'boot'

require 'rails/all'

Bundler.require(*Rails.groups)

module Asakatu5757
  class Application < Rails::Application
    config.load_defaults 6.0
    config.i18n.default_locale = :ja

    config.time_zone = 'Tokyo'
  end
end

The description added this time is "** config.i18n.default_locale =: ja **", and it can be made into the standard language Japanese.

② Introduction of rails-i18n

Gemfile


gem 'rails-i18n'

Terminal


% bundle install

③ Create a file for Japanese localization in locales and edit it.

Example) When the nickname column of the User model is translated into Japanese.

config/locales/ja.yml


ja:
 activerecord:
   attributes:
     user:
       nickname:nickname

Recommended Posts

[Rails] Japanese localization of error messages
Japanese localization of error messages (rails)
Japanese localization of error messages
Rails: Japanese localization of validation messages including devise
Introduction of Rspec and Japanese localization of error messages
[Rails] Japanese localization of error message when using Form object
Japanese localization of Ubuntu20.04
Japanese localization of Eclipse
Rails error messages cannot be translated into Japanese
[Ruby on Rails] Individual display of error messages
[Rails] Japanese localization using rails-i18n
[Japanese localization of gem: devise]
Japaneseization of Rails error messages [devise / Form objects, etc.]
From Ruby on Rails error message display to Japanese localization
[Rails] Validation settings and Japanese localization
Animated display of Swift error messages
[Rails] How to display error messages individually
Japanese localization of CentOS 8 and Japanese keyboard layout
[Ruby on Rails] Japanese notation of errors
How to display error messages in Japanese
The road to Japaneseizing Rails devise error messages
[Ruby on Rails] How to display error messages
[Rails] Let's translate the error message into Japanese
[Japanese localization] i18n rails Easy Japanese localization view display only
Convert error messages to Japanese Supports multiple tables
[Rails] How to get success and error messages
[Note] Rails error list
About Ruby error messages
Implementation of flash messages
One case of solving a migration error in Rails
Catch Rails Routing Error
[Rails] Introduction of PAY.JP
[Rails error] unexpected tIDENTIFIER
Mac Rails Install Error
Rails Tutorial/Significance of Indexing
[Rails] validates How to translate error sentences into Japanese
rails heroku error log
rails error resolution summary
[Rails] Create initial data with seed.rb [Faker] [Japanese localization]
[Note] Error message when using Rails Form object pattern Japanese
I made a Japanese version of Rails / devise automatic email
[Rails] Workaround for classes automatically generated by devise error messages
Japanese localization of Docker container of CentOS7 / CentOS8 and Japan time setting
[Rails] How to display error messages for comment function (for beginners)
Rails implementation of ajax removal
[Rails] Introduction of devise Basics
Cleansing processing of Japanese sentences
[Rails] Japanese longest surname (validation)
rails error Library not loaded
Utilization of Rails Boolean type
[Rails 6] Implementation of search function
[Rails] Implementation of category function
Error in rails db: migrate
Display Flash messages in Rails
[Rails] Rails version upgrade error memorandum
Error when using rails capybara
[Rails] Implementation of tutorial function
[Rails] Creation of the second vertical axis and Japanese localization in graph drawing using amCharts4, etc.
[Rails] Implementation of like function
[rails] error during devise installation
Summary of java error processing