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
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
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
MyCard
Neos
Commits
661061b5
Commit
661061b5
authored
May 19, 2024
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rerange code and translation source
parent
e811fd11
Pipeline
#27197
failed with stages
in 7 minutes and 11 seconds
Changes
13
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
78 additions
and
58 deletions
+78
-58
src/main.tsx
src/main.tsx
+3
-3
src/ui/I18N/I18NContext/index.tsx
src/ui/I18N/I18NContext/index.tsx
+32
-0
src/ui/I18N/I18NSelector/index.tsx
src/ui/I18N/I18NSelector/index.tsx
+3
-4
src/ui/I18N/Source/Brazilian/translation.json
src/ui/I18N/Source/Brazilian/translation.json
+0
-0
src/ui/I18N/Source/Chinese/translation.json
src/ui/I18N/Source/Chinese/translation.json
+0
-0
src/ui/I18N/Source/English/translation.json
src/ui/I18N/Source/English/translation.json
+0
-0
src/ui/I18N/Source/French/translation.json
src/ui/I18N/Source/French/translation.json
+0
-0
src/ui/I18N/Source/Japanese/translation.json
src/ui/I18N/Source/Japanese/translation.json
+0
-0
src/ui/I18N/Source/Portuguese/translation.json
src/ui/I18N/Source/Portuguese/translation.json
+0
-0
src/ui/I18N/Source/Spanish/translation.json
src/ui/I18N/Source/Spanish/translation.json
+0
-0
src/ui/I18N/index.ts
src/ui/I18N/index.ts
+11
-22
src/ui/Layout/index.tsx
src/ui/Layout/index.tsx
+11
-11
src/ui/Match/index.tsx
src/ui/Match/index.tsx
+18
-18
No files found.
src/main.tsx
View file @
661061b5
...
@@ -28,7 +28,7 @@ import ReactDOM from "react-dom/client";
...
@@ -28,7 +28,7 @@ import ReactDOM from "react-dom/client";
import
{
theme
}
from
"
@/ui/theme
"
;
import
{
theme
}
from
"
@/ui/theme
"
;
import
{
LanguageProvider
}
from
"
./Language/LanguageContext
"
;
import
{
I18NProvider
}
from
"
./ui/I18N
"
;
import
{
NeosRouter
}
from
"
./ui/NeosRouter
"
;
import
{
NeosRouter
}
from
"
./ui/NeosRouter
"
;
const
root
=
ReactDOM
.
createRoot
(
const
root
=
ReactDOM
.
createRoot
(
...
@@ -36,7 +36,7 @@ const root = ReactDOM.createRoot(
...
@@ -36,7 +36,7 @@ const root = ReactDOM.createRoot(
);
);
root
.
render
(
root
.
render
(
<
Language
Provider
>
<
I18N
Provider
>
<
ConfigProvider
theme=
{
theme
}
locale=
{
zhCN
}
>
<
ConfigProvider
theme=
{
theme
}
locale=
{
zhCN
}
>
<
App
>
<
App
>
<
ProConfigProvider
dark
>
<
ProConfigProvider
dark
>
...
@@ -44,5 +44,5 @@ root.render(
...
@@ -44,5 +44,5 @@ root.render(
</
ProConfigProvider
>
</
ProConfigProvider
>
</
App
>
</
App
>
</
ConfigProvider
>
</
ConfigProvider
>
</
Language
Provider
>,
</
I18N
Provider
>,
);
);
src/
Language/LanguageContext
.tsx
→
src/
ui/I18N/I18NContext/index
.tsx
View file @
661061b5
import
React
,
{
createContext
,
useContext
,
useState
}
from
"
react
"
;
import
React
,
{
createContext
,
useContext
,
useState
}
from
"
react
"
;
interface
Language
ContextType
{
interface
I18N
ContextType
{
language
:
string
;
language
:
string
;
changeLanguage
:
(
newLanguage
:
string
)
=>
void
;
changeLanguage
:
(
newLanguage
:
string
)
=>
void
;
}
}
const
LanguageContext
=
createContext
<
LanguageContextType
|
undefined
>
(
const
I18NContext
=
createContext
<
I18NContextType
|
undefined
>
(
undefined
);
undefined
,
);
export
const
Language
Provider
:
React
.
FC
<
{
children
:
React
.
ReactNode
}
>
=
({
export
const
I18N
Provider
:
React
.
FC
<
{
children
:
React
.
ReactNode
}
>
=
({
children
,
children
,
})
=>
{
})
=>
{
const
[
language
,
setLanguage
]
=
useState
<
string
>
(
"
cn
"
);
// default language
const
[
language
,
setLanguage
]
=
useState
<
string
>
(
"
cn
"
);
// default language
...
@@ -19,16 +17,16 @@ export const LanguageProvider: React.FC<{ children: React.ReactNode }> = ({
...
@@ -19,16 +17,16 @@ export const LanguageProvider: React.FC<{ children: React.ReactNode }> = ({
};
};
return
(
return
(
<
Language
Context
.
Provider
value=
{
{
language
,
changeLanguage
}
}
>
<
I18N
Context
.
Provider
value=
{
{
language
,
changeLanguage
}
}
>
{
children
}
{
children
}
</
Language
Context
.
Provider
>
</
I18N
Context
.
Provider
>
);
);
};
};
export
const
use
Language
=
():
Language
ContextType
=>
{
export
const
use
I18N
=
():
I18N
ContextType
=>
{
const
context
=
useContext
(
Language
Context
);
const
context
=
useContext
(
I18N
Context
);
if
(
!
context
)
{
if
(
!
context
)
{
throw
new
Error
(
"
use
Language must be used within a Language
Provider
"
);
throw
new
Error
(
"
use
I18N must be used within a I18N
Provider
"
);
}
}
return
context
;
return
context
;
};
};
src/
Language/LanguageSelector
.tsx
→
src/
ui/I18N/I18NSelector/index
.tsx
View file @
661061b5
import
React
,
{
useEffect
}
from
"
react
"
;
import
React
,
{
useEffect
}
from
"
react
"
;
import
{
useTranslation
}
from
"
react-i18next
"
;
import
{
useTranslation
}
from
"
react-i18next
"
;
const
Language
Selector
:
React
.
FC
=
()
=>
{
export
const
I18N
Selector
:
React
.
FC
=
()
=>
{
const
{
i18n
}
=
useTranslation
();
const
{
i18n
}
=
useTranslation
();
const
onClickLanguageChange
=
(
e
:
React
.
ChangeEvent
<
HTMLSelectElement
>
)
=>
{
const
onClickLanguageChange
=
(
e
:
React
.
ChangeEvent
<
HTMLSelectElement
>
)
=>
{
...
@@ -10,7 +10,8 @@ const LanguageSelector: React.FC = () => {
...
@@ -10,7 +10,8 @@ const LanguageSelector: React.FC = () => {
};
};
useEffect
(()
=>
{
useEffect
(()
=>
{
//Adding language state as a dependency to force re-render when the language changes
// Adding language state as a dependency to force re-render
// when the language changes
},
[
i18n
.
language
]);
},
[
i18n
.
language
]);
return
(
return
(
...
@@ -25,5 +26,3 @@ const LanguageSelector: React.FC = () => {
...
@@ -25,5 +26,3 @@ const LanguageSelector: React.FC = () => {
</
select
>
</
select
>
);
);
};
};
export
default
LanguageSelector
;
src/
Translation
/Brazilian/translation.json
→
src/
ui/I18N/Source
/Brazilian/translation.json
View file @
661061b5
File moved
src/
Translation
/Chinese/translation.json
→
src/
ui/I18N/Source
/Chinese/translation.json
View file @
661061b5
File moved
src/
Translation
/English/translation.json
→
src/
ui/I18N/Source
/English/translation.json
View file @
661061b5
File moved
src/
Translation
/French/translation.json
→
src/
ui/I18N/Source
/French/translation.json
View file @
661061b5
File moved
src/
Translation
/Japanese/translation.json
→
src/
ui/I18N/Source
/Japanese/translation.json
View file @
661061b5
File moved
src/
Translation
/Portuguese/translation.json
→
src/
ui/I18N/Source
/Portuguese/translation.json
View file @
661061b5
File moved
src/
Translation
/Spanish/translation.json
→
src/
ui/I18N/Source
/Spanish/translation.json
View file @
661061b5
File moved
src/
i18n.tsx
→
src/
ui/I18N/index.ts
View file @
661061b5
export
*
from
"
./I18NContext
"
;
export
*
from
"
./I18NSelector
"
;
import
i18next
from
"
i18next
"
;
import
i18next
from
"
i18next
"
;
import
{
initReactI18next
}
from
"
react-i18next
"
;
import
{
initReactI18next
}
from
"
react-i18next
"
;
import
translationBrazilian
from
"
./Translation/Brazilian/translation.json
"
;
/* Import all translation files */
import
translationChinese
from
"
./Translation/Chinese/translation.json
"
;
import
translationBrazilian
from
"
./Source/Brazilian/translation.json
"
;
//Import all translation files
import
translationChinese
from
"
./Source/Chinese/translation.json
"
;
import
translationEnglish
from
"
./Translation/English/translation.json
"
;
import
translationEnglish
from
"
./Source/English/translation.json
"
;
import
translationFrench
from
"
./Translation/French/translation.json
"
;
import
translationFrench
from
"
./Source/French/translation.json
"
;
import
translationJapanese
from
"
./Translation/Japanese/translation.json
"
;
import
translationJapanese
from
"
./Source/Japanese/translation.json
"
;
import
translationPortuguese
from
"
./Translation/Portuguese/translation.json
"
;
import
translationPortuguese
from
"
./Source/Portuguese/translation.json
"
;
import
translationSpanish
from
"
./Translation/Spanish/translation.json
"
;
import
translationSpanish
from
"
./Source/Spanish/translation.json
"
;
//---Using translation
// const resources = {
// en: {
// translation: translationEnglish,
// },
// es: {
// translation: translationSpanish,
// },
// fr: {
// translation: translationFrench,
// },
// }
//---Using different namespaces
const
resources
=
{
const
resources
=
{
cn
:
{
cn
:
{
Header
:
translationChinese
.
Header
,
Header
:
translationChinese
.
Header
,
...
...
src/ui/Layout/index.tsx
View file @
661061b5
...
@@ -17,9 +17,9 @@ import {
...
@@ -17,9 +17,9 @@ import {
removeCookie
,
removeCookie
,
}
from
"
@/api
"
;
}
from
"
@/api
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
LanguageSelector
from
"
@/Language/LanguageSelector
"
;
import
{
accountStore
}
from
"
@/stores
"
;
import
{
accountStore
}
from
"
@/stores
"
;
import
{
I18NSelector
}
from
"
../I18N
"
;
import
styles
from
"
./index.module.scss
"
;
import
styles
from
"
./index.module.scss
"
;
import
{
import
{
getLoginStatus
,
getLoginStatus
,
...
@@ -60,7 +60,7 @@ const HeaderBtn: React.FC<
...
@@ -60,7 +60,7 @@ const HeaderBtn: React.FC<
};
};
export
const
Component
=
()
=>
{
export
const
Component
=
()
=>
{
const
{
t
}
=
useTranslation
(
"
Header
"
);
const
{
t
:
i18n
}
=
useTranslation
(
"
Header
"
);
// 捕获SSO登录
// 捕获SSO登录
const
routerLocation
=
useLocation
();
const
routerLocation
=
useLocation
();
...
@@ -99,15 +99,15 @@ export const Component = () => {
...
@@ -99,15 +99,15 @@ export const Component = () => {
/>
/>
</
a
>
</
a
>
<
HeaderBtn
to=
"/"
>
{
t
(
"
HomePage
"
)
}
</
HeaderBtn
>
<
HeaderBtn
to=
"/"
>
{
i18n
(
"
HomePage
"
)
}
</
HeaderBtn
>
<
HeaderBtn
to=
"/match"
disabled=
{
!
logined
}
>
<
HeaderBtn
to=
"/match"
disabled=
{
!
logined
}
>
{
t
(
"
Match
"
)
}
{
i18n
(
"
Match
"
)
}
</
HeaderBtn
>
</
HeaderBtn
>
<
HeaderBtn
to=
"/build"
disabled=
{
!
logined
}
>
<
HeaderBtn
to=
"/build"
disabled=
{
!
logined
}
>
{
t
(
"
DeckBuilding
"
)
}
{
i18n
(
"
DeckBuilding
"
)
}
</
HeaderBtn
>
</
HeaderBtn
>
<
span
style=
{
{
flexGrow
:
1
}
}
/>
<
span
style=
{
{
flexGrow
:
1
}
}
/>
<
Language
Selector
/>
<
I18N
Selector
/>
<
span
className=
{
styles
.
profile
}
>
<
span
className=
{
styles
.
profile
}
>
<
Dropdown
<
Dropdown
arrow
arrow
...
@@ -116,14 +116,14 @@ export const Component = () => {
...
@@ -116,14 +116,14 @@ export const Component = () => {
{
{
label
:
(
label
:
(
<
a
href=
{
NeosConfig
.
profileUrl
}
target=
"_blank"
>
<
a
href=
{
NeosConfig
.
profileUrl
}
target=
"_blank"
>
{
t
(
"
PersonalCenter
"
)
}
{
i18n
(
"
PersonalCenter
"
)
}
</
a
>
</
a
>
),
),
},
},
{
{
label
:
(
label
:
(
<
a
href=
"https://ygobbs.com"
target=
"_blank"
>
<
a
href=
"https://ygobbs.com"
target=
"_blank"
>
{
t
(
"
MengkaCommunity
"
)
}
{
i18n
(
"
MengkaCommunity
"
)
}
</
a
>
</
a
>
),
),
},
},
...
@@ -133,16 +133,16 @@ export const Component = () => {
...
@@ -133,16 +133,16 @@ export const Component = () => {
href=
"https://mycard.moe/ygopro/arena/#/"
href=
"https://mycard.moe/ygopro/arena/#/"
target=
"_blank"
target=
"_blank"
>
>
{
t
(
"
DuelDatabase
"
)
}
{
i18n
(
"
DuelDatabase
"
)
}
</
a
>
</
a
>
),
),
},
},
{
{
label
:
logined
?
t
(
"
LogOut
"
)
:
t
(
"
LoginToMengka
"
),
label
:
logined
?
i18n
(
"
LogOut
"
)
:
i18n
(
"
LoginToMengka
"
),
onClick
:
logined
?
onLogout
:
onLogin
,
onClick
:
logined
?
onLogout
:
onLogin
,
},
},
{
{
label
:
t
(
"
Fullscreen
"
),
label
:
i18n
(
"
Fullscreen
"
),
onClick
:
()
=>
document
.
documentElement
.
requestFullscreen
(),
onClick
:
()
=>
document
.
documentElement
.
requestFullscreen
(),
danger
:
true
,
danger
:
true
,
},
},
...
...
src/ui/Match/index.tsx
View file @
661061b5
...
@@ -52,7 +52,7 @@ export const Component: React.FC = () => {
...
@@ -52,7 +52,7 @@ export const Component: React.FC = () => {
const
[
entertainMatchLoading
,
setEntertainMatchLoading
]
=
useState
(
false
);
// 娱乐匹配的loading状态
const
[
entertainMatchLoading
,
setEntertainMatchLoading
]
=
useState
(
false
);
// 娱乐匹配的loading状态
const
[
watchLoading
,
setWatchLoading
]
=
useState
(
false
);
// 观战模式的loading状态
const
[
watchLoading
,
setWatchLoading
]
=
useState
(
false
);
// 观战模式的loading状态
const
navigate
=
useNavigate
();
const
navigate
=
useNavigate
();
const
{
t
}
=
useTranslation
(
"
Match
"
);
const
{
t
:
i18n
}
=
useTranslation
(
"
Match
"
);
// 匹配
// 匹配
const
onMatch
=
async
(
arena
:
"
athletic
"
|
"
entertain
"
)
=>
{
const
onMatch
=
async
(
arena
:
"
athletic
"
|
"
entertain
"
)
=>
{
...
@@ -224,7 +224,7 @@ export const Component: React.FC = () => {
...
@@ -224,7 +224,7 @@ export const Component: React.FC = () => {
<
div
className=
{
styles
.
wrap
}
>
<
div
className=
{
styles
.
wrap
}
>
<
Space
size=
{
16
}
>
<
Space
size=
{
16
}
>
<
Select
<
Select
title=
{
t
(
"
Deck
"
)
}
title=
{
i18n
(
"
Deck
"
)
}
showSearch
showSearch
value=
{
deckName
}
value=
{
deckName
}
style=
{
{
width
:
200
}
}
style=
{
{
width
:
200
}
}
...
@@ -248,13 +248,13 @@ export const Component: React.FC = () => {
...
@@ -248,13 +248,13 @@ export const Component: React.FC = () => {
onClick=
{
()
=>
navigate
(
"
/build
"
)
}
onClick=
{
()
=>
navigate
(
"
/build
"
)
}
size=
"large"
size=
"large"
>
>
{
t
(
"
DeckEdit
"
)
}
{
i18n
(
"
DeckEdit
"
)
}
</
Button
>
</
Button
>
</
Space
>
</
Space
>
<
div
className=
{
styles
[
"
mode-select
"
]
}
>
<
div
className=
{
styles
[
"
mode-select
"
]
}
>
<
Mode
<
Mode
title=
{
t
(
"
MCCompetitiveMatchmakingTitle
"
)
}
title=
{
i18n
(
"
MCCompetitiveMatchmakingTitle
"
)
}
desc=
{
t
(
"
MCCompetitiveMatchmakingDesc
"
)
}
desc=
{
i18n
(
"
MCCompetitiveMatchmakingDesc
"
)
}
icon=
{
icon=
{
athleticMatchLoading
?
(
athleticMatchLoading
?
(
<
LoadingOutlined
/>
<
LoadingOutlined
/>
...
@@ -265,8 +265,8 @@ export const Component: React.FC = () => {
...
@@ -265,8 +265,8 @@ export const Component: React.FC = () => {
onClick=
{
onCompetitiveMatch
}
onClick=
{
onCompetitiveMatch
}
/>
/>
<
Mode
<
Mode
title=
{
t
(
"
MCCasualMatchmakingTitle
"
)
}
title=
{
i18n
(
"
MCCasualMatchmakingTitle
"
)
}
desc=
{
t
(
"
MCCasualMatchmakingDesc
"
)
}
desc=
{
i18n
(
"
MCCasualMatchmakingDesc
"
)
}
icon=
{
icon=
{
entertainMatchLoading
?
(
entertainMatchLoading
?
(
<
LoadingOutlined
/>
<
LoadingOutlined
/>
...
@@ -277,20 +277,20 @@ export const Component: React.FC = () => {
...
@@ -277,20 +277,20 @@ export const Component: React.FC = () => {
onClick=
{
onEntertainMatch
}
onClick=
{
onEntertainMatch
}
/>
/>
<
Mode
<
Mode
title=
{
t
(
"
MCCustomRoomTitle
"
)
}
title=
{
i18n
(
"
MCCustomRoomTitle
"
)
}
desc=
{
t
(
"
MCCustomRoomDesc
"
)
}
desc=
{
i18n
(
"
MCCustomRoomDesc
"
)
}
icon=
{
<
BulbOutlined
/>
}
icon=
{
<
BulbOutlined
/>
}
onClick=
{
onMCCustomRoom
}
onClick=
{
onMCCustomRoom
}
/>
/>
<
Mode
<
Mode
title=
{
t
(
"
MCSpectatorListTitle
"
)
}
title=
{
i18n
(
"
MCSpectatorListTitle
"
)
}
desc=
{
t
(
"
MCSpectatorListDesc
"
)
}
desc=
{
i18n
(
"
MCSpectatorListDesc
"
)
}
icon=
{
watchLoading
?
<
LoadingOutlined
/>
:
<
PlayCircleFilled
/>
}
icon=
{
watchLoading
?
<
LoadingOutlined
/>
:
<
PlayCircleFilled
/>
}
onClick=
{
onMCWatch
}
onClick=
{
onMCWatch
}
/>
/>
<
Mode
<
Mode
title=
{
t
(
"
SinglePlayerModeTitle
"
)
}
title=
{
i18n
(
"
SinglePlayerModeTitle
"
)
}
desc=
{
t
(
"
SinglePlayerModeDesc
"
)
}
desc=
{
i18n
(
"
SinglePlayerModeDesc
"
)
}
icon=
{
icon=
{
singleLoading
?
(
singleLoading
?
(
<
LoadingOutlined
/>
<
LoadingOutlined
/>
...
@@ -301,18 +301,18 @@ export const Component: React.FC = () => {
...
@@ -301,18 +301,18 @@ export const Component: React.FC = () => {
onClick=
{
onAIMatch
}
onClick=
{
onAIMatch
}
/>
/>
<
Mode
<
Mode
title=
{
t
(
"
CustomRoomTitle
"
)
}
title=
{
i18n
(
"
CustomRoomTitle
"
)
}
desc=
{
t
(
"
CustomRoomDesc
"
)
}
desc=
{
i18n
(
"
CustomRoomDesc
"
)
}
icon=
{
<
SettingFilled
/>
}
icon=
{
<
SettingFilled
/>
}
onClick=
{
onCustomRoom
}
onClick=
{
onCustomRoom
}
/>
/>
<
Mode
<
Mode
title=
{
t
(
"
ReplayTitle
"
)
}
title=
{
i18n
(
"
ReplayTitle
"
)
}
desc=
{
t
(
"
ReplayDesc
"
)
}
desc=
{
i18n
(
"
ReplayDesc
"
)
}
icon=
{
<
IconFont
type=
"icon-record"
size=
{
24
}
/>
}
icon=
{
<
IconFont
type=
"icon-record"
size=
{
24
}
/>
}
onClick=
{
replayOpen
}
onClick=
{
replayOpen
}
/>
/>
<
Mode
title=
{
t
(
"
WIPTitle
"
)
}
desc=
{
t
(
"
WIPDesc
"
)
}
icon=
{
null
}
/>
<
Mode
title=
{
i18n
(
"
WIPTitle
"
)
}
desc=
{
i18n
(
"
WIPDesc
"
)
}
icon=
{
null
}
/>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
...
...
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