I would like to set 'i18n.locale' from within an initializer in EmberJS.
I am using 1.12 via Ember-CLI with ember-i18n.
I tried this
import Ember from 'ember';
export function initialize(container, application) {
Ember.set('i18n.locale', 'de');
}
export default {
name: 'user-locale',
initialize: initialize
}
but am receiving Assertion Failed: Path 'i18n.locale' must be global if no obj is given.
You could get
i18n
asservice:i18n
and use instance-initializer to seti18n.locale
.InstanceInitializers guides:
http://emberjs.com/deprecations/v1.x/#toc_access-to-instances-in-initializers
http://emberjs.com/blog/2015/05/13/ember-1-12-released.html#toc_instance-initializers
As of Ember 1.13.8 you now have to access the container as a function
const i18n = instance.container().lookup('service:i18n');