0

I'm trying to work out how to structure my en.yml file, and it doesn't seem to be working as expected. With a structure like this:

en:
  activerecord:
    attributes:
      user: 
        first_name: "First name"

It works fine, referencing the first name either with :first_name, or <%=t 'activerecord.attributes.user.first_name' %>. I also have common text in the same file like 'Yes' and 'No' for boolean fields. Why can't I create a lang file like this:

en:
  globals:
    yes: "Yes"
    no: "No"
  activerecord:
    attributes:
      user: 
        first_name: "First name"

And then reference them with <%=t 'globals.yes' %> etc? It just gives a translation missing error each time. I even tried <%=t 'views.user.yes' %> to no avail. Am I missing some sort of required format here? There is a good discussion on this here but it doesn't really answer my question

Community
  • 1
  • 1
Dave
  • 1,051
  • 1
  • 10
  • 20

1 Answers1

3

The "yes" and "no" keys are reserved in YAML and are equivalent to boolean true and false, respectively.

Reference: http://www.yaml.org/refcard.html (Check under "Language Independent Scalar types").

There is also an interesting blog post on the subject by Julian Kniephoff.

Marcelo De Polli
  • 28,123
  • 4
  • 37
  • 47