Added a default Language setting for global lang

Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
Florian Bouillon 2020-03-25 15:50:08 +01:00
parent 5ac1a18f6f
commit e9d6ac12e1
No known key found for this signature in database
GPG Key ID: B143FF27EF555D16

View File

@ -5,14 +5,20 @@ import { ExpansionSingle, ExpansionList } from './interfaces/Expansion'
import RequestWrapper from './Request' import RequestWrapper from './Request'
export default class TCGdex { export default class TCGdex {
public lang: Langs = "en" public static defaultLang: Langs = "en"
public lang?: Langs
public constructor(lang?: Langs) { public constructor(lang?: Langs) {
if (lang) this.lang = lang if (lang) this.lang = lang
} }
public getLang() {
return this.lang || TCGdex.defaultLang
}
private getBaseUrl() { private getBaseUrl() {
return `https://api.tcgdex.net/${this.lang}` return `https://api.tcgdex.net/${this.getLang()}`
} }
private gbu() { private gbu() {