From 0c7a5b3460eac705ce1771dea98518e842c9a0df Mon Sep 17 00:00:00 2001 From: MARCROCK22 Date: Sat, 8 Feb 2025 13:24:02 -0400 Subject: [PATCH] fix: langInstance type --- src/langs/handler.ts | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/langs/handler.ts b/src/langs/handler.ts index 7276044..bd75b21 100644 --- a/src/langs/handler.ts +++ b/src/langs/handler.ts @@ -45,14 +45,15 @@ export class LangsHandler extends BaseHandler { } } - parse(file: EventInstance) { - const locale = file.name.split('.').slice(0, -1).join('.') || file.name; - const result = this.onFile(locale, file.file); - if ('path' in file) this.__paths[locale] = file.path as string; - if (result) this.values[locale] = result; + parse(file: LangInstance) { + const oldLocale = file.name.split('.').slice(0, -1).join('.') || file.name; + const result = this.onFile(oldLocale, file.file); + if (!result) return; + if ('path' in file) this.__paths[result.locale] = file.path as string; + this.values[result.locale] = result.file; } - set(instances: EventInstance[]) { + set(instances: LangInstance[]) { for (const i of instances) { this.parse(i); } @@ -79,9 +80,14 @@ export class LangsHandler extends BaseHandler { } } - onFile(_locale: string, file: FileLoaded>): Record | false { - return file.default ?? false; + onFile(locale: string, file: FileLoaded>): { file: Record; locale: string } | false { + return file.default + ? { + file: file.default, + locale, + } + : false; } } -export type EventInstance = { name: string; file: Record }; +export type LangInstance = { name: string; file: Record; path: string };