0
0
Fork 0
This commit is contained in:
xeltica 2021-09-24 02:18:31 +09:00
parent 230e952c84
commit d7b77ee022
12 changed files with 136 additions and 169 deletions

View file

@ -4,31 +4,16 @@ import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import { App } from './App';
import { LOCALSTORAGE_KEY_TOKEN } from './const';
import { resources } from './langs';
import { getBrowserLanguage, resources } from './langs';
document.body.classList.add('dark');
// cookieにトークンが入ってたらlocalStorageに移し替える
const token = document.cookie
.split('; ')
.find(row => row.startsWith('token'))
?.split('=')[1];
if (token) {
localStorage[LOCALSTORAGE_KEY_TOKEN] = token;
// 今の所はcookieをトークン以外に使用しないため全消去する
// もしcookieの用途が増えるのであればここを良い感じに書き直す必要がある
document.cookie = '';
}
console.log(resources);
i18n
.use(initReactI18next)
.init({
resources,
lng: localStorage['lang'] ?? 'ja_JP',
lng: localStorage['lang'] ?? getBrowserLanguage(),
interpolation: {
escapeValue: false // react already safes from xss
}