oyvindhauge
oyvindhauge

Reputation: 3693

translating activerecord model attributes in rails

I'm trying to translate my model attributes when form errors are shown. The error itself is translated correctly, however, the attribute with the error is not.

in my nb.yml locale I have written:

  activerecord:
    attributes:
      book:
        price: "pris"

Example output: Price er for kort (minimum 0 tegn)

Am using this locale: https://github.com/svenfuchs/rails-i18n/blob/master/rails/locale/nb.yml

Upvotes: 1

Views: 1488

Answers (1)

raviolicode
raviolicode

Reputation: 2175

I noticed two things that could be the cause of your issue:

1) From Rails guides, you should add the id of the language before active record (I don't know if you have it or not...) like this:

nb:
  activerecord:
    attributes:
      book:
        price: "Pris"

2) Did you remove the aliases after line 201 from nb.yml from rails-i18n?

See this issue on SO.

Hope this helps!

Upvotes: 2

Related Questions