Ember and Moment - change locale

Hi there!
How do i change locale in all app? I mean, user clicks on switch language, and all components in my app, will change names of month.

Boris, try check it GitHub - jamesarosen/ember-i18n

1 Like

Yes, ember-i18n is the way to go.

With it it’s pretty easy to hook up an action that will change the language, which will reflect everywhere.

In this action you’ll do two things:

  1. this.get('i18n').set('locale', newLocale)
  2. moment.locale(newLocale)

Just make sure your computed properties using moment etc. bind to i18n.locale.

// ... inside a controller/route/etc
i18n: Ember.inject.service(),

myComputed: function() {
  // ...
  return moment().format();
}.property('i18n.locale'),
1 Like

GitHub - adopted-ember-addons/ember-moment recomputes helpers on locale change. Just be sure to use the service API to trigger the locale change.

1 Like