diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-11-12 05:03:12 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-11-12 05:03:12 +0900 |
| commit | fab389e6241acf5eb0500e17972b90e8785199dd (patch) | |
| tree | 473096d69b1c48ed75f4a1a4f199c5cb1f4f0ecb /src/client/app/boot.js | |
| parent | [Client] Enable code splitting (diff) | |
| download | misskey-fab389e6241acf5eb0500e17972b90e8785199dd.tar.gz misskey-fab389e6241acf5eb0500e17972b90e8785199dd.tar.bz2 misskey-fab389e6241acf5eb0500e17972b90e8785199dd.zip | |
[Client] Stop generate scripts for each languages
Resolve #3172
Diffstat (limited to 'src/client/app/boot.js')
| -rw-r--r-- | src/client/app/boot.js | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/client/app/boot.js b/src/client/app/boot.js index 0d5eefaea9..59278ff23c 100644 --- a/src/client/app/boot.js +++ b/src/client/app/boot.js @@ -3,15 +3,9 @@ * (ENTRY POINT) */ -/** - * ドメインに基づいて適切なスクリプトを読み込みます。 - * ユーザーの言語およびモバイル端末か否かも考慮します。 - * webpackは介さないためrequireやimportは使えません。 - */ - 'use strict'; -(function() { +(async function() { // キャッシュ削除要求があれば従う if (localStorage.getItem('shouldFlush') == 'true') { refresh(); @@ -67,8 +61,18 @@ langs.includes(settings.device.lang)) { lang = settings.device.lang; } + + window.lang = lang; //#endregion + let locale = localStorage.getItem('locale'); + if (locale == null) { + const locale = await fetch(`/assets/locales/${lang}.json`) + .then(response => response.json()); + + localStorage.setItem('locale', JSON.stringify(locale)); + } + // Detect the user agent const ua = navigator.userAgent.toLowerCase(); const isMobile = /mobile|iphone|ipad|android/.test(ua); @@ -106,7 +110,7 @@ // Note: 'async' make it possible to load the script asyncly. // 'defer' make it possible to run the script when the dom loaded. const script = document.createElement('script'); - script.setAttribute('src', `/assets/${app}.${ver}.${lang}.js${salt}`); + script.setAttribute('src', `/assets/${app}.${ver}.js${salt}`); script.setAttribute('async', 'true'); script.setAttribute('defer', 'true'); head.appendChild(script); |