Translate elf pages
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { readdirSync, readJsonFileSync } from '../fs'
|
||||
import { readdirSync, readFileSync, readJsonFileSync } from '../fs'
|
||||
import { compareVersion } from '../../../lib/string'
|
||||
import { ElfData } from '../../../lib/honkai3rd/elfs'
|
||||
|
||||
@@ -8,6 +8,28 @@ const elfDataList = elfFileNameList
|
||||
const filePathname = 'honkai3rd/elfs/' + fileName
|
||||
const data = readJsonFileSync(filePathname) as ElfData
|
||||
|
||||
const krDataFilePath = `honkai3rd/ko-KR/elfs/${data.id}.md`
|
||||
try {
|
||||
const krData = parseElfData(readFileSync(krDataFilePath).toString())
|
||||
data.krName = krData.name
|
||||
data.skillRows.forEach((skillRow, skillRowIndex) => {
|
||||
skillRow.forEach((skill, skillIndex) => {
|
||||
if (krData.skillRows?.[skillRowIndex]?.[skillIndex]?.name != null) {
|
||||
skill.krName = krData.skillRows?.[skillRowIndex]?.[skillIndex]?.name
|
||||
}
|
||||
if (
|
||||
krData.skillRows?.[skillRowIndex]?.[skillIndex]?.description != null
|
||||
) {
|
||||
skill.krDescription =
|
||||
krData.skillRows?.[skillRowIndex]?.[skillIndex]?.description
|
||||
}
|
||||
})
|
||||
})
|
||||
} catch (error) {
|
||||
// console.warn('Failed to read', krDataFilePath)
|
||||
// console.warn(error)
|
||||
}
|
||||
|
||||
return data
|
||||
})
|
||||
.sort((a, b) => {
|
||||
@@ -37,3 +59,24 @@ export function listElfs() {
|
||||
export function getElfById(id: string) {
|
||||
return elfMap.get(id)
|
||||
}
|
||||
|
||||
function parseElfData(rawData: string) {
|
||||
const [name, ...skillRowSections] = rawData.split('\n## ')
|
||||
const skillRows = skillRowSections.map((skillRowSection) => {
|
||||
const skillSections = skillRowSection.split('\n### ')
|
||||
return skillSections.map((skillSection) => {
|
||||
const [name, description] = skillSection
|
||||
.split('\n\n')
|
||||
.map((data) => data.replace(/#+\s/, '').trim())
|
||||
return {
|
||||
name,
|
||||
description,
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
return {
|
||||
name: name.replace(/#+\s/, '').trim(),
|
||||
skillRows,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user