Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I specify shared attributes translations between models in I18n locale file?

I tried the following:

es:
  activerecord:
    attributes:
      name: Nombre

And it did not work.

But the following do work:

es:
  activerecord:
    attributes:
      person:
        name: Nombre

Which is the correct way to define default attributes across models?

Also I'm using Formtastic and Active Admin.

like image 228
Zequez Avatar asked Oct 14 '11 05:10

Zequez


2 Answers

Move the common attributes up one level:

es:
  attributes:
    name: Nombre
  activerecord:
    attributes:
      user:
        birthday: Etc

Example

like image 168
Halil Özgür Avatar answered Sep 19 '22 00:09

Halil Özgür


this is how im doing. Not perfect but will do the job.

activerecord:
  attributes:
    attribute_commons: &commons
      name: Nome
      description: Descrição
    user:
      <<: *commons
    role:
      <<: *commons
      level: Nível
    product:
      <<: *commons
      size: Tamanho
like image 26
Warley Noleto Avatar answered Sep 20 '22 00:09

Warley Noleto