LoginSignup
114
129

More than 5 years have passed since last update.

railsの日本語化 deviseの日本語化

Last updated at Posted at 2015-04-09

Railsの日本語対応

以下を参考に日本語化する。
Railsで日本語化対応にする方法
http://qiita.com/kusu_tweet/items/b534c808ac1ee0382f05

deviseの日本語化 

github
https://gist.github.com/yhara/606476
から
devise.ja.ymlをダウンロードし、/config/localesに入れる。

追記:
以下のURL内のdevise.ja.ymlのほうが良かった。
http://qiita.com/MasatoYoshioka@github/items/8d910e793e7c485403bb

deviseのエラーメッセージのカスタマイズ

railsでdeviseプラグイン使用時、エラーメッセージを日本語化する
http://gaku3601.hatenablog.com/entry/2014/10/04/185947
を参考にして

taken: "は既に使用されています。"
blank: "が入力されていません。"
too_short: "は%{count}文字以上に設定して下さい。"
too_long: "は%{count}文字以下に設定して下さい。"
invalid: "は有効でありません。"
confirmation: "が内容とあっていません。"

をdevise.ja.ymlの下部に加える

fields_for周りの日本語化

ここは必要に応じて。

下記のような記述をja.ymlの下部に入れる。
userの部分はテーブル、name以下の部分はフィールドに該当する。
activerecordのつけ忘れに注意。

ja:
  activerecord:
    attributes:
      user:
        name: 名前
        password: パスワード
        password_confirmation: パスワード確認
        email: メールアドレス

日本語化を反映させる

下記を追記。
(これ忘れると日本語されないので念のため)

config/application.rb
# config.i18n.default_locale = :de のコメントアウトがあるのでこれを利用すればよい
config.i18n.default_locale = :ja
114
129
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
114
129