getUserLanguage = function () {
  // Put here the logic for determining the user language

  return "zh";
};

if (Meteor.isClient) {
  Meteor.startup(function () {
    _.extend(Notifications.defaultOptions, {
      timeout: 3500
    });

    TAPi18n.setLanguage(getUserLanguage())
      .done(function () {
        Session.set("showLoadingIndicator", false);
      })
      .fail(function (error_message) {
        // Handle the situation
        console.log(error_message);
      });
  });
}
@@ -1,20 +1,23 @@
-getU
+const u
 serLanguage = fu
@@ -18,70 +18,67 @@
 e = 
-function () %7B%0A  // Put here the logic for determining the user
+() =%3E %7B%0A  // If the user is logged in, retrieve their saved
  lan
@@ -87,22 +87,66 @@
 age%0A
-%0A
   
-return %22zh%22
+if (Meteor.user()) return Meteor.user().profile.language
 ;%0A%7D;
@@ -284,242 +284,685 @@
    T
-APi18n.setLanguage(getUserLanguage())%0A      .done(function () %7B%0A        Session.set(%22showLoadingIndicator%22, false);%0A      %7D)%0A      .fail(function (error_message) %7B%0A        // Handle the situation%0A        console.log(error_message);%0A  
+racker.autorun(() =%3E %7B%0A      let lang;%0A%0A      // URL Language takes priority%0A      const urlLang = FlowRouter.getQueryParam('lang');%0A      if (urlLang) %7B%0A        lang = urlLang;%0A      %7D else if (userLanguage()) %7B%0A        // User language is set if no url lang%0A        lang = userLanguage();%0A      %7D else %7B%0A        // If no user language, try setting by browser (default en)%0A        const localeFromBrowser = window.navigator.userLanguage %7C%7C window.navigator.language;%0A        let locale = 'en';%0A%0A        if (localeFromBrowser.match(/en/)) locale = 'en';%0A        if (localeFromBrowser.match(/zh/)) locale = 'zh';%0A%0A        lang = locale;%0A      %7D%0A      TAPi18n.setLanguage(lang);%0A
     

Add a new method to find language for user