[RUBY] How to translate the error message into Japanese (What to do if you cannot log in for some reason)

How to translate error messages into Japanese

I can't hide my confusion about Markdown notation in my first post, but I'd like to gradually get used to it.

This time, when I tried to translate the error message into Japanese, I could not log in as a user by devise, so I would like to share how to solve it.

Development environment

Ruby 2.6.5 devise 4.7.3

I wrote the following code in each file. For some reason I got an error when I pasted the latest devise.en.yml file (ver.> = 4.2.0). Using the version below it (> = 3.4.0) solved it.

config/webpack/application.rb



module ChatDiary
  class Application < Rails::Application
    # Initialize configuration defaults for originally generated Rails version.
    config.load_defaults 6.0
    config.time_zone = 'Asia/Tokyo'
    config.i18n.default_locale = :ja
    config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}').to_s]
    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration can go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded after loading
    # the framework and any gems in your application.
  end
end

ruby:config/locales/devise.en.yml



ja:
  devise:
    confirmations:
      confirmed: 'I have registered an account.'
      send_instructions: 'We will email you within minutes about activating your account.'
      send_paranoid_instructions: "If your email address is already registered, you will receive a verification email within minutes."
    failure:
      already_authenticated: 'You are already logged in.'
      inactive: 'Your account has not been activated. Follow the steps in the email to activate your account.'
      invalid: "%{authentication_keys}Or the password is invalid."
      locked: 'Your account is frozen.'
      last_attempt: 'Multiple operations have been performed before your account was frozen.'
      not_found_in_database: "%{authentication_keys}Or the password is invalid."
      timeout: 'The session has timed out. Please log in again.'
      unauthenticated: 'Please register for an account or log in.'
      unconfirmed: 'You will need to verify your email address.'
    mailer:
      confirmation_instructions:
        subject: 'About account activation'
      reset_password_instructions:
        subject: 'About resetting password'
      unlock_instructions:
        subject: 'About unfreezing your account'
    omniauth_callbacks:
      failure: "%{kind}Failed to authenticate with your account. Reason:(%{reason})"
      success: "%{kind}You have successfully authenticated with your account."
    passwords:
      no_token: "You cannot access this page. If you are accessed from the link in the password reset email, please check the URL."
      send_instructions: 'We will email you within a few minutes to reset your password.'
      send_paranoid_instructions: "If your email address is already registered, you will receive an email to reset your password within minutes."
      updated: 'The password has been changed correctly.'
      updated_not_active: 'The password has been changed correctly.'
    registrations:
      destroyed: 'I deleted my account. We look forward to seeing you again.'
      signed_up: 'Account registration is complete.'
      signed_up_but_inactive: 'Please activate your account to log in.'
      signed_up_but_locked: 'I can't log in because my account is frozen.'
      signed_up_but_unconfirmed: 'I sent an email to verify my identity. Please activate your account from the link in the email.'
      update_needs_confirmation: 'I changed my account information. To verify the identity of the changed email address, please perform the verification process from the identity verification email.'
      updated: 'I changed my account information.'
    sessions:
      signed_in: 'You are now logged.'
      signed_out: 'logged out.'
      already_signed_out: 'You have already logged out.'
    unlocks:
      send_instructions: 'We will email you within minutes on how to unfreeze your account.'
      send_paranoid_instructions: 'If you find your account, we will email you within minutes on how to unfreeze your account.'
      unlocked: 'I have unfrozen my account.'
  errors:
    messages:
      already_confirmed: 'Is already registered. Please login.'
      confirmation_period_expired: "Has expired.%{period}You need to confirm by. Please make a new request."
      expired: 'Has expired. Please make a new request.'
      not_found: 'Was not found.'
      not_locked: 'Is not frozen.'
      not_saved:
        one: "Because an error occurred%{resource}Was not saved:"
        other: "%{count}Because an error occurred%{resource}Was not saved:"
Source code above: Go to devise's GitHub page

Reference article

Growth Engineer Blog Article

Recommended Posts

How to translate the error message into Japanese (What to do if you cannot log in for some reason)
What to do if you don't see the test code error message in the terminal console
What to do if you get the error message unrecognized selector send to instance "***"
[Rails] What to do if you can't get an error message with the errors method
What to do if you get a gcc error in Docker
What to do if you get a DISPLAY error in gym.render ()
What to do if you forget the root password in CentOS7
What to do if you cannot roll back the migration (UnknownMigrationVersionError)
[Rails] Let's translate the error message into Japanese
How to translate Rails into Japanese in general
[Rails] validates How to translate error sentences into Japanese
What to do if you can't get the text of an element in Selenium
What to do if you get the error Couldn't find Item without an ID
What to do if you cannot execute with the command "Java package name / class name"
What to do if you get a java.io.IOException in GlassFish
What to do if the adb command cannot be executed
What to do if you can't use the rails command
[Rails] What to do if you accidentally install bundle in the production environment in your local environment
What to do if you get a "Cannot Pull Container Error" when starting ECS ​​Fargate
What to do if you get a "302" error in your controller unit test code in Rails
What to do if you get an error in Basic authentication during Rails test code
[Maven] What to do if you are asked to incorporate a jar that is not in the remote repository into the war
<Dot installation> What to do if you cannot proceed due to an error when building a development environment for Rails learning.
What to do if the Rails page doesn't appear in Rails tutorial 1.3.2
What to do if Cloud9 is full in the Rails tutorial
What to do if you get a JNI shared library error when trying to build in Eclipse
What to do if you get an [An HTTP request took too long to complete.] Error in Docker.
What to do if you get a groovy warning in Thymeleaf Layout
What to do if you get an error during rails db: reset
What to do if the prefix c is not bound in JSP
[Composer] [Laravel] What to do if you cannot install due to insufficient memory
What to do if you get an error with bundle install by entering gem'bcrypt' in your Gemfile
What to do if you get an uninitialized constant Likes Controller error
What to do if you can't install the plugin from the Eclipse marketplace
What to do if you get an error saying Cannot find a valid baseurl for repo when you use yum -y install docker in a udemy course using CentOS7
What to do and how to install when an error occurs in DXRuby 1.4.7
What to do if you should have installed Rails but an error occurs with rails -v (for beginners)
What to do if the image posted by refile disappears after setting a 404 error page in Rails
What to do if you don't like the code generated by swagger-codegen-cli
What to do if Operation not permitted is displayed when you execute a command in the terminal
What to do if you get an error when you hit Heroku logs
What to do if you install Ubuntu
What to do if you get the error Too long with no output (exceeded 10m0s) on CircleCI
[Rails] How to translate devise into Japanese
How to display error messages in Japanese
What to do if the build fails with the error "Module compiled with Swift x.x.x cannot be imported by the Swift x.x.x compiler"
What to do if you get an "A server is already running." Error when you try to start the rails server
What to do if you get a javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake in the IBM JDK
What to do if you have enabled Use the WSL2 based engine in Docker Desktop with insufficient WSL2 installation
In Bean Validation, if you want to include Field Name in Error Message, it cannot be output from LocalValidatorFactoryBean.
What to do if you get a SQLite3 :: BusyException: database is locked error
What to do if you can't activate the select box created by bootstrap-select
[Java] Are you reading the error message properly? [How to read the stack trace]
What to do if the changes are not reflected in the jar manifest file
What to do if you have installed Java for OS X on macOS
What to do if you get an error on heroku rake db: migrate
What to do if you get To install the missing version, run `gem install bundler: 2.1.4`
What to do if the server tomcat dies
What to do if you push incorrect information
[Java] What to do if you get an error in Eclipse saying "Not allowed at source level below 1.X"
What to do if you get an Argument Error: wrong number of arguments (given 2, expected 0) in your RSpec test