Lang attribute doesn't change when changing locale on profile

This is working for me. Warning, I broke my development site while trying to figure this out. I think this is safe, but maybe someone else can take a look at it.

<script type="text/discourse-plugin" version="0.3">
  let currentUser = api.getCurrentUser();
  if (currentUser) {
      let username = currentUser.username;
      api.container.lookup('store:main').find('user', username).then(function (user) {
        let userLocale = user.get('locale');
        if ('ar' === userLocale) {
          let st = document.createElement('style');
          st.innerHTML = "html {font-family: 'Noto Naskh Arabic', serif !important; }";
          document.head.appendChild(st); 
        }
      });
  }
</script>
8 إعجابات