ember-i18n没有找到默认的语言环境;回到" en"

时间:2017-02-23 09:52:26

标签: ember.js ember-i18n

我收到ember-i18n的警告(ember-i18n:5.0.0)

我已在defaultLocale中设置:' en' (正如ember-i18n docs中所述)在environment.js中,但仍然是人口警告。

// environment.js

module.exports = function(environment) {
    var ENV = {
        modulePrefix: 'spotlight',
        environment: environment,
        baseURL: '/',
        locationType: 'auto',
        EmberENV: {
           FEATURES: {}
        }, 

        APP: {
           defaultLocale:'en',
        }
    };
    if (environment === 'development') {
        ENV.APP.RAISE_ON_DEPRECATION = true;
    }

    if (environment === 'test') {
       ENV.baseURL = '/';
       ENV.locationType = 'auto';
       ENV.APP.LOG_ACTIVE_GENERATION = false;
       ENV.APP.LOG_VIEW_LOOKUPS = false;
       ENV.APP.rootElement = '#ember-testing';
    }
    if (environment === 'production') {}

    ENV.i18n = { defaultLocale: 'en' };
    return ENV;
};

//的package.json

{
  "devDependencies": {
      "ember-i18n": "5.0.0"
  }
}

//应用程序/初始化/ i18n.js

import Ember from 'ember';

export default {
    name: 'i18n',
    after: 'ember-i18n',
    initialize: function()
    {
        var application = arguments[1] || arguments[0];
        application.inject('controller', 'i18n', 'service:i18n');
        application.inject('route', 'i18n', 'service:i18n');
    }
}

提前感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

知道了。这是因为home.jsp(我的项目初​​始化文件)静态元内容。

始终使用静态元内容(home.js元内容)而不是environment.js文件进行设置。

<meta name="spotlight/config/environment" content="%7B%22modulePrefix%22%3A%22spotlight%22%2C%22environment%22%3A%22development%22%2C%22baseURL%22%3A%22%2F%22%2C%22locationType%22%3A%22hash%22%2C%22EmberENV%22%3A%7B%22FEATURES%22%3A%7B%7D%7D%2C%22i18n%22%3A%7B%22defaultLocale%22%3A%22en%22%7D%2C%22APP%22%3A%7B%22LOG_RESOLVER%22%3Atrue%2C%22LOG_ACTIVE_GENERATION%22%3Atrue%2C%22LOG_TRANSITIONS%22%3Atrue%2C%22LOG_TRANSITIONS_INTERNAL%22%3Atrue%2C%22LOG_VIEW_LOOKUPS%22%3Atrue%2C%22LOG_BINDINGS%22%3Atrue%2C%22RAISE_ON_DEPRECATION%22%3Atrue%2C%22LOG_STACKTRACE_ON_DEPRECATION%22%3Atrue%7D%2C%22contentSecurityPolicyHeader%22%3A%22Content-Security-Policy-Report-Only%22%2C%22contentSecurityPolicy%22%3A%7B%22default-src%22%3A%22%27none%27%22%2C%22script-src%22%3A%22%27self%27%20%27unsafe-eval%27%22%2C%22font-src%22%3A%22%27self%27%22%2C%22connect-src%22%3A%22%27self%27%22%2C%22img-src%22%3A%22%27self%27%22%2C%22style-src%22%3A%22%27self%27%22%2C%22media-src%22%3A%22%27self%27%22%7D%2C%22exportApplicationGlobal%22%3Atrue%7D">