samedi 21 février 2015

i18n translation not working with ember - Assertion Failed: Missing translation for key

I am using ember-cli-i18n in an ember-cli app..


I have property menuItems which returns..



[{
text: 'leftnav_nonfollower',
route: 'nonFollowers'
}, {
text: 'leftnav_nonfans',
route: 'fans'
}]


In template i use menuItems as ..



{{#each menuItem in navItems}}
<li {{action 'changeRoute' menuItem }} >
<a href="#" class='nav-circle'>
{{t menuItem.text}}
</a>
</li>
{{/each}}


Now instead of looking for translation for leftnav_nonfollower.. the library utility t() is actually instead looking for translation of string menuItem.text.. thus giving error Assertion Failed: Missing translation for key "menuItem.text".





2 commentaires:

  1. Running into the same problem. I know I can stub the i18n service, but I just want to use it in my component tests.
    Did you find a solution?

    RépondreSupprimer
    Réponses
    1. To answer my own question:
      declare a variable in the test, and
      in beforeEach do
      this.set('i18n', this.container.lookup('service:i18n'))

      Supprimer