chore: code style

This commit is contained in:
hdsuperman
2022-12-22 22:21:38 +08:00
parent a9ac199ac5
commit 0d616792dc
3 changed files with 55 additions and 59 deletions
+19 -21
View File
@@ -1,17 +1,17 @@
import i18n from 'i18next'; import i18n from "i18next";
import dayjs from 'dayjs'; import dayjs from "dayjs";
import { initReactI18next } from 'react-i18next'; import { initReactI18next } from "react-i18next";
import Backend from 'i18next-http-backend'; import Backend from "i18next-http-backend";
import LanguageDetector from 'i18next-browser-languagedetector'; import LanguageDetector from "i18next-browser-languagedetector";
import common from '../public/locales/en/common.json'; import common from "../public/locales/en/common.json";
import auth from '../public/locales/en/auth.json'; import auth from "../public/locales/en/auth.json";
import member from '../public/locales/en/member.json'; import member from "../public/locales/en/member.json";
import chat from '../public/locales/en/chat.json'; import chat from "../public/locales/en/chat.json";
import fav from '../public/locales/en/fav.json'; import fav from "../public/locales/en/fav.json";
import welcome from '../public/locales/en/welcome.json'; import welcome from "../public/locales/en/welcome.json";
import setting from '../public/locales/en/setting.json'; import setting from "../public/locales/en/setting.json";
import file from '../public/locales/en/file.json'; import file from "../public/locales/en/file.json";
// don't want to use this? // don't want to use this?
// have a look at the Quick start guide // have a look at the Quick start guide
@@ -27,13 +27,12 @@ export const resources = {
member, member,
welcome, welcome,
setting, setting,
file, file
}, }
} as const; } as const;
i18n.on("languageChanged", (lng) => { i18n.on("languageChanged", (lng) => {
console.log("changed", lng);
// 匹配dayjs的多语言关键字 // 匹配dayjs的多语言关键字
dayjs.locale(lng === 'zh' ? "zh-cn" : lng === 'jp' ? "ja" : lng); dayjs.locale(lng === "zh" ? "zh-cn" : lng === "jp" ? "ja" : lng);
}); });
i18n i18n
// load translation using http -> see /public/locales (i.e. https://github.com/i18next/react-i18next/tree/master/example/react/public/locales) // load translation using http -> see /public/locales (i.e. https://github.com/i18next/react-i18next/tree/master/example/react/public/locales)
@@ -52,17 +51,16 @@ i18n
defaultNS, defaultNS,
load: "languageOnly", load: "languageOnly",
// lng: "jp", // lng: "jp",
fallbackLng: 'en', fallbackLng: "en",
fallbackNS: "common", fallbackNS: "common",
debug: false, debug: false,
detection: { detection: {
order: ["localStorage", "navigator"] order: ["localStorage", "navigator"]
}, },
interpolation: { interpolation: {
escapeValue: false, // not needed for react as it escapes by default escapeValue: false // not needed for react as it escapes by default
}, },
returnNull: false, returnNull: false
}); });
export default i18n; export default i18n;
-2
View File
@@ -1,7 +1,5 @@
// import React from 'react';
import { memo, useState } from "react"; import { memo, useState } from "react";
import { useParams } from "react-router-dom"; import { useParams } from "react-router-dom";
import StyledWrapper from "./styled"; import StyledWrapper from "./styled";
import BlankPlaceholder from "../../common/component/BlankPlaceholder"; import BlankPlaceholder from "../../common/component/BlankPlaceholder";
import Server from "../../common/component/Server"; import Server from "../../common/component/Server";
+1 -1
View File
@@ -1,4 +1,4 @@
import React, { ReactElement, ReactNode } from "react"; import React from "react";
import dayjs from "dayjs"; import dayjs from "dayjs";
import styled from "styled-components"; import styled from "styled-components";
import reactStringReplace from "react-string-replace"; import reactStringReplace from "react-string-replace";