ember-i18n : TypeError: app[initializerType] is not a function

时间:2015-06-26 10:10:40

标签: ember.js internationalization

I've been installing ember-i18n on a working Ember project. (https://github.com/jamesarosen/ember-i18n)

After registering an initializer app/initializers/i18n.js :

export default {
  name: 'i18n',

  after: 'ember-i18n',

  initialize: function(_, app) {
    app.inject('model', 'i18n', 'service:i18n')
  }
};

And relaunching the server, I get this error in the console :

app[initializerType] is not a function

Do you have any idea ?

Ember version : "ember": "1.11.1"

2 个答案:

答案 0 :(得分:0)

看起来初始化程序的格式不正确。根据{{​​3}},有两个重要部分。首先,必须注册工厂(application.register),然后必须注入(application.inject)。

Ember.Application.initializer({       名称:'logger',

  initialize: function(container, application) {
    var logger = {
      log: function(m) {
        console.log(m);
      }
    };

    application.register('logger:main', logger, { instantiate: false });
    application.inject('route', 'logger', 'logger:main');
  }
});

答案 1 :(得分:0)

似乎ember 1.11.1和ember-i18n之间存在不兼容性。

升级到1.13.2(和ember-data 1.13.4)解决了这个问题,而没有对初始化程序进行任何更改。