views:

1040

answers:

1

Trying to use my active record translations in config/locales/de.yml also in my views. I thought I am clever using this:

de:
  activerecord: 
    attributes:
      user:
        login: "Benutzerkennung"
        comment: "Bemerkungen"

And in my view this:

<%= label_tag :login, t('activerecord.attributes.user.login') %>

But instead of the translation value ("Benutzerkennung") I am getting the infamous "translation missing: de, activerecord, attributes, user, login"

Has anybody got this working (not using the label translation plugin (I am wary of potential side effects), or User.humanize_attribute_name)? What am I missing? (it does work when I use "activerecord1" or something else than activerecord, so my setup seems to be fine)

Thanks!

+4  A: 

Ok, my bad, it does work just fine. I fell in the YML formatting trap :(

To help you debug along the way, use "script/console" and the following statements: - I18n.locale --> should output the locale you want to examine - I18n.t('activerecord.attributes') --> should give you all the key/value pairs for your translation, if not, you made a formatting error in your YML file or it could not be found

And btw - the plugin works quite well http://github.com/iain/i18n%5Flabel/ if you don't like the result of ".human_name" (which the plugin uses), just fall back to I18n.t('your key')

juwalter
Thanks, this actually pointed me towards my locale file being in config/locale instead of config/locales
TheDeadSerious