1

I tried first something like this in my application controller:

init123: function() {
  var locale;
  if (this.session.get('lang') === null || this.session.get('lang') === undefined)
    locale = ENV.i18n.defaultLocale;
  else
    locale = this.session.get('lang');

  this.get('i18n').set('locale', locale);
}.on('init'),

but this only works when the user is logged in. If not, always the default is set.

Then I tried stuff with the initalizer like on this answer.

How to set the i18n.locale from within an initializer from Artych

But how do I remember the last choice done in the browser?

Thx

Community
  • 1
  • 1
PowPi
  • 164
  • 1
  • 1
  • 10

2 Answers2

1

You need to persist the preference somewhere. Take a look at the ember-localforage-adapter or ember-local-storage packages.

brian
  • 167
  • 4
0

If you are using ember-simple-auth you can save it into the session.

lpinto.eu
  • 2,077
  • 4
  • 21
  • 45