@aidc-toolkit/core 0.9.0 → 0.9.1
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/.idea/runConfigurations/build_dev.xml +12 -0
- package/eslint.config.js +3 -0
- package/package.json +12 -13
- package/src/locale/i18n.ts +17 -7
- package/typedoc.json +2 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<component name="ProjectRunConfigurationManager">
|
|
2
|
+
<configuration default="false" name="build-dev" type="js.build_tools.npm" nameIsGenerated="true">
|
|
3
|
+
<package-json value="$PROJECT_DIR$/package.json" />
|
|
4
|
+
<command value="run" />
|
|
5
|
+
<scripts>
|
|
6
|
+
<script value="build-dev" />
|
|
7
|
+
</scripts>
|
|
8
|
+
<node-interpreter value="project" />
|
|
9
|
+
<envs />
|
|
10
|
+
<method v="2" />
|
|
11
|
+
</configuration>
|
|
12
|
+
</component>
|
package/eslint.config.js
CHANGED
|
@@ -6,6 +6,9 @@ import esLintConfigLove from "eslint-config-love";
|
|
|
6
6
|
import { esLintConfigAIDCToolkit } from "@aidc-toolkit/dev";
|
|
7
7
|
|
|
8
8
|
export default tseslint.config(
|
|
9
|
+
{
|
|
10
|
+
ignores: ["eslint.config.js", "dist"]
|
|
11
|
+
},
|
|
9
12
|
js.configs.recommended,
|
|
10
13
|
...tseslint.configs.strictTypeChecked,
|
|
11
14
|
stylistic.configs["recommended-flat"],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aidc-toolkit/core",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Core functionality for AIDC Toolkit",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -20,23 +20,22 @@
|
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
22
|
"eslint": "eslint .",
|
|
23
|
-
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
24
|
-
"
|
|
23
|
+
"build": "tsup src/index.ts --clean --format cjs,esm --dts",
|
|
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/js": "^9.
|
|
29
|
-
"@stylistic/eslint-plugin": "^2.
|
|
30
|
-
"eslint-config-love": "^
|
|
31
|
-
"eslint-plugin-jsdoc": "^50.
|
|
27
|
+
"@aidc-toolkit/dev": "^0.9.1",
|
|
28
|
+
"@eslint/js": "^9.11.1",
|
|
29
|
+
"@stylistic/eslint-plugin": "^2.8.0",
|
|
30
|
+
"eslint-config-love": "^71.0.0",
|
|
31
|
+
"eslint-plugin-jsdoc": "^50.3.0",
|
|
32
32
|
"ts-node": "^10.9.2",
|
|
33
|
-
"tsup": "^8.
|
|
34
|
-
"typescript": "^5.
|
|
35
|
-
"typescript-eslint": "^8.
|
|
36
|
-
"vitest": "^2.0.5"
|
|
33
|
+
"tsup": "^8.3.0",
|
|
34
|
+
"typescript": "^5.6.2",
|
|
35
|
+
"typescript-eslint": "^8.7.0"
|
|
37
36
|
},
|
|
38
37
|
"dependencies": {
|
|
39
|
-
"i18next": "^23.
|
|
38
|
+
"i18next": "^23.15.1",
|
|
40
39
|
"i18next-browser-languagedetector": "^8.0.0",
|
|
41
40
|
"i18next-cli-language-detector": "^1.1.8"
|
|
42
41
|
}
|
package/src/locale/i18n.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import i18next from "i18next";
|
|
2
|
-
import I18nextBrowserLanguageDetector from "i18next-browser-
|
|
2
|
+
import I18nextBrowserLanguageDetector from "i18next-browser-languagedetector";
|
|
3
3
|
import I18nextCLILanguageDetector from "i18next-cli-language-detector";
|
|
4
4
|
|
|
5
5
|
export default i18next;
|
|
@@ -38,6 +38,8 @@ export enum I18NEnvironment {
|
|
|
38
38
|
Browser
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
let i18nInitPending = true;
|
|
42
|
+
|
|
41
43
|
/**
|
|
42
44
|
* Initialize internationalization.
|
|
43
45
|
*
|
|
@@ -46,9 +48,17 @@ export enum I18NEnvironment {
|
|
|
46
48
|
*
|
|
47
49
|
* @param debug
|
|
48
50
|
* Debug setting.
|
|
51
|
+
*
|
|
52
|
+
* @returns
|
|
53
|
+
* True if initialization was completed, false if skipped (already initialized).
|
|
49
54
|
*/
|
|
50
|
-
export async function i18nInit(environment: I18NEnvironment, debug = false): Promise<
|
|
51
|
-
|
|
55
|
+
export async function i18nInit(environment: I18NEnvironment, debug = false): Promise<boolean> {
|
|
56
|
+
const initialized = i18nInitPending;
|
|
57
|
+
|
|
58
|
+
// Skip if initialization is not pending.
|
|
59
|
+
if (i18nInitPending) {
|
|
60
|
+
i18nInitPending = false;
|
|
61
|
+
|
|
52
62
|
let module: object;
|
|
53
63
|
|
|
54
64
|
switch (environment) {
|
|
@@ -76,13 +86,13 @@ export async function i18nInit(environment: I18NEnvironment, debug = false): Pro
|
|
|
76
86
|
pendingResourceBundles = undefined;
|
|
77
87
|
|
|
78
88
|
// Add pending resource bundles.
|
|
79
|
-
|
|
89
|
+
for (const initResourceBundle of initResourceBundles) {
|
|
80
90
|
i18nAddResourceBundle(initResourceBundle.lng, initResourceBundle.ns, initResourceBundle.resources);
|
|
81
|
-
}
|
|
91
|
+
}
|
|
82
92
|
});
|
|
83
|
-
} else {
|
|
84
|
-
throw new Error("i18n already initialized");
|
|
85
93
|
}
|
|
94
|
+
|
|
95
|
+
return initialized;
|
|
86
96
|
}
|
|
87
97
|
|
|
88
98
|
/**
|