Here's my code which works fine.
export default Route.extend({
beforeModel() {
this.controllerFor('myreusable-template').set('currentStep', 'prepare_data');
},
afterModel(model) {
if (model.get('roles.length') === 0) {
model.newRole({
name: this.get('i18n').t('routes.myreusableTemplate.addRoles.user1')
});
}
}
});
here are my test case file imports
import { moduleFor, test } from 'ember-qunit';
import Ember from 'ember';
import tHelper from 'ember-i18n/helper';
import localeConfig from 'ember-i18n/config/en';
moduleFor('controller:myreusable-template/my-file', {
unit: true,
needs: ['service:layoutSizeData',
'service:i18n',
'locale:en/translations',
//'locale:en/config',
'util:i18n/missing-message',
'util:i18n/compile-template',
'config:environment'],
beforeEach() {
this.container.lookup('service:i18n').set('locale', 'en');
this.registry.register('locale:en/config', localeConfig);
this.registry.register('helper:t', tHelper);
}
});
And this is the error I am getting while executing the file.
undefined is not an object (evaluating 'this.get('i18n').t').
I am following the i18n doc to write the imports but it still not working. I am using ember ember-cli: 2.12.3, "ember-i18n": "5.0.1".
Aucun commentaire:
Enregistrer un commentaire