ember-i18n 没有找到默认语言环境;回到 "en"
ember-i18n did not find a default locale; falling back to "en"
我收到 ember-i18n (ember-i18n: 5.0.0)
的警告
我在 environment.js 中设置了 defaultLocale: 'en'(如 ember-i18n 文档中所述),但仍然是 populationg 警告。
//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"
}
}
//app/initializer/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');
}
}
在此先感谢您的帮助。
知道了。这是因为 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">
我收到 ember-i18n (ember-i18n: 5.0.0)
的警告我在 environment.js 中设置了 defaultLocale: 'en'(如 ember-i18n 文档中所述),但仍然是 populationg 警告。
//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"
}
}
//app/initializer/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');
}
}
在此先感谢您的帮助。
知道了。这是因为 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">