wip
This commit is contained in:
parent
230e952c84
commit
d7b77ee022
12 changed files with 136 additions and 169 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue