LoginSignup
2
0

More than 5 years have passed since last update.

railsでi18nを使う

Posted at

日本語に設定

config/application.rb
config.i18n.default_locale = :ja

モデル関連

hoge.yml
ja:
  activerecord:
    models:
      hoge: ほげ
    attributes:
      hoge:
        huga: ふが
hoge.html.haml
= Hoge.model_name.human # => ほげ
= Hoge.human_attribute_name(:huga) # => ふが

その他

foo.yml
ja:
  label:
    foo: ふー
  messages:
    bar: ばー
foo.html.haml
= t('label.foo') # => ふー
= t('messages.bar') # => ばー
2
0
0

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
2
0