DEV Community

n350071🇯🇵
n350071🇯🇵

Posted on

2 1

How to localize f.label by i18n in Rails (日本語化)

1. add two lines to config/application.rb

    config.i18n.default_locale = :ja
    config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}').to_s]

2. create new file on config/locales/

I named the file models.ja.yml.

ja:
  activerecord:
    models:
      user: ユーザー
      admin: 管理者
      medium: メディア
    attributes:
      user:
        id: ID
        email: メールアドレス
        password: パスワード
        password_confirmation: パスワードの確認
        current_password: 現在のパスワード
        remember_me: ログイン状態を記憶する
      admin:
        id: ID
      medium:
        media: メディア

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay