Meteor.startup(function() {
  Tracker.autorun(function() {
    if ( !((Meteor.user() || {}).profile || {}).language ) {
      return Session.set('language', navigator.language.substring(0, 2));
    }
    Session.set('language', Meteor.user().profile.language);
  });

  Tracker.autorun(function() {
    let language = Session.get('language') || 'en';

    if (!['en', 'ru', 'ua'].indexOf(language)) language = 'en';

    TAPi18n.setLanguage(language);
    moment.locale(language);
    accountsUIBootstrap3.setLanguage(language === 'uk' ? 'ua' : language);

    if ( !((Meteor.user() || {}).profile || {}).weekDow ) return;
    moment.locale(Meteor.user().profile.language, {
      week: {dow: Meteor.user().profile.weekDow}
    });
  });
});

@@ -115,89 +115,15 @@
 e ) 
-%7B%0A      return Session.set('language', navigator.language.substring(0, 2));%0A    %7D
+return;
 %0A   
@@ -230,115 +230,192 @@
 let 
-language = Session.get('language') %7C%7C 'en';%0A%0A    if (!%5B'en', 'ru', 'ua'%5D.indexOf(language)) language = 'en'
+defaultLang = navigator.language.substring(0, 2);%0A    defaultLang = TAPi18n.getLanguages()%5BdefaultLang%5D ? defaultLang : 'en';%0A%0A    let language = Session.get('language') %7C%7C defaultLang
 ;%0A%0A 

Refactor determining user locale