Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
Neos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
BBeretta
Neos
Commits
75b8dbfd
Commit
75b8dbfd
authored
May 14, 2024
by
BBeretta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: prettier adoption added
parent
19a974ef
Pipeline
#27121
failed with stages
in 12 minutes and 20 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
61 additions
and
59 deletions
+61
-59
src/Language/LanguageContext.tsx
src/Language/LanguageContext.tsx
+9
-5
src/Language/LanguageSelector.tsx
src/Language/LanguageSelector.tsx
+3
-3
src/i18n.tsx
src/i18n.tsx
+32
-34
src/main.tsx
src/main.tsx
+9
-9
src/ui/Layout/index.tsx
src/ui/Layout/index.tsx
+3
-3
src/ui/Start/index.tsx
src/ui/Start/index.tsx
+5
-5
No files found.
src/Language/LanguageContext.tsx
View file @
75b8dbfd
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
;
};
src/Language/LanguageSelector.tsx
View file @
75b8dbfd
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
(()
=>
{
...
...
src/i18n.tsx
View file @
75b8dbfd
...
...
@@ -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
;
src/main.tsx
View file @
75b8dbfd
...
...
@@ -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
>,
);
src/ui/Layout/index.tsx
View file @
75b8dbfd
...
...
@@ -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
};
src/ui/Start/index.tsx
View file @
75b8dbfd
...
...
@@ -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
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment