You can do:
attribute_commons: &commons
foo: "bar"
activerecord:
attributes:
category:
<<: *commons
other_attribute: "outro atributo"
product:
<<: *commons
price: "preço"
Preface: While I playing around I18n's model translation I found that
there is no way to define common attribute name translations if two or
more model has same one. I have to define attribute translation per
models.
Sven, I think that would be really nice and useful if the translations could be inheritable.
So, take this example:
pt-BR:
name: Nome
activerecord:
attributes:
user:
name: Nome
if you translated something once in a toplevel, you shouldn't need to translate it again, but you can replace it:
pt-BR:
name: Nome
activerecord:
attributes:
user:
name: Nome completo
But, if you don't want, this would be enough:
pt-BR:
name: Nome
This is quite simple:
I18n.t "activerecord.attributes.user.name" would try:
[:activerecord][:attributes][:user][:name], then, if miss:
[:activerecord][:attributes][:name], then, if miss:
[:activerecord][:name], then, if miss
[:name], and it would finally find the translation, or, if it miss:
then I18n.t would return the translation missing string
This approach would be very welcome, if you think that "name" would be used in many places of the applications, such as a lot of translations.
What do you think?
I can implement this as a plugin or as a patch if you want.
Well... I'm thinking about everything, not just activerecord things.... and I'm thinking about inheritance, not about a namespace for global translations...