@aidc-toolkit/core 0.9.1 → 0.9.2
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/eslint.config.js +1 -6
- package/package.json +9 -10
- package/src/locale/i18n.ts +10 -11
package/eslint.config.js
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
import tseslint from "typescript-eslint";
|
|
2
|
-
import js from "@eslint/js";
|
|
3
2
|
import stylistic from "@stylistic/eslint-plugin";
|
|
4
3
|
import jsdoc from "eslint-plugin-jsdoc";
|
|
5
4
|
import esLintConfigLove from "eslint-config-love";
|
|
6
5
|
import { esLintConfigAIDCToolkit } from "@aidc-toolkit/dev";
|
|
7
6
|
|
|
8
7
|
export default tseslint.config(
|
|
9
|
-
{
|
|
10
|
-
ignores: ["eslint.config.js", "dist"]
|
|
11
|
-
},
|
|
12
|
-
js.configs.recommended,
|
|
13
8
|
...tseslint.configs.strictTypeChecked,
|
|
14
9
|
stylistic.configs["recommended-flat"],
|
|
15
10
|
jsdoc.configs["flat/recommended-typescript"],
|
|
16
11
|
esLintConfigLove,
|
|
17
|
-
esLintConfigAIDCToolkit
|
|
12
|
+
...esLintConfigAIDCToolkit
|
|
18
13
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aidc-toolkit/core",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "Core functionality for AIDC Toolkit",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -24,18 +24,17 @@
|
|
|
24
24
|
"build-dev": "npm run build && tsc src/index.ts --outDir dist --target esnext --moduleResolution nodenext --module nodenext --emitDeclarationOnly --declaration --declarationMap"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@aidc-toolkit/dev": "^0.9.
|
|
28
|
-
"@eslint
|
|
29
|
-
"
|
|
30
|
-
"eslint-
|
|
31
|
-
"eslint-plugin-jsdoc": "^50.3.0",
|
|
27
|
+
"@aidc-toolkit/dev": "^0.9.2",
|
|
28
|
+
"@stylistic/eslint-plugin": "^2.10.1",
|
|
29
|
+
"eslint-config-love": "^98.0.2",
|
|
30
|
+
"eslint-plugin-jsdoc": "^50.5.0",
|
|
32
31
|
"ts-node": "^10.9.2",
|
|
33
|
-
"tsup": "^8.3.
|
|
34
|
-
"typescript": "^5.6.
|
|
35
|
-
"typescript-eslint": "^8.
|
|
32
|
+
"tsup": "^8.3.5",
|
|
33
|
+
"typescript": "^5.6.3",
|
|
34
|
+
"typescript-eslint": "^8.14.0"
|
|
36
35
|
},
|
|
37
36
|
"dependencies": {
|
|
38
|
-
"i18next": "^23.
|
|
37
|
+
"i18next": "^23.16.5",
|
|
39
38
|
"i18next-browser-languagedetector": "^8.0.0",
|
|
40
39
|
"i18next-cli-language-detector": "^1.1.8"
|
|
41
40
|
}
|
package/src/locale/i18n.ts
CHANGED
|
@@ -38,8 +38,6 @@ export enum I18NEnvironment {
|
|
|
38
38
|
Browser
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
let i18nInitPending = true;
|
|
42
|
-
|
|
43
41
|
/**
|
|
44
42
|
* Initialize internationalization.
|
|
45
43
|
*
|
|
@@ -53,11 +51,11 @@ let i18nInitPending = true;
|
|
|
53
51
|
* True if initialization was completed, false if skipped (already initialized).
|
|
54
52
|
*/
|
|
55
53
|
export async function i18nInit(environment: I18NEnvironment, debug = false): Promise<boolean> {
|
|
56
|
-
|
|
54
|
+
let initialized: boolean;
|
|
57
55
|
|
|
58
56
|
// Skip if initialization is not pending.
|
|
59
|
-
if (
|
|
60
|
-
|
|
57
|
+
if (pendingResourceBundles !== undefined) {
|
|
58
|
+
initialized = true;
|
|
61
59
|
|
|
62
60
|
let module: object;
|
|
63
61
|
|
|
@@ -74,22 +72,23 @@ export async function i18nInit(environment: I18NEnvironment, debug = false): Pro
|
|
|
74
72
|
throw new Error("Not supported");
|
|
75
73
|
}
|
|
76
74
|
|
|
75
|
+
const initResourceBundles = pendingResourceBundles;
|
|
76
|
+
|
|
77
|
+
// No need to manage pending resource bundles past this point.
|
|
78
|
+
pendingResourceBundles = undefined;
|
|
79
|
+
|
|
77
80
|
await i18next.use(module as never).init({
|
|
78
81
|
fallbackLng: "en",
|
|
79
82
|
debug,
|
|
80
83
|
resources: {}
|
|
81
84
|
}).then(() => {
|
|
82
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
83
|
-
const initResourceBundles = pendingResourceBundles!;
|
|
84
|
-
|
|
85
|
-
// No need to manage pending resource bundles past this point.
|
|
86
|
-
pendingResourceBundles = undefined;
|
|
87
|
-
|
|
88
85
|
// Add pending resource bundles.
|
|
89
86
|
for (const initResourceBundle of initResourceBundles) {
|
|
90
87
|
i18nAddResourceBundle(initResourceBundle.lng, initResourceBundle.ns, initResourceBundle.resources);
|
|
91
88
|
}
|
|
92
89
|
});
|
|
90
|
+
} else {
|
|
91
|
+
initialized = false;
|
|
93
92
|
}
|
|
94
93
|
|
|
95
94
|
return initialized;
|