[Rails] How to translate devise into Japanese

Development environment

・ Ruby: 2.5.7 Rails: 5.2.4 ・ Vagrant: 2.2.7 -VirtualBox: 6.1 ・ OS: macOS Catalina

Premise

The following has been implemented.

-Login function implementation

Implementation

1. Introduce Gem

Gemfile


#Postscript
gem 'devise-i18n'

2. Edit ʻapplication.rb`

application.rb


module Bookers2Debug
  class Application < Rails::Application
    config.load_defaults 5.2
    config.i18n.default_locale = :ja #Postscript
  end
end

Create and edit the devise.ja.yml file

$ touch config/locales/devise.ja.yml

yml:devise.ja.yml


ja:
  activerecord:
    errors:
      models:
        user:
          attributes:
            email:
              taken: "Is already in use."
              blank: "Is not entered."
              too_short: "Is%{count}Please set more than characters."
              too_long: "Is%{count}Please set it below the character."
              invalid: "Is not valid."
            password:
              taken: "Is already in use."
              blank: "Is not entered."
              too_short: "Is%{count}Please set more than characters."
              too_long: "Is%{count}Please set it below the character."
              invalid: "Is not valid."
              confirmation: "Does not match the content."
    attributes:
      user:
        current_password: "Current password"
        name:name
        email: "mail address"
        password: "password"
        password_confirmation: "Confirmation password"
        remember_me: "login automatically from now on"
        name:Full name
        sex:sex
        postcode:Postal code
        prefecture_code:Prefectures
        address_city:Municipality
        address_street:address
        address_building:Building name
    models:
      user: "user"
  devise:
    confirmations:
      new:
        resend_confirmation_instructions: "Resend account confirmation email"
    mailer:
      confirmation_instructions:
        action: "Account confirmation"
        greeting: "Welcome,%{recipient}Mr.!"
        instruction: "The following link will complete the confirmation of your email address:"
      reset_password_instructions:
        action: "Change Password"
        greeting: "Hello,%{recipient}Mr.!"
        instruction: "Someone wants to reset my password. You can reset your password at the following link."
        instruction_2: "Ignore this email if you didn't want it."
        instruction_3: "Your password will not change until you access the link above and set a new password."
      unlock_instructions:
        action: "Account unlock"
        greeting: "Hello,%{recipient}Mr.!"
        instruction: "Click the link below to unlock your account."
        message: "Your account is locked due to repeated login failures."
    passwords:
      edit:
        change_my_password: "change the password"
        change_your_password: "Change password"
        confirm_new_password: "New password for confirmation"
        new_password: "new password"
      new:
        forgot_your_password: "Did you forget your password??"
        send_me_reset_password_instructions: "Send how to reset your password"
    registrations:
      edit:
        are_you_sure: "Is it really good?"
        cancel_my_account: "Account deletion"
        currently_waiting_confirmation_for_email: "%{email}Waiting for confirmation"
        leave_blank_if_you_don_t_want_to_change_it: "If left blank, do not change"
        title: "%{resource}Edit"
        unhappy: "I don't like it"
        update: "update"
        we_need_your_current_password_to_confirm_your_changes: "Please enter your current password for the changes to take effect"
      new:
        sign_up: "account registration"
    sessions:
      new:
        sign_in: "Login"
    shared:
      links:
        back: "Return"
        didn_t_receive_confirmation_instructions: "Did you receive an account confirmation email??"
        didn_t_receive_unlock_instructions: "Have you received an email on how to unfreeze your account??"
        forgot_your_password: "Did you forget your password??"
        sign_in: "Login"
        sign_in_with_provider: "%{provider}Login with"
        sign_up: "account registration"
    unlocks:
      new:
        resend_unlock_instructions: "Resend account unfreeze method"

Recommended Posts

[Rails] How to translate devise into Japanese
How to translate Rails into Japanese in general
[Rails] validates How to translate error sentences into Japanese
[Rails] How to install devise
[Rails] How to use devise (Note)
[Rails] How to write in Japanese
[Note] How to use Rails 6 Devise + cancancan
How to translate enum into Japanese and generate linked radio buttons
How to write Rails
How to uninstall Rails
[Rails] Let's translate the error message into Japanese
[Rails] How to use Gem'rails-i18n' for Japanese support
[Rails] How to convert UC time display to Japanese time display
[rails] How to post images
[Ruby on Rails] How to write enum in Japanese
[rails] How to use devise helper method before_action: authenticate_user!
[Rails] How to use enum
[Rails] How to use enum
How to read rails routes
How to use rails join
[Rails] Add column to devise
How to terminate rails server
How to write Rails validation
How to write Rails seed
[Rails] How to use validation
[Rails] How to edit and customize devise view and controller
[Rails] How to disable turbolinks
[Rails] How to use authenticate_user!
[Rails] How to use "kaminari"
[Rails] How to implement scraping
How to write Rails routing
[Rails] How to install simple_calendar
[Rails] How to install reCAPTCHA
[Rails] How to use Scope
[Rails] How to delete images uploaded by carrierwave (using devise)
Super easy in 2 steps! How to install devise! !! (rails 5 version)
[Rails] How to install Font Awesome
[Rails] How to prevent screen transition
How to use Ruby on Rails
How to deploy Bootstrap on Rails
[Rails] How to speed up docker-compose
[Rails] How to add new pages
Rails on Tiles (how to write)
[Rails] How to write exception handling?
[Rails] How to install ImageMagick (RMajick)
[Rails] How to install Font Awesome
[Rails] How to use Active Storage
[Rails] Add strong parameters to devise
How to introduce jQuery in Rails 6
[Rails] How to implement star rating
How to return Rails API mode to Rails
How to get along with Rails
[Introduction to Rails] How to use render
How to install Swiper in Rails
[Rails] devise
[Ruby on Rails] How to avoid creating unnecessary routes for devise
[Rails 5] How to display the password change screen when using devise
How to implement search functionality in Rails
How to change app name in rails
How to use custom helpers in rails
[Ruby on Rails] How to use CarrierWave