diff --git a/src/common/default-template.ts b/src/common/default-template.ts deleted file mode 100644 index 4167a68..0000000 --- a/src/common/default-template.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * デフォルトの投稿用テンプレート - */ -export const defaultTemplate = `昨日のMisskeyの活動は - -ノート: {notesCount}({notesDelta}) -フォロー : {followingCount}({followingDelta}) -フォロワー :{followersCount}({followersDelta}) - -でした。 -{url}`; diff --git a/src/frontend/App.tsx b/src/frontend/App.tsx index f8852ed..40f35d1 100644 --- a/src/frontend/App.tsx +++ b/src/frontend/App.tsx @@ -2,6 +2,8 @@ import React, { useState, useEffect, useCallback } from 'react'; import { BrowserRouter, Link, Route, Switch, useLocation } from 'react-router-dom'; import { Provider } from 'react-redux'; import { useTranslation } from 'react-i18next'; +import i18n from 'i18next'; +import { initReactI18next } from 'react-i18next'; import { IndexPage } from './pages'; import { RankingPage } from './pages/ranking'; @@ -10,11 +12,28 @@ import { TermPage } from './pages/term'; import { store, useSelector } from './store'; import { ModalComponent } from './Modal'; import { ActualTheme } from './misc/theme'; -import { ErrorCode } from '../common/types/error-code'; +import { getBrowserLanguage, resources } from './langs'; +import { LOCALSTORAGE_KEY_LANG } from './const'; import 'xeltica-ui/dist/css/xeltica-ui.min.css'; import './style.scss'; +document.body.classList.add('dark'); + +if (!localStorage[LOCALSTORAGE_KEY_LANG]) { + localStorage[LOCALSTORAGE_KEY_LANG] = getBrowserLanguage(); +} + +i18n + .use(initReactI18next) + .init({ + resources, + lng: localStorage[LOCALSTORAGE_KEY_LANG], + interpolation: { + escapeValue: false // react already safes from xss + } + }); + const AppInner : React.VFC = () => { const $location = useLocation(); diff --git a/src/frontend/components/SettingPage.tsx b/src/frontend/components/SettingPage.tsx index df2e02e..71f000c 100644 --- a/src/frontend/components/SettingPage.tsx +++ b/src/frontend/components/SettingPage.tsx @@ -3,7 +3,6 @@ import { alertModes } from '../../common/types/alert-mode'; import { IUser } from '../../common/types/user'; import { Visibility } from '../../common/types/visibility'; import { useGetSessionQuery } from '../services/session'; -import { defaultTemplate } from '../../common/default-template'; import { Card } from './Card'; import { Theme, themes } from '../misc/theme'; import { API_ENDPOINT, LOCALSTORAGE_KEY_TOKEN } from '../const'; @@ -141,6 +140,8 @@ export const SettingPage: React.VFC = () => { })); }, [dispatch]); + const defaultTemplate = t('_template.default'); + return session.isLoading || !data ? (
) : ( diff --git a/src/frontend/init.tsx b/src/frontend/init.tsx index b8fefe8..588b8ef 100644 --- a/src/frontend/init.tsx +++ b/src/frontend/init.tsx @@ -1,23 +1,6 @@ import * as React from 'react'; import * as ReactDOM from 'react-dom'; -import i18n from 'i18next'; -import { initReactI18next } from 'react-i18next'; import { App } from './App'; -import { getBrowserLanguage, resources } from './langs'; - -document.body.classList.add('dark'); - - -i18n - .use(initReactI18next) - .init({ - resources, - lng: localStorage['lang'] ?? getBrowserLanguage(), - interpolation: { - escapeValue: false // react already safes from xss - } - }); - ReactDOM.render(