Browse Source

clean data attributes

Yuki Takei 5 years ago
parent
commit
9bb4fc51cd
2 changed files with 8 additions and 9 deletions
  1. 8 7
      src/client/js/services/AppContainer.js
  2. 0 2
      src/server/views/layout/layout.html

+ 8 - 7
src/client/js/services/AppContainer.js

@@ -42,9 +42,15 @@ export default class AppContainer extends Container {
     const userAgent = window.navigator.userAgent.toLowerCase();
     this.isMobile = /iphone|ipad|android/.test(userAgent);
 
-    const userlang = body.dataset.userlang;
-    this.i18n = i18nFactory(userlang);
+    const currentUserElem = document.getElementById('growi-current-user');
+    if (currentUserElem != null) {
+      this.currentUser = JSON.parse(currentUserElem.textContent);
+    }
+
+    const userLocaleId = this.currentUser.lang;
+    this.i18n = i18nFactory(userLocaleId);
     this.locales = this.i18n.options.resources;
+
     this.containerInstances = {};
     this.componentInstances = {};
     this.rendererInstances = {};
@@ -79,11 +85,6 @@ export default class AppContainer extends Container {
   initContents() {
     const body = document.querySelector('body');
 
-    const currentUserElem = document.getElementById('growi-current-user');
-    if (currentUserElem != null) {
-      this.currentUser = JSON.parse(currentUserElem.textContent);
-    }
-
     this.isAdmin = body.dataset.isAdmin === 'true';
 
     this.isDocSaved = true;

+ 0 - 2
src/server/views/layout/layout.html

@@ -69,8 +69,6 @@
   data-plugin-enabled="{{ getConfig('crowi', 'plugin:isEnabledPlugins') }}"
   {% block html_base_attr %}{% endblock %}
   data-csrftoken="{{ csrf() }}"
-  data-current-username="{% if user %}{{ user.username }}{% endif %}"
-  data-userlang="{% if user %}{{ user.lang }}{% endif %}"
  >
 
 <div id="wrapper">