Skip to content

Commit 9067df6

Browse files
authored
feat: translate-archetypes (#422)
<details> <summary>Looks a bit ugly since official translation are too too long. IMAGE:</summary> ![{2DAA136F-1CBF-4699-8325-0CB186EA0B28}](https://github.com/user-attachments/assets/d9fbf65a-bb4a-4772-97e0-9141b1da7be4) </details> Any suggestion is greatly appreciated. Perhaps implementing images like in aceship? With full name as hover? ![{8663FC8C-ABBE-4B72-99FF-8F23F1BD207C}](https://github.com/user-attachments/assets/49ca1d92-e8ea-4cc5-a75b-d4302bf9cca5) Also, would you prefer merging this to `dev` or to the `editor2` branch to make sure there won't be conflicts later.
2 parents 6a5edd7 + 43947f9 commit 9067df6

File tree

3 files changed

+44
-19
lines changed

3 files changed

+44
-19
lines changed

scripts/shared.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { access } from 'fs/promises'
2-
import { uniq, uniqBy } from 'lodash-es'
2+
import { capitalize, uniq, uniqBy } from 'lodash-es'
33
import fetch from 'node-fetch'
44
import { pinyin } from 'pinyin'
55
import simplebig from 'simplebig'
@@ -102,7 +102,7 @@ export async function getOperators() {
102102
if (!prof) {
103103
const enSubProfName =
104104
subProfDictEN?.[op.subProfessionId]?.subProfessionName ||
105-
subProfDictCN[op.subProfessionId].subProfessionName
105+
capitalize(op.subProfessionId)
106106

107107
professions.push({
108108
id: op.profession,
@@ -120,7 +120,7 @@ export async function getOperators() {
120120
} else if (!prof.sub.find((p) => p.id === op.subProfessionId)) {
121121
const enSubProfName =
122122
subProfDictEN?.[op.subProfessionId]?.subProfessionName ||
123-
subProfDictCN[op.subProfessionId].subProfessionName
123+
capitalize(op.subProfessionId)
124124

125125
prof.sub.push({
126126
id: op.subProfessionId,

src/components/editor/operator/sheet/sheetOperator/ProfClassificationWithFilters.tsx

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ import { Button, Divider, H4, H5 } from '@blueprintjs/core'
22
import { Popover2 } from '@blueprintjs/popover2'
33

44
import clsx from 'clsx'
5+
import { useAtomValue } from 'jotai'
56
import { FC, ImgHTMLAttributes, useEffect, useMemo } from 'react'
67

78
import { PROFESSIONS } from 'models/operator'
89

9-
import { useTranslation } from '../../../../../i18n/i18n'
10+
import { languageAtom, useTranslation } from '../../../../../i18n/i18n'
1011
import {
1112
DEFAULTPROFID,
1213
DEFAULTSUBPROFID,
@@ -25,6 +26,7 @@ export const ProfClassificationWithFilters: FC<
2526
ProfClassificationWithFiltersProp
2627
> = ({ toTop }) => {
2728
const t = useTranslation()
29+
const language = useAtomValue(languageAtom)
2830
const {
2931
useProfFilterState: [{ selectedProf }, setProfFilter],
3032
usePaginationFilterState: [_, setPaginationFilter],
@@ -36,19 +38,31 @@ export const ProfClassificationWithFilters: FC<
3638
id: DEFAULTPROFID.ALL,
3739
name: t.components.editor.operator.sheet.sheetOperator
3840
.ProfClassificationWithFilters.all,
41+
name_en:
42+
t.components.editor.operator.sheet.sheetOperator
43+
.ProfClassificationWithFilters.all,
3944
sub: [],
4045
},
4146
{
4247
id: DEFAULTPROFID.FAV,
4348
name: t.components.editor.operator.sheet.sheetOperator
4449
.ProfClassificationWithFilters.favorites,
50+
name_en:
51+
t.components.editor.operator.sheet.sheetOperator
52+
.ProfClassificationWithFilters.favorites,
4553
sub: [],
4654
},
47-
...PROFESSIONS,
55+
...PROFESSIONS.map((profession) => ({
56+
...profession,
57+
name_en: profession.name_en || profession.name,
58+
})),
4859
{
4960
id: DEFAULTPROFID.OTHERS,
5061
name: t.components.editor.operator.sheet.sheetOperator
5162
.ProfClassificationWithFilters.others,
63+
name_en:
64+
t.components.editor.operator.sheet.sheetOperator
65+
.ProfClassificationWithFilters.others,
5266
sub: [],
5367
},
5468
],
@@ -60,11 +74,17 @@ export const ProfClassificationWithFilters: FC<
6074
id: DEFAULTSUBPROFID.ALL,
6175
name: t.components.editor.operator.sheet.sheetOperator
6276
.ProfClassificationWithFilters.all,
77+
name_en:
78+
t.components.editor.operator.sheet.sheetOperator
79+
.ProfClassificationWithFilters.all,
6380
},
6481
{
6582
id: DEFAULTSUBPROFID.SELECTED,
6683
name: t.components.editor.operator.sheet.sheetOperator
6784
.ProfClassificationWithFilters.selected,
85+
name_en:
86+
t.components.editor.operator.sheet.sheetOperator
87+
.ProfClassificationWithFilters.selected,
6888
},
6989
...(formattedProfessions.find(({ id }) => id === selectedProf[0])?.sub ||
7090
[]),
@@ -95,16 +115,16 @@ export const ProfClassificationWithFilters: FC<
95115
return (
96116
<div className="flex flex-row-reverse relative h-full">
97117
<ul className="h-full flex flex-col w-6 sm:w-12">
98-
{formattedProfessions.map(({ id, name }) => (
118+
{formattedProfessions.map((prof) => (
99119
<ProfIcon
100-
key={id}
101-
profId={id}
102-
name={name}
103-
selected={selectedProf.includes(id)}
120+
key={prof.id}
121+
profId={prof.id}
122+
name={language === 'en' && prof.name_en ? prof.name_en : prof.name}
123+
selected={selectedProf.includes(prof.id)}
104124
onProfClick={() =>
105125
setProfFilter((prev) => ({
106126
...prev,
107-
selectedProf: [id, DEFAULTSUBPROFID.ALL],
127+
selectedProf: [prof.id, DEFAULTSUBPROFID.ALL],
108128
}))
109129
}
110130
/>
@@ -113,22 +133,27 @@ export const ProfClassificationWithFilters: FC<
113133
<Divider className="mr-0" />
114134
<div className="h-full flex flex-col justify-center items-end absolute right-full sm:relative sm:left-0">
115135
<ul>
116-
{subProfs.map(({ id, name }) => (
117-
<li key={id}>
136+
{subProfs.map((subProf) => (
137+
<li key={subProf.id}>
118138
<H4
119139
className={clsx(
120140
'truncate cursor-pointer my-3 opacity-50 hover:underline hover:opacity-90',
121-
selectedProf.includes(id) && '!opacity-100 underline',
122-
name.length > 3 && '!text-base',
141+
selectedProf.includes(subProf.id) && '!opacity-100 underline',
142+
(language === 'en' && subProf.name_en
143+
? subProf.name_en
144+
: subProf.name
145+
).length > 3 && '!text-base',
123146
)}
124147
onClick={() =>
125148
setProfFilter(({ selectedProf, ...rest }) => ({
126-
selectedProf: [selectedProf[0], id],
149+
selectedProf: [selectedProf[0], subProf.id],
127150
...rest,
128151
}))
129152
}
130153
>
131-
{name}
154+
{language === 'en' && subProf.name_en
155+
? subProf.name_en
156+
: subProf.name}
132157
</H4>
133158
</li>
134159
))}

src/models/generated/operators.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4540,7 +4540,7 @@
45404540
{ "id": "librator", "name": "解放者", "name_en": "Liberator" },
45414541
{ "id": "fighter", "name": "斗士", "name_en": "Fighter" },
45424542
{ "id": "hammer", "name": "撼地者", "name_en": "Earthshaker" },
4543-
{ "id": "primguard", "name": "本源近卫", "name_en": "本源近卫" }
4543+
{ "id": "primguard", "name": "本源近卫", "name_en": "Primguard" }
45444544
]
45454545
},
45464546
{
@@ -4646,7 +4646,7 @@
46464646
{ "id": "phalanx", "name": "阵法术师", "name_en": "Phalanx Caster" },
46474647
{ "id": "blastcaster", "name": "轰击术师", "name_en": "Blast Caster" },
46484648
{ "id": "primcaster", "name": "本源术师", "name_en": "Primal Caster" },
4649-
{ "id": "soulcaster", "name": "塑灵术师", "name_en": "塑灵术师" }
4649+
{ "id": "soulcaster", "name": "塑灵术师", "name_en": "Soulcaster" }
46504650
]
46514651
}
46524652
]

0 commit comments

Comments
 (0)