1
0
mirror of https://github.com/tcgdex/cards-database.git synced 2025-07-04 09:19:19 +00:00

feat: Add the TCG Pocket cards in other languages (#734)

This commit is contained in:
2025-05-17 19:27:22 +02:00
committed by GitHub
parent c26b91ac85
commit 8ca40f410d
1116 changed files with 26787 additions and 4023 deletions

View File

@ -3,7 +3,7 @@ import Queue from '@dzeio/queue'
import { glob } from 'glob'
import { exec, spawn } from 'node:child_process'
import { writeFileSync } from 'node:fs'
import { Card, Set, SupportedLanguages } from '../../../interfaces'
import { Card, Languages, Set, SupportedLanguages } from '../../../interfaces'
import * as legals from '../../../meta/legals'
interface fileCacheInterface {
@ -177,3 +177,13 @@ export function getLastEdit(path: string): string {
}
return date
}
export function resolveText<T>(text: Languages<T> | undefined, lang: SupportedLanguages): T | undefined {
if (!text) return text as undefined
let res: T | undefined = text[lang]
if (typeof res === 'undefined' && !lang.includes('-')) {
const key = Object.keys(text).find(key => key.startsWith(lang))
return text[key as keyof Languages<T>]
}
return res
}