TomyLee
TomyLee

Reputation: 5

Translate activerecord attributes

I saw a lot of topics on Stack but still can't find solution. I had to translate my model attribute so I followed:

Translations for Active Record Models

I want get something like this: "Pozycja nie może być puste" <= "%{attribute} %{message}

attribute => position
message => nie może być puste"

So I built this but it isn't working. How setup this interpolation?

errors:
  format: "%{attribute} %{message}"
    messages:
      blank: "nie może być puste"

activerecord:
  models:
    user: 
      attributes:
        position: "Pozycja"

Upvotes: 0

Views: 644

Answers (1)

Deepak Mahakale
Deepak Mahakale

Reputation: 23711

The keys hierarchy should be proper,

It should be like this

pl:
  errors:
    format: "%{attribute} %{message}"
      messages:
        blank: "nie może być puste"

  activerecord:
    attributes:
      user: 
        position: "Pozycja"

For more you can always refer rails en.yml

Upvotes: 1

Related Questions