seyfert 2.2.1-dev-13162061448.0 → 2.2.1-dev-13217859162.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/langs/handler.d.ts +13 -6
- package/lib/langs/handler.js +13 -7
- package/package.json +1 -1
package/lib/langs/handler.d.ts
CHANGED
|
@@ -13,13 +13,20 @@ export declare class LangsHandler extends BaseHandler {
|
|
|
13
13
|
get(locale?: string): import("..").DefaultLocale;
|
|
14
14
|
};
|
|
15
15
|
load(dir: string): Promise<void>;
|
|
16
|
-
parse(file:
|
|
17
|
-
set(instances:
|
|
18
|
-
reload(lang: string): Promise<false |
|
|
16
|
+
parse(file: LangInstance): void;
|
|
17
|
+
set(instances: LangInstance[]): void;
|
|
18
|
+
reload(lang: string): Promise<false | {
|
|
19
|
+
file: Record<string, any>;
|
|
20
|
+
locale: string;
|
|
21
|
+
} | null>;
|
|
19
22
|
reloadAll(stopIfFail?: boolean): Promise<void>;
|
|
20
|
-
onFile(
|
|
23
|
+
onFile(locale: string, { file }: LangInstance): {
|
|
24
|
+
file: Record<string, any>;
|
|
25
|
+
locale: string;
|
|
26
|
+
} | false;
|
|
21
27
|
}
|
|
22
|
-
export type
|
|
28
|
+
export type LangInstance = {
|
|
23
29
|
name: string;
|
|
24
|
-
file: Record<string, any
|
|
30
|
+
file: FileLoaded<Record<string, any>>;
|
|
31
|
+
path: string;
|
|
25
32
|
};
|
package/lib/langs/handler.js
CHANGED
|
@@ -38,12 +38,13 @@ class LangsHandler extends common_1.BaseHandler {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
parse(file) {
|
|
41
|
-
const
|
|
42
|
-
const result = this.onFile(
|
|
41
|
+
const oldLocale = file.name.split('.').slice(0, -1).join('.') || file.name;
|
|
42
|
+
const result = this.onFile(oldLocale, file);
|
|
43
|
+
if (!result)
|
|
44
|
+
return;
|
|
43
45
|
if ('path' in file)
|
|
44
|
-
this.__paths[locale] = file.path;
|
|
45
|
-
|
|
46
|
-
this.values[locale] = result;
|
|
46
|
+
this.__paths[result.locale] = file.path;
|
|
47
|
+
this.values[result.locale] = result.file;
|
|
47
48
|
}
|
|
48
49
|
set(instances) {
|
|
49
50
|
for (const i of instances) {
|
|
@@ -71,8 +72,13 @@ class LangsHandler extends common_1.BaseHandler {
|
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
|
-
onFile(
|
|
75
|
-
return file.default
|
|
75
|
+
onFile(locale, { file }) {
|
|
76
|
+
return file.default
|
|
77
|
+
? {
|
|
78
|
+
file: file.default,
|
|
79
|
+
locale,
|
|
80
|
+
}
|
|
81
|
+
: false;
|
|
76
82
|
}
|
|
77
83
|
}
|
|
78
84
|
exports.LangsHandler = LangsHandler;
|