import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import { TAPi18n } from 'meteor/tap:i18n';
import { FlowRouter } from 'meteor/kadira:flow-router';
import moment from 'moment';

Meteor.startup(() => {
  Tracker.autorun((tracker) => {
    if (Meteor.user() != null) {
      tracker.stop();

      const language = FlowRouter.current().params.language;
      const myLanguage = Meteor.user().profile.language;

      if (language != myLanguage) {
        FlowRouter.withReplaceState(() => {
          FlowRouter.setParams({ language: myLanguage });
        });
      }

      if (TAPi18n.getLanguage() != myLanguage) {
        TAPi18n.setLanguage(myLanguage);
      }

      if (moment.locale() != myLanguage) {
        moment.locale(myLanguage);
      }
    }
  });
});

@@ -227,16 +227,51 @@
 () =%3E %7B%0A
+  moment.locale('en'); // default%0A%0A
   Tracke
@@ -643,26 +643,20 @@
 if (
-TAPi18n.getLanguag
+moment.local
 e() 
@@ -684,26 +684,20 @@
     
-TAPi18n.setLanguag
+moment.local
 e(my
@@ -722,36 +722,42 @@
 %0A%0A      if (
-moment.local
+TAPi18n.getLanguag
 e() != myLan
@@ -769,36 +769,42 @@
 ) %7B%0A        
-moment.local
+TAPi18n.setLanguag
 e(myLanguage

set moment to default before setting it to the user profile value