Commit 75b8dbfd authored by BBeretta's avatar BBeretta

fix: prettier adoption added

parent 19a974ef
Pipeline #27121 failed with stages
in 12 minutes and 20 seconds
import React, { createContext, useState, useContext } from 'react';
import React, { createContext, useState, useContext } from "react";
interface LanguageContextType {
language: string;
changeLanguage: (newLanguage: string) => void;
}
const LanguageContext = createContext<LanguageContextType | undefined>(undefined);
const LanguageContext = createContext<LanguageContextType | undefined>(
undefined,
);
export const LanguageProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
const [language, setLanguage] = useState<string>('cn'); // default language
export const LanguageProvider: React.FC<{ children: React.ReactNode }> = ({
children,
}) => {
const [language, setLanguage] = useState<string>("cn");
const changeLanguage = (newLanguage: string) => {
setLanguage(newLanguage);
......@@ -24,7 +28,7 @@ export const LanguageProvider: React.FC<{ children: React.ReactNode }> = ({ chil
export const useLanguage = (): LanguageContextType => {
const context = useContext(LanguageContext);
if (!context) {
throw new Error('useLanguage must be used within a LanguageProvider');
throw new Error("useLanguage must be used within a LanguageProvider");
}
return context;
};
import React, { useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import React, { useEffect } from "react";
import { useTranslation } from "react-i18next";
const LanguageSelector: React.FC = () => {
const { t, i18n } = useTranslation();
......@@ -7,7 +7,7 @@ const LanguageSelector: React.FC = () => {
const onClickLanguageChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
const language = e.target.value;
i18n.changeLanguage(language);
console.log('Language:: ', language);
console.log("Language:: ", language);
};
useEffect(() => {
......
......@@ -25,41 +25,39 @@ import translationPortuguese from "./Translation/Portuguese/translation.json";
//---Using different namespaces
const resources = {
cn: {
Header: translationChinese.Header,
Start: translationChinese.Start
},
en: {
Header: translationEnglish.Header,
Start: translationEnglish.Start
},
es: {
Header: translationSpanish.Header,
Start: translationSpanish.Start
},
fr: {
Header: translationFrench.Header,
Start: translationFrench.Start
},
jp: {
Header: translationJapanese.Header,
Start: translationJapanese.Start
},
br: {
Header: translationBrazilian.Header,
Start: translationBrazilian.Start
},
pt: {
Header: translationPortuguese.Header,
Start: translationPortuguese.Start
},
}
cn: {
Header: translationChinese.Header,
Start: translationChinese.Start,
},
en: {
Header: translationEnglish.Header,
Start: translationEnglish.Start,
},
es: {
Header: translationSpanish.Header,
Start: translationSpanish.Start,
},
fr: {
Header: translationFrench.Header,
Start: translationFrench.Start,
},
jp: {
Header: translationJapanese.Header,
Start: translationJapanese.Start,
},
br: {
Header: translationBrazilian.Header,
Start: translationBrazilian.Start,
},
pt: {
Header: translationPortuguese.Header,
Start: translationPortuguese.Start,
},
};
i18next
.use(initReactI18next)
.init({
i18next.use(initReactI18next).init({
resources,
lng:"cn", //default language
lng: "cn", //default language
});
export default i18next;
\ No newline at end of file
export default i18next;
......@@ -29,9 +29,9 @@ import { theme } from "@/ui/theme";
import { NeosRouter } from "./ui/NeosRouter";
import './i18n'
import "./i18n";
import { LanguageProvider } from './Language/LanguageContext';
import { LanguageProvider } from "./Language/LanguageContext";
const root = ReactDOM.createRoot(
document.getElementById("root") as HTMLElement,
......@@ -39,12 +39,12 @@ const root = ReactDOM.createRoot(
root.render(
<LanguageProvider>
<ConfigProvider theme={theme} locale={zhCN}>
<App>
<ProConfigProvider dark>
<NeosRouter />
</ProConfigProvider>
</App>
</ConfigProvider>
<ConfigProvider theme={theme} locale={zhCN}>
<App>
<ProConfigProvider dark>
<NeosRouter />
</ProConfigProvider>
</App>
</ConfigProvider>
</LanguageProvider>,
);
......@@ -61,7 +61,7 @@ const HeaderBtn: React.FC<
};
export const Component = () => {
const { t } = useTranslation('Header');
const { t } = useTranslation("Header");
// 捕获SSO登录
const routerLocation = useLocation();
......@@ -133,7 +133,7 @@ export const Component = () => {
href="https://mycard.moe/ygopro/arena/#/"
target="_blank"
>
{t("DuelDatabase")}
{t("DuelDatabase")}
</a>
),
},
......@@ -168,4 +168,4 @@ const NeosAvatar = () => {
return (
<Avatar size="small" src={user?.avatar_url} style={{ cursor: "pointer" }} />
);
};
\ No newline at end of file
};
......@@ -13,7 +13,7 @@ import { useTranslation } from "react-i18next";
const NeosConfig = useConfig();
export const Component: React.FC = () => {
const { t } = useTranslation('Start');
const { t } = useTranslation("Start");
const { user } = useSnapshot(accountStore);
return (
......@@ -50,8 +50,8 @@ export const Component: React.FC = () => {
Component.displayName = "Start";
const LoginBtn: React.FC<{ logined: boolean }> = ({ logined }) => {
const { t } = useTranslation('Start');
const { t } = useTranslation("Start");
const navigate = useNavigate();
const loginViaSSO = () =>
......@@ -65,8 +65,8 @@ const LoginBtn: React.FC<{ logined: boolean }> = ({ logined }) => {
style={{ marginTop: "auto" }}
onClick={logined ? goToMatch : loginViaSSO}
>
<span>{logined ? t("StartGame") : t("LoginToGame")}</span>
<span>{logined ? t("StartGame") : t("LoginToGame")}</span>
<RightOutlined />
</SpecialButton>
);
};
\ No newline at end of file
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment