Reputation: 1783
I am running a site w/ English and Spanish translation files, with the English as the default.
Using translations such as:
en:
tenants:
about: "About"
to
es:
tenants:
about: "Acera"
Using
t "tenants.about"
Works without issue and reads properly from either the en.yml and es.yml files when appropriate.
However, when trying to use the human_attribute_name property to pull model attributes from another section of the spanish es.yml file, the values are not being read.
So something like
Job.human_attribute_name(:title)
Returns "title" instead of "Título".
The portion of the same es.yml file with the humanized attributes is as follows:
es:
tenants:
about: "Acerca"
activerecord:
attributes:
job:
title: "Título de la oferta de trabajo"
location: "Localización de la oferta de trabajo"
job_type: "Tipo de trabajo"
description: "Descripción"
Any insight would be appreciated.
Upvotes: 1
Views: 4915
Reputation: 1783
Wow - super annoying.
This was at the bottom of the long es.yml translation file from github: https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale
# remove these aliases after 'activemodel' and 'activerecord' namespaces are removed from
Rails repository
activemodel:
errors:
<<: *errors
activerecord:
errors:
<<: *errors
Which was overriding my activerecord: declaration at the top of the file.
Not the best location considering it's a 200+ line file, but shame on me for not reading the whole thing. Hope this helps someone.
Upvotes: 4
Reputation: 24340
I think the 'es:' is missing, or the indentation is not correct. The "
are not necessary :
es:
activerecord:
attributes:
job:
title: Título
Upvotes: -1