From aced02185c5596270cd45ed9cbb2c2aa334553e4 Mon Sep 17 00:00:00 2001 From: Fahad Alduraibi Date: Thu, 17 Dec 2015 20:19:28 -0500 Subject: [PATCH] Adjust layout direction based on user's language This fixes the issue https://github.com/RocketChat/Rocket.Chat/issues/1623 So basically if a user login from a new machine and the language loaded from their profile is different from the local one then set the correct language and if it is an RTL language set the RTL class immediately. --- client/startup/startup.coffee | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/client/startup/startup.coffee b/client/startup/startup.coffee index c42fb6200e0..1d590b55508 100644 --- a/client/startup/startup.coffee +++ b/client/startup/startup.coffee @@ -39,8 +39,11 @@ Meteor.startup -> if Meteor.user()?.language? c.stop() - localStorage.setItem("userLanguage", Meteor.user().language) - setLanguage Meteor.user().language + if localStorage.getItem('userLanguage') isnt Meteor.user().language + localStorage.setItem("userLanguage", Meteor.user().language) + setLanguage Meteor.user().language + if isRtl localStorage.getItem "userLanguage" + $('html').addClass "rtl" userLanguage = localStorage.getItem("userLanguage") userLanguage ?= defaultUserLanguage()