0

For test reasons i tried:

I18n.locale = "fehler_ausgabe"
puts I18n.translate "activerecord.attributes.diagnosis.sicherheit"

What worked correctly and returned E-mail addresse for this yaml-file:

fehler_ausgabe:
  activerecord:
    attributes:
      diagnosis:
        sicherheit: "E-mail addresse"

Next i tried to test a error that is in my model defined like this:

validates :sicherheit, inclusion: { in: ["U","V"]}, unless: :skip_fehler

I changed my yaml file:

fehler_ausgabe:
  activerecord:
    attributes:
      diagnosis:
        sicherheit: "E-mail addresse"
          inclusion: "muss zugeorndet werden"

I tried again:

puts I18n.translate "activerecord.attributes.diagnosis.sicherheit"

But now somehow get this error:

I18n::InvalidLocaleData (can not load translations from C:/Sites/heroku
2/config/locales/fehler_ausgabe.yml: #<Psych::SyntaxError:     (C:/Sites/heroku2/config/locales/fehler_ausgabe.yml): 
did not find expected key while parsin
g a block mapping at line 5 column 9>):

What do i wrong? I dont understand why my code now throws a error! THANKS

Simone Carletti
  • 173,507
  • 49
  • 363
  • 364
John Smith
  • 6,105
  • 16
  • 58
  • 109
  • 1
    Your change makes YAML file with invalid data. You can not have `inclusion:` in `sicherheit: "E-mail addresse"` either remove "E-mail addresse" or `inclusion`. – Surya Nov 01 '14 at 09:52
  • could you please respond in a answer so that i can mark it as correct ? thanks – John Smith Nov 01 '14 at 10:02

1 Answers1

3

Your change:

fehler_ausgabe:
  activerecord:
    attributes:
      diagnosis:
        sicherheit: "E-mail addresse"
          inclusion: "muss zugeorndet werden"

makes your YAML file invalid. You can not have inclusion: "muss zugeorndet werden" if you tend to have sicherheit: "E-mail addresse". Either remove inclusion: "muss zugeorndet werden" or "E-mail addresse" to make your arrangement work.

However, you can checkout this answer to setup inclusion validation properly in your YAML.

Community
  • 1
  • 1
Surya
  • 15,703
  • 3
  • 51
  • 74