Rails error messages cannot be translated into Japanese

phenomenon

The file that describes the Japanese translation of the column name did not work well because the error message was translated into Japanese.

Solutions

Once I arranged the spacing of the description, it worked. I was able to learn anew that there are other things that do not work with spacing other than typographical errors.

config/locales/models/ja.yml


  #It doesn't work well unless the hierarchical structure is represented by spacing
  ja:
    activerecord:
      models:
        event:Event
      attributes:
        event:
          name:event name
          place:Venue
          content:Event content

Procedure for translating error messages into Japanese

Install the gem "rails-i18n"

Gemfile


gem 'rails-i18n'

↓ bundle install ↓ Edit the description of config/application.rb

config/application.rb


config.i18n.default_locale = :ja

Now you can translate it into Japanese. However, the column names are still written in English, so (Example) Please enter an email I get an error message like this.

Write the column name translated into Japanese

Create a file called "ja.yml" in config/locales/models /. Describe the Japanese corresponding to the column name in the created file.

config/locales/models/ja.yml


  #It doesn't work well unless the hierarchical structure is represented by spacing
  ja:
    activerecord:
      models:
        event:Event
      attributes:
        event:
          name:event name
          place:Venue
          content:Event content

References

Japanese localization of Rails validation error message

Recommended Posts

Rails error messages cannot be translated into Japanese
[Rails] Japanese localization of error messages
Japanese localization of error messages (rails)
[Rails] Let's translate the error message into Japanese
[Rails] validates How to translate error sentences into Japanese
Japanese localization of error messages
Japanese localization of error messages
Translated JPA 2.2 JavaDoc into Japanese
Spring-security error message cannot be changed
[Rails] Display form error messages asynchronously
[Rails 6] MySQL 2 cannot be bundle install
[Rails] Posts cannot be deleted when commented! ??
Rails g devise: install cannot be executed!
[Rails] How to display error messages individually
Testing for Error Messages: Rails Tutorial Notes-Chapter 7
Rails server cannot be started in Cloud9
[Rails] How to translate devise into Japanese
How to display error messages in Japanese
RubyOnRails, Authentication plugin'caching_sha2_password' cannot be loaded error solution
The road to Japaneseizing Rails devise error messages
[Ruby on Rails] How to display error messages
[Rails 6] method :: delete cannot be used with link_to
Rails: Japanese localization of validation messages including devise
How to translate Rails into Japanese in general
[Rails] Japanese localization of validation error message ~ ja.yml ~
Introduction of Rspec and Japanese localization of error messages
Convert error messages to Japanese Supports multiple tables
[Rails] How to get success and error messages
[Ruby on Rails] Individual display of error messages
Rails must be exist error (@save is not executed)
Japaneseization of Rails error messages [devise / Form objects, etc.]