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
8f1aa9a7
Commit
8f1aa9a7
authored
Jun 18, 2024
by
BBeretta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat/language-translation (dev solution provided by ChunChi )
parent
677e08f2
Pipeline
#27842
failed with stages
in 7 minutes and 33 seconds
Changes
9
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
501 additions
and
112 deletions
+501
-112
src/api/cards.ts
src/api/cards.ts
+19
-14
src/api/strings.ts
src/api/strings.ts
+19
-13
src/middleware/sqlite/index.ts
src/middleware/sqlite/index.ts
+20
-19
src/service/room/errorMsg.ts
src/service/room/errorMsg.ts
+49
-6
src/ui/BuildDeck/store.ts
src/ui/BuildDeck/store.ts
+74
-11
src/ui/Duel/Message/PositionModal/index.tsx
src/ui/Duel/Message/PositionModal/index.tsx
+83
-11
src/ui/Duel/PlayMat/Menu/index.tsx
src/ui/Duel/PlayMat/Menu/index.tsx
+142
-27
src/ui/Duel/utils/interactTypeToStringIcon.tsx
src/ui/Duel/utils/interactTypeToStringIcon.tsx
+94
-8
src/ui/I18N/index.ts
src/ui/I18N/index.ts
+1
-3
No files found.
src/api/cards.ts
View file @
8f1aa9a7
...
...
@@ -86,22 +86,27 @@ export function getCardImgUrl(code: number, back = false) {
return
`
${
ASSETS_BASE
}
/card_back.jpg`
;
}
// Define translations for different languages (I18N)
const
language
=
localStorage
.
getItem
(
"
language
"
);
let
imgUrl
;
switch
(
language
)
{
case
"
en
"
:
case
"
br
"
:
case
"
pt
"
:
case
"
fr
"
:
case
"
es
"
:
imgUrl
=
NeosConfig
.
releaseImgUrl
.
replace
(
"
zh-CN
"
,
"
en-US
"
);
break
;
default
:
imgUrl
=
NeosConfig
.
releaseImgUrl
;
break
;
}
/* End of definition (I18N) */
if
(
isSuperReleaseCard
(
code
))
{
return
`
${
NeosConfig
.
preReleaseImgUrl
}
/
${
code
}
.jpg`
;
}
else
{
const
language
=
localStorage
.
getItem
(
"
language
"
);
if
(
language
===
"
en
"
||
language
===
"
br
"
||
language
===
"
pt
"
||
language
===
"
fr
"
||
language
===
"
es
"
)
{
NeosConfig
.
releaseImgUrl
=
NeosConfig
.
releaseImgUrl
.
replace
(
"
zh-CN
"
,
"
en-US
"
,
);
}
return
`
${
NeosConfig
.
releaseImgUrl
}
/
${
code
}
.jpg`
;
return
`
${
imgUrl
}
/
${
code
}
.jpg`
;
}
}
src/api/strings.ts
View file @
8f1aa9a7
...
...
@@ -9,20 +9,26 @@ export async function initStrings() {
const
language
=
localStorage
.
getItem
(
"
language
"
)
||
"
cn
"
;
//It currently only supports en-US, es-ES, ja-JP, ko-KR, zh-CN
if
(
language
===
"
en
"
||
language
===
"
br
"
||
language
===
"
pt
"
||
language
===
"
fr
"
)
{
stringsUrl
=
stringsUrl
.
replace
(
"
zh-CN
"
,
"
en-US
"
);
}
else
if
(
language
===
"
ja
"
)
{
stringsUrl
=
stringsUrl
.
replace
(
"
zh-CN
"
,
"
ja-JP
"
);
}
else
if
(
language
===
"
es
"
)
{
stringsUrl
=
stringsUrl
.
replace
(
"
zh-CN
"
,
"
es-ES
"
);
}
else
if
(
language
===
"
ko
"
)
{
stringsUrl
=
stringsUrl
.
replace
(
"
zh-CN
"
,
"
ko-KR
"
);
switch
(
language
)
{
case
"
en
"
:
case
"
br
"
:
case
"
pt
"
:
case
"
fr
"
:
stringsUrl
=
stringsUrl
.
replace
(
"
zh-CN
"
,
"
en-US
"
);
break
;
case
"
ja
"
:
stringsUrl
=
stringsUrl
.
replace
(
"
zh-CN
"
,
"
ja-JP
"
);
break
;
case
"
es
"
:
stringsUrl
=
stringsUrl
.
replace
(
"
zh-CN
"
,
"
es-ES
"
);
break
;
case
"
ko
"
:
stringsUrl
=
stringsUrl
.
replace
(
"
zh-CN
"
,
"
ko-KR
"
);
break
;
default
:
break
;
}
const
strings
=
await
(
await
fetch
(
stringsUrl
)).
text
();
...
...
src/middleware/sqlite/index.ts
View file @
8f1aa9a7
...
...
@@ -62,6 +62,24 @@ interface YgoDbs {
let
YGODBS
:
YgoDbs
=
{
release
:
null
,
preRelease
:
null
};
//It currently only supports en-US, es-ES, ja-JP, ko-KR, zh-CN
// Function to update URLs based on the language
function
updateDbUrls
(
info
:
any
,
language
:
string
):
void
{
const
languageMap
:
{
[
key
:
string
]:
string
}
=
{
en
:
"
en-US
"
,
br
:
"
en-US
"
,
pt
:
"
en-US
"
,
fr
:
"
en-US
"
,
ja
:
"
ja-JP
"
,
ko
:
"
ko-KR
"
,
es
:
"
es-ES
"
,
};
const
locale
=
languageMap
[
language
]
||
"
zh-CN
"
;
info
.
releaseDbUrl
=
info
.
releaseDbUrl
.
replace
(
"
zh-CN
"
,
locale
);
info
.
preReleaseDbUrl
=
info
.
preReleaseDbUrl
.
replace
(
"
zh-CN
"
,
locale
);
}
// FIXME: 应该有个返回值,告诉业务方本次请求的结果,比如初始化DB失败
function
helper
<
T
extends
sqliteCmd
>
(
action
:
sqliteAction
<
T
>
)
{
switch
(
action
.
cmd
)
{
...
...
@@ -69,25 +87,8 @@ function helper<T extends sqliteCmd>(action: sqliteAction<T>) {
const
info
=
action
.
initInfo
;
if
(
info
)
{
const
language
=
localStorage
.
getItem
(
"
language
"
)
||
"
cn
"
;
//It currently only supports en-US, es-ES, ja-JP, ko-KR, zh-CN
if
(
language
===
"
en
"
||
language
===
"
br
"
||
language
===
"
pt
"
||
language
===
"
fr
"
)
{
info
.
releaseDbUrl
=
info
.
releaseDbUrl
.
replace
(
"
zh-CN
"
,
"
en-US
"
);
info
.
preReleaseDbUrl
=
info
.
preReleaseDbUrl
.
replace
(
"
zh-CN
"
,
"
en-US
"
);
}
else
if
(
language
===
"
ja
"
)
{
info
.
releaseDbUrl
=
info
.
releaseDbUrl
.
replace
(
"
zh-CN
"
,
"
ja-JP
"
);
info
.
preReleaseDbUrl
=
info
.
preReleaseDbUrl
.
replace
(
"
zh-CN
"
,
"
ja-JP
"
);
}
else
if
(
language
===
"
ko
"
)
{
info
.
releaseDbUrl
=
info
.
releaseDbUrl
.
replace
(
"
zh-CN
"
,
"
ko-KR
"
);
info
.
preReleaseDbUrl
=
info
.
preReleaseDbUrl
.
replace
(
"
zh-CN
"
,
"
ko-KR
"
);
}
else
if
(
language
===
"
es
"
)
{
info
.
releaseDbUrl
=
info
.
releaseDbUrl
.
replace
(
"
zh-CN
"
,
"
es-ES
"
);
info
.
preReleaseDbUrl
=
info
.
preReleaseDbUrl
.
replace
(
"
zh-CN
"
,
"
es-ES
"
);
}
// Update URLs based on the language
updateDbUrls
(
info
,
language
);
const
releasePromise
=
pfetch
(
info
.
releaseDbUrl
,
{
progressCallback
:
action
.
initInfo
?.
progressCallback
,
...
...
src/service/room/errorMsg.ts
View file @
8f1aa9a7
...
...
@@ -15,15 +15,58 @@ const DECKERROR_EXTRACOUNT = 0x7;
const
DECKERROR_SIDECOUNT
=
0x8
;
const
DECKERROR_NOTAVAIL
=
0x9
;
const
language
=
localStorage
.
getItem
(
"
language
"
);
const
mainDeckWarining
=
language
!==
"
cn
"
?
"
The main deck should contain 40-60 cards.
"
:
"
主卡组数量应为40-60张
"
;
// Define the possible language codes (I18N)
type
Language
=
"
en
"
|
"
br
"
|
"
pt
"
|
"
fr
"
|
"
ja
"
|
"
ko
"
|
"
es
"
|
"
cn
"
;
// Define the structure for the messages (I18N)
const
messages
:
Record
<
Language
,
{
mainDeckWarning
:
string
;
extraDeckWarning
:
string
}
>
=
{
en
:
{
mainDeckWarning
:
"
The number of Main Deck should be 40-60 cards
"
,
extraDeckWarning
:
"
The number of Extra Deck should be 0-15
"
,
},
br
:
{
mainDeckWarning
:
"
The number of Main Deck should be 40-60 cards
"
,
extraDeckWarning
:
"
The number of Extra Deck should be 0-15
"
,
},
pt
:
{
mainDeckWarning
:
"
The number of Main Deck should be 40-60 cards
"
,
extraDeckWarning
:
"
The number of Extra Deck should be 0-15
"
,
},
fr
:
{
mainDeckWarning
:
"
The number of Main Deck should be 40-60 cards
"
,
extraDeckWarning
:
"
The number of Extra Deck should be 0-15
"
,
},
ja
:
{
mainDeckWarning
:
"
The number of Main Deck should be 40-60 cards
"
,
extraDeckWarning
:
"
The number of Extra Deck should be 0-15
"
,
},
ko
:
{
mainDeckWarning
:
"
The number of Main Deck should be 40-60 cards
"
,
extraDeckWarning
:
"
The number of Extra Deck should be 0-15
"
,
},
es
:
{
mainDeckWarning
:
"
The number of Main Deck should be 40-60 cards
"
,
extraDeckWarning
:
"
The number of Extra Deck should be 0-15
"
,
},
cn
:
{
mainDeckWarning
:
"
主卡组数量应为40-60张
"
,
extraDeckWarning
:
"
额外卡组数量应为0-15张
"
,
},
};
/* End of definition (I18N) */
export
default
async
function
handleErrorMsg
(
errorMsg
:
ygopro
.
StocErrorMsg
)
{
const
{
error_type
,
error_code
}
=
errorMsg
;
playEffect
(
AudioActionType
.
SOUND_INFO
);
// Get the language from localStorage or default to 'cn' (I18N)
const
language
=
(
localStorage
.
getItem
(
"
language
"
)
||
"
cn
"
)
as
Language
;
const
mainDeckWarning
=
messages
[
language
].
mainDeckWarning
;
//const extraDeckWarning = messages[language].extraDeckWarning;
switch
(
error_type
)
{
case
ErrorType
.
JOINERROR
:
{
roomStore
.
errorMsg
=
fetchStrings
(
Region
.
System
,
1403
+
error_code
);
...
...
@@ -63,7 +106,7 @@ export default async function handleErrorMsg(errorMsg: ygopro.StocErrorMsg) {
break
;
}
case
DECKERROR_MAINCOUNT
:
{
roomStore
.
errorMsg
=
mainDeckWar
i
ning
;
roomStore
.
errorMsg
=
mainDeckWarning
;
break
;
}
case
DECKERROR_EXTRACOUNT
:
{
...
...
src/ui/BuildDeck/store.ts
View file @
8f1aa9a7
...
...
@@ -7,17 +7,80 @@ import { Type } from "@/ui/Shared/DeckZone";
import
{
compareCards
,
type
EditingDeck
}
from
"
./utils
"
;
const
language
=
localStorage
.
getItem
(
"
language
"
);
const
cardTypeNotMatch
=
language
!==
"
cn
"
?
"
The Card Type does not match
"
:
"
卡片种类不符合
"
;
const
exceedsNumberCardsSameName
=
language
!==
"
cn
"
?
"
Exceeds the number of cards with the same name
"
:
"
超过同名卡
"
;
const
limitCards
=
language
!==
"
cn
"
?
"
Limit of cards
"
:
"
张的上限
"
;
const
exceedsLimit
=
language
!==
"
cn
"
?
"
Exceeds the limit
"
:
"
超过
"
;
const
cannotAddTokens
=
language
!==
"
cn
"
?
"
Cannot add tokens
"
:
"
不能添加衍生物
"
;
// Define the possible language codes (I18N)
type
Language
=
"
en
"
|
"
br
"
|
"
pt
"
|
"
fr
"
|
"
ja
"
|
"
ko
"
|
"
es
"
|
"
cn
"
;
// Define the structure for the messages (I18N)
const
messages
:
Record
<
Language
,
{
cardTypeNotMatch
:
string
;
exceedsNumberCardsSameName
:
string
,
limitCards
:
string
,
exceedsLimit
:
string
,
cannotAddTokens
:
string
}
>
=
{
en
:
{
cardTypeNotMatch
:
"
The Card Type does not match
"
,
exceedsNumberCardsSameName
:
"
The number of Extra Deck should be 0-15
"
,
limitCards
:
"
Limit of cards
"
,
exceedsLimit
:
"
Exceeds the limit
"
,
cannotAddTokens
:
"
Cannot add tokens
"
},
br
:
{
cardTypeNotMatch
:
"
The Card Type does not match
"
,
exceedsNumberCardsSameName
:
"
The number of Extra Deck should be 0-15
"
,
limitCards
:
"
Limit of cards
"
,
exceedsLimit
:
"
Exceeds the limit
"
,
cannotAddTokens
:
"
Cannot add tokens
"
},
pt
:
{
cardTypeNotMatch
:
"
The Card Type does not match
"
,
exceedsNumberCardsSameName
:
"
The number of Extra Deck should be 0-15
"
,
limitCards
:
"
Limit of cards
"
,
exceedsLimit
:
"
Exceeds the limit
"
,
cannotAddTokens
:
"
Cannot add tokens
"
},
fr
:
{
cardTypeNotMatch
:
"
The Card Type does not match
"
,
exceedsNumberCardsSameName
:
"
The number of Extra Deck should be 0-15
"
,
limitCards
:
"
Limit of cards
"
,
exceedsLimit
:
"
Exceeds the limit
"
,
cannotAddTokens
:
"
Cannot add tokens
"
},
ja
:
{
cardTypeNotMatch
:
"
The Card Type does not match
"
,
exceedsNumberCardsSameName
:
"
The number of Extra Deck should be 0-15
"
,
limitCards
:
"
Limit of cards
"
,
exceedsLimit
:
"
Exceeds the limit
"
,
cannotAddTokens
:
"
Cannot add tokens
"
},
ko
:
{
cardTypeNotMatch
:
"
The Card Type does not match
"
,
exceedsNumberCardsSameName
:
"
The number of Extra Deck should be 0-15
"
,
limitCards
:
"
Limit of cards
"
,
exceedsLimit
:
"
Exceeds the limit
"
,
cannotAddTokens
:
"
Cannot add tokens
"
},
es
:
{
cardTypeNotMatch
:
"
The Card Type does not match
"
,
exceedsNumberCardsSameName
:
"
Exceeds the number of cards with the same name
"
,
limitCards
:
"
Limit of cards
"
,
exceedsLimit
:
"
Exceeds the limit
"
,
cannotAddTokens
:
"
Cannot add tokens
"
},
cn
:
{
cardTypeNotMatch
:
"
卡片种类不符合
"
,
exceedsNumberCardsSameName
:
"
超过同名卡
"
,
limitCards
:
"
张的上限
"
,
exceedsLimit
:
"
超过
"
,
cannotAddTokens
:
"
不能添加衍生物
"
},
};
// Get the language from localStorage or default to 'cn' (I18N)
const
language
=
(
localStorage
.
getItem
(
"
language
"
)
||
"
cn
"
)
as
Language
;
const
cardTypeNotMatch
=
messages
[
language
].
cardTypeNotMatch
;
const
exceedsNumberCardsSameName
=
messages
[
language
].
exceedsNumberCardsSameName
;
const
limitCards
=
messages
[
language
].
limitCards
;
const
exceedsLimit
=
messages
[
language
].
exceedsLimit
;
const
cannotAddTokens
=
messages
[
language
].
cannotAddTokens
;
/* End of definition (I18N) */
export
const
editDeckStore
=
proxy
({
deckName
:
""
,
...
...
src/ui/Duel/Message/PositionModal/index.tsx
View file @
8f1aa9a7
...
...
@@ -16,9 +16,83 @@ const defaultProps = { isOpen: false, positions: [] };
const
localStore
=
proxy
<
PositionModalProps
>
(
defaultProps
);
const
language
=
localStorage
.
getItem
(
"
language
"
);
const
title
=
language
!==
"
cn
"
?
"
Please select a position
"
:
"
请选择表示形式
"
;
// Define a type for translations with an index signature (I18N)
interface
Translations
{
[
key
:
string
]:
{
Title
:
string
,
FACEUP_ATTACK
:
string
;
FACEUP_DEFENSE
:
string
;
FACEDOWN_ATTACK
:
string
;
FACEDOWN_DEFENSE
:
string
;
};
}
// Retrieve language from localStorage or default to "cn"
const
language
=
localStorage
.
getItem
(
"
language
"
)
||
"
cn
"
;
// Define translations for different languages (I18N)
const
translations
:
Translations
=
{
en
:
{
Title
:
"
Please select a position
"
,
FACEUP_ATTACK
:
"
Face-Up Attack
"
,
FACEUP_DEFENSE
:
"
Face-Up Defense
"
,
FACEDOWN_ATTACK
:
"
Face-Down Attack
"
,
FACEDOWN_DEFENSE
:
"
Face-Down Defense
"
,
},
br
:
{
Title
:
"
Por favor, selecione uma posição
"
,
FACEUP_ATTACK
:
"
Ataque com a Face para Cima
"
,
FACEUP_DEFENSE
:
"
Defesa com a Face para Cima
"
,
FACEDOWN_ATTACK
:
"
Ataque com a Face para Baixo
"
,
FACEDOWN_DEFENSE
:
"
Defesa com a Face para Baixo
"
,
},
pt
:
{
Title
:
"
Por favor, selecione uma posição
"
,
FACEUP_ATTACK
:
"
Ataque com a Face para Cima
"
,
FACEUP_DEFENSE
:
"
Defesa com a Face para Cima
"
,
FACEDOWN_ATTACK
:
"
Ataque com a Face para Baixo
"
,
FACEDOWN_DEFENSE
:
"
Defesa com a Face para Baixo
"
,
},
fr
:
{
Title
:
"
Veuillez sélectionner une position
"
,
FACEUP_ATTACK
:
"
Attaque Face Visible
"
,
FACEUP_DEFENSE
:
"
Défense Face Visible
"
,
FACEDOWN_ATTACK
:
"
Attaque Face Cachée
"
,
FACEDOWN_DEFENSE
:
"
Défense Face Cachée
"
,
},
ja
:
{
Title
:
"
ポジションを選択してください
"
,
FACEUP_ATTACK
:
"
表側攻撃表示
"
,
FACEUP_DEFENSE
:
"
表側守備表示
"
,
FACEDOWN_ATTACK
:
"
裏側攻撃表示
"
,
FACEDOWN_DEFENSE
:
"
裏側守備表示
"
,
},
ko
:
{
Title
:
"
포지션을 선택해주세요
"
,
FACEUP_ATTACK
:
"
앞면 공격 표시
"
,
FACEUP_DEFENSE
:
"
앞면 수비 표시
"
,
FACEDOWN_ATTACK
:
"
뒷면 공격 표시
"
,
FACEDOWN_DEFENSE
:
"
뒷면 수비 표시
"
,
},
es
:
{
Title
:
"
Por favor, seleccione una posición
"
,
FACEUP_ATTACK
:
"
Ataque en Posición de Ataque
"
,
FACEUP_DEFENSE
:
"
Defensa en Posición de Ataque
"
,
FACEDOWN_ATTACK
:
"
Ataque en Posición de Defensa
"
,
FACEDOWN_DEFENSE
:
"
Defensa en Posición de Defensa
"
,
},
cn
:
{
Title
:
"
请选择表示形式
"
,
FACEUP_ATTACK
:
"
正面攻击形式
"
,
FACEUP_DEFENSE
:
"
正面防守形式
"
,
FACEDOWN_ATTACK
:
"
背面攻击形式
"
,
FACEDOWN_DEFENSE
:
"
背面防守形式
"
,
},
};
// // Define translations for different languages (I18N)
// const title = language !== "cn" ? "Please select a position" : "请选择表示形式";
// const test = translations[language].Title
export
const
PositionModal
=
()
=>
{
const
{
isOpen
,
positions
}
=
useSnapshot
(
localStore
);
const
[
selected
,
setSelected
]
=
useState
<
ygopro
.
CardPosition
|
undefined
>
(
...
...
@@ -27,7 +101,7 @@ export const PositionModal = () => {
return
(
<
NeosModal
title=
{
title
}
title=
{
t
ranslations
[
language
].
T
itle
}
open=
{
isOpen
}
footer=
{
<
Button
...
...
@@ -63,24 +137,22 @@ export const PositionModal = () => {
);
};
// Function to get card position based on language
function
cardPosition
(
position
:
ygopro
.
CardPosition
):
string
{
const
faceUpAtk
=
language
!==
"
cn
"
?
"
Face-Up Attack
"
:
"
正面攻击形式
"
;
const
faceUpDef
=
language
!==
"
cn
"
?
"
Face-Up Defense
"
:
"
正面防守形式
"
;
const
faceDownAtk
=
language
!==
"
cn
"
?
"
Face-Down Attack
"
:
"
背面攻击形式
"
;
const
faceDownDef
=
language
!==
"
cn
"
?
"
Face-Down Defense
"
:
"
背面防守形式
"
;
const
messages
=
translations
[
language
];
switch
(
position
)
{
case
ygopro
.
CardPosition
.
FACEUP_ATTACK
:
{
return
faceUpAtk
;
return
messages
.
FACEUP_ATTACK
;
;
}
case
ygopro
.
CardPosition
.
FACEUP_DEFENSE
:
{
return
faceUpDef
;
return
messages
.
FACEUP_DEFENSE
;
}
case
ygopro
.
CardPosition
.
FACEDOWN_ATTACK
:
{
return
faceDownAtk
;
return
messages
.
FACEDOWN_ATTACK
;
;
}
case
ygopro
.
CardPosition
.
FACEDOWN_DEFENSE
:
{
return
faceDownDef
;
return
messages
.
FACEDOWN_DEFENSE
;
}
default
:
{
return
"
[?]
"
;
...
...
src/ui/Duel/PlayMat/Menu/index.tsx
View file @
8f1aa9a7
...
...
@@ -39,22 +39,137 @@ import { openChatBox } from "../ChatBox";
const
{
useToken
}
=
theme
;
const
FINISH_CANCEL_RESPONSE
=
-
1
;
const
language
=
localStorage
.
getItem
(
"
language
"
);
const
drawPhase
=
language
!==
"
cn
"
?
"
Draw
"
:
"
抽卡阶段
"
;
const
standbyPhase
=
language
!==
"
cn
"
?
"
Standhy Phase
"
:
"
准备阶段
"
;
const
mainPhase1
=
language
!==
"
cn
"
?
"
Main Phase 1
"
:
"
主要阶段 1
"
;
const
battlePhase
=
language
!==
"
cn
"
?
"
Battle Phase
"
:
"
战斗阶段
"
;
const
battleStart
=
language
!==
"
cn
"
?
"
Battle Start
"
:
"
战斗开始
"
;
const
battleStep
=
language
!==
"
cn
"
?
"
Battle Step
"
:
"
战斗步骤
"
;
const
damage
=
language
!==
"
cn
"
?
"
Damage Step
"
:
"
伤害步骤
"
;
const
damageCalc
=
language
!==
"
cn
"
?
"
Damage Step (Damage Calculation)
"
:
"
伤害步骤(伤害计算)
"
;
const
mainPhase2
=
language
!==
"
cn
"
?
"
Main Phase 2
"
:
"
主要阶段 2
"
;
const
endPhase
=
language
!==
"
cn
"
?
"
End Phase
"
:
"
结束阶段
"
;
const
unknown
=
language
!==
"
cn
"
?
"
Unknown
"
:
"
未知阶段
"
;
// Define the possible language codes (I18N)
type
Language
=
"
en
"
|
"
br
"
|
"
pt
"
|
"
fr
"
|
"
ja
"
|
"
ko
"
|
"
es
"
|
"
cn
"
;
// Define the structure for the messages (I18N)
const
messages
:
Record
<
Language
,
{
drawPhase
:
string
;
standbyPhase
:
string
,
mainPhase1
:
string
,
battlePhase
:
string
,
battleStart
:
string
,
battleStep
:
string
,
damage
:
string
,
damageCalc
:
string
,
mainPhase2
:
string
,
endPhase
:
string
,
unknown
:
string
}
>
=
{
en
:
{
drawPhase
:
"
Draw
"
,
standbyPhase
:
"
Standhy Phase
"
,
mainPhase1
:
"
Main Phase 1
"
,
battlePhase
:
"
Battle Phase
"
,
battleStart
:
"
Battle Start
"
,
battleStep
:
"
Battle Step
"
,
damage
:
"
Damage Step
"
,
damageCalc
:
"
Damage Step (Damage Calculation)
"
,
mainPhase2
:
"
Main Phase 2
"
,
endPhase
:
"
End Phase
"
,
unknown
:
"
Unknown
"
},
br
:
{
drawPhase
:
"
Compra
"
,
standbyPhase
:
"
Fase de Espera
"
,
mainPhase1
:
"
Fase Principal 1
"
,
battlePhase
:
"
Fase de Batalha
"
,
battleStart
:
"
Início da Batalha
"
,
battleStep
:
"
Fase da Batalha
"
,
damage
:
"
Fase de Dano
"
,
damageCalc
:
"
Fase de Dano (Cálculo de Dano)
"
,
mainPhase2
:
"
Fase Principal 2
"
,
endPhase
:
"
Fase Final
"
,
unknown
:
"
Desconhecido
"
},
pt
:
{
drawPhase
:
"
Compra
"
,
standbyPhase
:
"
Fase de Espera
"
,
mainPhase1
:
"
Fase Principal 1
"
,
battlePhase
:
"
Fase de Batalha
"
,
battleStart
:
"
Início da Batalha
"
,
battleStep
:
"
Fase da Batalha
"
,
damage
:
"
Fase de Dano
"
,
damageCalc
:
"
Fase de Dano (Cálculo de Dano)
"
,
mainPhase2
:
"
Fase Principal 2
"
,
endPhase
:
"
Fase Final
"
,
unknown
:
"
Desconhecido
"
},
fr
:
{
drawPhase
:
"
Pioche
"
,
standbyPhase
:
"
Phase de Standby
"
,
mainPhase1
:
"
Phase Principale 1
"
,
battlePhase
:
"
Phase de Bataille
"
,
battleStart
:
"
Début de la Bataille
"
,
battleStep
:
"
Étape de Bataille
"
,
damage
:
"
Étape de Dégâts
"
,
damageCalc
:
"
Étape de Dégâts (Calcul des Dégâts)
"
,
mainPhase2
:
"
Phase Principale 2
"
,
endPhase
:
"
Phase Finale
"
,
unknown
:
"
Inconnu
"
},
ja
:
{
drawPhase
:
"
ドロー
"
,
standbyPhase
:
"
スタンバイフェイズ
"
,
mainPhase1
:
"
メインフェイズ 1
"
,
battlePhase
:
"
バトルフェイズ
"
,
battleStart
:
"
バトル開始
"
,
battleStep
:
"
バトルステップ
"
,
damage
:
"
ダメージステップ
"
,
damageCalc
:
"
ダメージステップ(ダメージ計算)
"
,
mainPhase2
:
"
メインフェイズ 2
"
,
endPhase
:
"
エンドフェイズ
"
,
unknown
:
"
未知
"
},
ko
:
{
drawPhase
:
"
드로우
"
,
standbyPhase
:
"
대기 페이즈
"
,
mainPhase1
:
"
메인 페이즈 1
"
,
battlePhase
:
"
배틀 페이즈
"
,
battleStart
:
"
배틀 시작
"
,
battleStep
:
"
배틀 스텝
"
,
damage
:
"
데미지 스텝
"
,
damageCalc
:
"
데미지 스텝 (데미지 계산)
"
,
mainPhase2
:
"
메인 페이즈 2
"
,
endPhase
:
"
엔드 페이즈
"
,
unknown
:
"
알 수 없음
"
},
es
:
{
drawPhase
:
"
Robo
"
,
standbyPhase
:
"
Fase de Espera
"
,
mainPhase1
:
"
Fase Principal 1
"
,
battlePhase
:
"
Fase de Batalla
"
,
battleStart
:
"
Inicio de Batalla
"
,
battleStep
:
"
Paso de Batalla
"
,
damage
:
"
Paso de Daño
"
,
damageCalc
:
"
Paso de Daño (Cálculo de Daño)
"
,
mainPhase2
:
"
Fase Principal 2
"
,
endPhase
:
"
Fase Final
"
,
unknown
:
"
Desconocido
"
},
cn
:
{
drawPhase
:
"
抽卡阶段
"
,
standbyPhase
:
"
准备阶段
"
,
mainPhase1
:
"
主要阶段 1
"
,
battlePhase
:
"
战斗阶段
"
,
battleStart
:
"
战斗开始
"
,
battleStep
:
"
战斗步骤
"
,
damage
:
"
伤害步骤
"
,
damageCalc
:
"
伤害步骤(伤害计算)
"
,
mainPhase2
:
"
主要阶段 2
"
,
endPhase
:
"
结束阶段
"
,
unknown
:
"
未知阶段
"
,
},
};
// Get the language from localStorage or default to 'cn' (I18N)
const
language
=
(
localStorage
.
getItem
(
"
language
"
)
||
"
cn
"
)
as
Language
;
const
drawPhase
=
messages
[
language
].
drawPhase
;
const
standbyPhase
=
messages
[
language
].
standbyPhase
;
const
mainPhase1
=
messages
[
language
].
mainPhase1
;
const
battlePhase
=
messages
[
language
].
battlePhase
;
const
battleStart
=
messages
[
language
].
battleStart
;
const
battleStep
=
messages
[
language
].
battleStep
;
const
damage
=
messages
[
language
].
damage
;
const
damageCalc
=
messages
[
language
].
damageCalc
;
const
mainPhase2
=
messages
[
language
].
mainPhase2
;
const
endPhase
=
messages
[
language
].
endPhase
;
const
unknown
=
messages
[
language
].
unknown
;
/* End of definition (I18N) */
// PhaseType, 中文, response, 是否显示,是否禁用
const
initialPhaseBind
:
[
...
...
@@ -64,18 +179,18 @@ const initialPhaseBind: [
show
:
boolean
,
disabled
:
boolean
,
][]
=
[
[
PhaseType
.
DRAW
,
drawPhase
,
-
1
,
true
,
true
],
[
PhaseType
.
STANDBY
,
standbyPhase
,
-
1
,
true
,
true
],
[
PhaseType
.
MAIN1
,
mainPhase1
,
-
1
,
true
,
true
],
[
PhaseType
.
BATTLE
,
battlePhase
,
6
,
true
,
false
],
[
PhaseType
.
BATTLE_START
,
battleStart
,
3
,
false
,
true
],
[
PhaseType
.
BATTLE_STEP
,
battleStep
,
3
,
false
,
true
],
[
PhaseType
.
DAMAGE
,
damage
,
3
,
false
,
true
],
[
PhaseType
.
DAMAGE_GAL
,
damageCalc
,
3
,
false
,
true
],
[
PhaseType
.
MAIN2
,
mainPhase2
,
2
,
true
,
false
],
[
PhaseType
.
END
,
endPhase
,
7
,
true
,
false
],
[
PhaseType
.
UNKNOWN
,
unknown
,
-
1
,
false
,
true
],
];
[
PhaseType
.
DRAW
,
drawPhase
,
-
1
,
true
,
true
],
[
PhaseType
.
STANDBY
,
standbyPhase
,
-
1
,
true
,
true
],
[
PhaseType
.
MAIN1
,
mainPhase1
,
-
1
,
true
,
true
],
[
PhaseType
.
BATTLE
,
battlePhase
,
6
,
true
,
false
],
[
PhaseType
.
BATTLE_START
,
battleStart
,
3
,
false
,
true
],
[
PhaseType
.
BATTLE_STEP
,
battleStep
,
3
,
false
,
true
],
[
PhaseType
.
DAMAGE
,
damage
,
3
,
false
,
true
],
[
PhaseType
.
DAMAGE_GAL
,
damageCalc
,
3
,
false
,
true
],
[
PhaseType
.
MAIN2
,
mainPhase2
,
2
,
true
,
false
],
[
PhaseType
.
END
,
endPhase
,
7
,
true
,
false
],
[
PhaseType
.
UNKNOWN
,
unknown
,
-
1
,
false
,
true
],
];
export
const
Menu
=
()
=>
{
const
{
t
:
i18n
}
=
useTranslation
(
"
Menu
"
);
...
...
src/ui/Duel/utils/interactTypeToStringIcon.tsx
View file @
8f1aa9a7
...
...
@@ -4,16 +4,102 @@ import { IconFont } from "@/ui/Shared";
import
CardPosition
=
ygopro
.
CardPosition
;
const
language
=
localStorage
.
getItem
(
"
language
"
);
// Define the possible language codes (I18N)
type
Language
=
"
en
"
|
"
br
"
|
"
pt
"
|
"
fr
"
|
"
ja
"
|
"
ko
"
|
"
es
"
|
"
cn
"
;
// Define the structure for the messages (I18N)
const
messages
:
Record
<
Language
,
{
sSet
:
string
;
summon
:
string
,
spSummon
:
string
,
posChange
:
string
,
mSet
:
string
,
activate
:
string
,
attack
:
string
}
>
=
{
en
:
{
sSet
:
"
Set
"
,
summon
:
"
Normal Summon
"
,
spSummon
:
"
Special Summon
"
,
posChange
:
"
Change Position
"
,
mSet
:
"
Set
"
,
activate
:
"
Activate
"
,
attack
:
"
Attack
"
},
br
:
{
sSet
:
"
Setar
"
,
summon
:
"
Invocação Normal
"
,
spSummon
:
"
Invocação Especial
"
,
posChange
:
"
Mudar Posição
"
,
mSet
:
"
Setar
"
,
activate
:
"
Ativar
"
,
attack
:
"
Atacar
"
},
pt
:
{
sSet
:
"
Setar
"
,
summon
:
"
Invocação Normal
"
,
spSummon
:
"
Invocação Especial
"
,
posChange
:
"
Mudar Posição
"
,
mSet
:
"
Setar
"
,
activate
:
"
Ativar
"
,
attack
:
"
Atacar
"
},
fr
:
{
sSet
:
"
Poser
"
,
summon
:
"
Invocation Normale
"
,
spSummon
:
"
Invocation Spéciale
"
,
posChange
:
"
Changer de Position
"
,
mSet
:
"
Poser
"
,
activate
:
"
Activer
"
,
attack
:
"
Attaquer
"
},
ja
:
{
sSet
:
"
セット
"
,
summon
:
"
通常召喚
"
,
spSummon
:
"
特殊召喚
"
,
posChange
:
"
表示形式変更
"
,
mSet
:
"
セット
"
,
activate
:
"
発動
"
,
attack
:
"
攻撃
"
},
ko
:
{
sSet
:
"
세트
"
,
summon
:
"
일반 소환
"
,
spSummon
:
"
특수 소환
"
,
posChange
:
"
포지션 변경
"
,
mSet
:
"
세트
"
,
activate
:
"
발동
"
,
attack
:
"
공격
"
},
es
:
{
sSet
:
"
Colocar
"
,
summon
:
"
Invocación Normal
"
,
spSummon
:
"
Invocación Especial
"
,
posChange
:
"
Cambiar Posición
"
,
mSet
:
"
Colocar
"
,
activate
:
"
Activar
"
,
attack
:
"
Atacar
"
},
cn
:
{
sSet
:
"
后场放置
"
,
summon
:
"
普通召唤
"
,
spSummon
:
"
特殊召唤
"
,
posChange
:
"
改变表示形式
"
,
mSet
:
"
前场放置
"
,
activate
:
"
发动效果
"
,
attack
:
"
攻击
"
,
},
};
// Get the language from localStorage or default to 'cn' (I18N)
const
language
=
(
localStorage
.
getItem
(
"
language
"
)
||
"
cn
"
)
as
Language
;
/* End of definition (I18N) */
export
function
interactTypeToString
(
t
:
InteractType
):
string
{
const
sSet
=
language
!==
"
cn
"
?
"
Set
"
:
"
后场放置
"
;
const
summon
=
language
!==
"
cn
"
?
"
Normal Summon
"
:
"
普通召唤
"
;
const
spSummon
=
language
!==
"
cn
"
?
"
Special Summon
"
:
"
特殊召唤
"
;
const
posChange
=
language
!==
"
cn
"
?
"
Change Position
"
:
"
改变表示形式
"
;
const
mSet
=
language
!==
"
cn
"
?
"
Set
"
:
"
前场放置
"
;
const
activate
=
language
!==
"
cn
"
?
"
Activate
"
:
"
发动效果
"
;
const
attack
=
language
!==
"
cn
"
?
"
Attack
"
:
"
攻击
"
;
const
sSet
=
messages
[
language
].
sSet
;
const
summon
=
messages
[
language
].
summon
;
const
spSummon
=
messages
[
language
].
spSummon
;
const
posChange
=
messages
[
language
].
posChange
;
const
mSet
=
messages
[
language
].
mSet
;
const
activate
=
messages
[
language
].
activate
;
const
attack
=
messages
[
language
].
attack
;
switch
(
t
)
{
case
InteractType
.
SUMMON
:
...
...
src/ui/I18N/index.ts
View file @
8f1aa9a7
...
...
@@ -86,9 +86,7 @@ const resources = {
i18next
.
use
(
initReactI18next
).
init
({
resources
,
lng
:
localStorage
.
getItem
(
"
language
"
)
?
localStorage
.
getItem
(
"
language
"
)?.
toString
()
:
"
cn
"
,
//default language
lng
:
localStorage
.
getItem
(
"
language
"
)
??
"
cn
"
,
//default language
});
export
default
i18next
;
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