mirror of
https://github.com/tcgdex/cards-database.git
synced 2025-07-30 11:30:46 +00:00
Initial Database
Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
38
interfaces/Category.ts
Normal file
38
interfaces/Category.ts
Normal file
@ -0,0 +1,38 @@
|
||||
enum Category {
|
||||
POKEMON,
|
||||
TRAINER,
|
||||
ENERGY
|
||||
}
|
||||
|
||||
const en = [
|
||||
"Pokémon",
|
||||
"Trainer",
|
||||
"Energy"
|
||||
]
|
||||
|
||||
const fr = [
|
||||
"Pokémon",
|
||||
"Dresseur",
|
||||
"Énergie"
|
||||
]
|
||||
|
||||
namespace Category {
|
||||
export function fromEnglish(str: string) {
|
||||
let i = en.indexOf(str)
|
||||
if (str === "Pok<6F><6B>mon") i = 1
|
||||
if (i < 0) throw new Error(`Cannot get the category (${str})`)
|
||||
return i
|
||||
}
|
||||
|
||||
export function toLang(i: Category, lang: string): string {
|
||||
switch (lang) {
|
||||
case "en":
|
||||
return en[i]
|
||||
case "fr":
|
||||
return fr[i]
|
||||
}
|
||||
throw new Error(`Error, Language not implemented! (${lang})`)
|
||||
}
|
||||
}
|
||||
|
||||
export default Category
|
Reference in New Issue
Block a user