Common attributes translations with activerecord_i18n_defaults

The plugin activerecord_i18n_defaults lets you write locale’s files in a Rails 2.2 application like this:

pt-BR:
  activerecord:
    attributes:
      _all:
        login: "Identificação"
        name: "Nome"
      admin:
        age: "Idade"
      customer:
        nickname: "Apelido"
      user:
        email: "Endereço de e-mail"

instead of like this:

pt-BR:
  activerecord:
    attributes:
      admin:
        login: "Identificação"
        name: "Nome"
        age: "Idade"
      customer:
        login: "Identificação"
        name: "Nome"
        nickname: "Apelido"
      user:
        login: "Identificação"
        name: "Nome"
        email: "Endereço de e-mail"

Next time you need to create a locale’s file put your common attributes in the key _all and DRY.

If you like this plugin please consider to recommend me at Working With Rails.

2 thoughts on “Common attributes translations with activerecord_i18n_defaults

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">