Skip to content

Commit

Permalink
fix: langInstance type
Browse files Browse the repository at this point in the history
  • Loading branch information
MARCROCK22 committed Feb 8, 2025
1 parent 5b1122d commit 0c7a5b3
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/langs/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -79,9 +80,14 @@ export class LangsHandler extends BaseHandler {
}
}

onFile(_locale: string, file: FileLoaded<Record<string, any>>): Record<string, any> | false {
return file.default ?? false;
onFile(locale: string, file: FileLoaded<Record<string, any>>): { file: Record<string, any>; locale: string } | false {
return file.default
? {
file: file.default,
locale,
}
: false;
}
}

export type EventInstance = { name: string; file: Record<string, any> };
export type LangInstance = { name: string; file: Record<string, any>; path: string };

0 comments on commit 0c7a5b3

Please sign in to comment.