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 { interface LanguageContextType {
language: string; language: string;
changeLanguage: (newLanguage: string) => void; 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 }) => { export const LanguageProvider: React.FC<{ children: React.ReactNode }> = ({
const [language, setLanguage] = useState<string>('cn'); // default language children,
}) => {
const [language, setLanguage] = useState<string>("cn");
const changeLanguage = (newLanguage: string) => { const changeLanguage = (newLanguage: string) => {
setLanguage(newLanguage); setLanguage(newLanguage);
...@@ -24,7 +28,7 @@ export const LanguageProvider: React.FC<{ children: React.ReactNode }> = ({ chil ...@@ -24,7 +28,7 @@ export const LanguageProvider: React.FC<{ children: React.ReactNode }> = ({ chil
export const useLanguage = (): LanguageContextType => { export const useLanguage = (): LanguageContextType => {
const context = useContext(LanguageContext); const context = useContext(LanguageContext);
if (!context) { if (!context) {
throw new Error('useLanguage must be used within a LanguageProvider'); throw new Error("useLanguage must be used within a LanguageProvider");
} }
return context; return context;
}; };
import React, { useEffect } from 'react'; import React, { useEffect } from "react";
import { useTranslation } from 'react-i18next'; import { useTranslation } from "react-i18next";
const LanguageSelector: React.FC = () => { const LanguageSelector: React.FC = () => {
const { t, i18n } = useTranslation(); const { t, i18n } = useTranslation();
...@@ -7,7 +7,7 @@ const LanguageSelector: React.FC = () => { ...@@ -7,7 +7,7 @@ const LanguageSelector: React.FC = () => {
const onClickLanguageChange = (e: React.ChangeEvent<HTMLSelectElement>) => { const onClickLanguageChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
const language = e.target.value; const language = e.target.value;
i18n.changeLanguage(language); i18n.changeLanguage(language);
console.log('Language:: ', language); console.log("Language:: ", language);
}; };
useEffect(() => { useEffect(() => {
......
...@@ -27,39 +27,37 @@ import translationPortuguese from "./Translation/Portuguese/translation.json"; ...@@ -27,39 +27,37 @@ import translationPortuguese from "./Translation/Portuguese/translation.json";
const resources = { const resources = {
cn: { cn: {
Header: translationChinese.Header, Header: translationChinese.Header,
Start: translationChinese.Start Start: translationChinese.Start,
}, },
en: { en: {
Header: translationEnglish.Header, Header: translationEnglish.Header,
Start: translationEnglish.Start Start: translationEnglish.Start,
}, },
es: { es: {
Header: translationSpanish.Header, Header: translationSpanish.Header,
Start: translationSpanish.Start Start: translationSpanish.Start,
}, },
fr: { fr: {
Header: translationFrench.Header, Header: translationFrench.Header,
Start: translationFrench.Start Start: translationFrench.Start,
}, },
jp: { jp: {
Header: translationJapanese.Header, Header: translationJapanese.Header,
Start: translationJapanese.Start Start: translationJapanese.Start,
}, },
br: { br: {
Header: translationBrazilian.Header, Header: translationBrazilian.Header,
Start: translationBrazilian.Start Start: translationBrazilian.Start,
}, },
pt: { pt: {
Header: translationPortuguese.Header, Header: translationPortuguese.Header,
Start: translationPortuguese.Start Start: translationPortuguese.Start,
}, },
} };
i18next i18next.use(initReactI18next).init({
.use(initReactI18next)
.init({
resources, resources,
lng:"cn", //default language lng: "cn", //default language
}); });
export default i18next; export default i18next;
...@@ -29,9 +29,9 @@ import { theme } from "@/ui/theme"; ...@@ -29,9 +29,9 @@ import { theme } from "@/ui/theme";
import { NeosRouter } from "./ui/NeosRouter"; import { NeosRouter } from "./ui/NeosRouter";
import './i18n' import "./i18n";
import { LanguageProvider } from './Language/LanguageContext'; import { LanguageProvider } from "./Language/LanguageContext";
const root = ReactDOM.createRoot( const root = ReactDOM.createRoot(
document.getElementById("root") as HTMLElement, document.getElementById("root") as HTMLElement,
......
...@@ -61,7 +61,7 @@ const HeaderBtn: React.FC< ...@@ -61,7 +61,7 @@ const HeaderBtn: React.FC<
}; };
export const Component = () => { export const Component = () => {
const { t } = useTranslation('Header'); const { t } = useTranslation("Header");
// 捕获SSO登录 // 捕获SSO登录
const routerLocation = useLocation(); const routerLocation = useLocation();
......
...@@ -13,7 +13,7 @@ import { useTranslation } from "react-i18next"; ...@@ -13,7 +13,7 @@ import { useTranslation } from "react-i18next";
const NeosConfig = useConfig(); const NeosConfig = useConfig();
export const Component: React.FC = () => { export const Component: React.FC = () => {
const { t } = useTranslation('Start'); const { t } = useTranslation("Start");
const { user } = useSnapshot(accountStore); const { user } = useSnapshot(accountStore);
return ( return (
...@@ -50,7 +50,7 @@ export const Component: React.FC = () => { ...@@ -50,7 +50,7 @@ export const Component: React.FC = () => {
Component.displayName = "Start"; Component.displayName = "Start";
const LoginBtn: React.FC<{ logined: boolean }> = ({ logined }) => { const LoginBtn: React.FC<{ logined: boolean }> = ({ logined }) => {
const { t } = useTranslation('Start'); const { t } = useTranslation("Start");
const navigate = useNavigate(); const navigate = useNavigate();
......
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