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:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user