@aidc-toolkit/core 1.0.23-beta → 1.0.25-beta
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/README.md +22 -16
- package/dist/index.cjs +173 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +230 -0
- package/dist/index.d.ts +226 -14
- package/dist/index.js +112 -1
- package/dist/index.js.map +1 -1
- package/package.json +8 -11
- package/src/index.ts +4 -1
- package/src/locale/i18n.ts +4 -90
- package/src/logger.ts +52 -0
- package/src/type-helper.ts +117 -0
- package/src/type.ts +75 -0
- package/tsup.config.ts +3 -0
- package/typedoc.json +1 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/locale/i18n.d.ts +0 -68
- package/dist/locale/i18n.d.ts.map +0 -1
- package/dist/locale/i18n.js +0 -174
- package/dist/locale/i18n.js.map +0 -1
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create an object with omitted or picked entries.
|
|
3
|
+
*
|
|
4
|
+
* @template Omitting
|
|
5
|
+
* Type representation of `omitting` parameter for return type determination.
|
|
6
|
+
*
|
|
7
|
+
* @template T
|
|
8
|
+
* Object type.
|
|
9
|
+
*
|
|
10
|
+
* @template K
|
|
11
|
+
* Object key type.
|
|
12
|
+
*
|
|
13
|
+
* @param omitting
|
|
14
|
+
* True if omitting.
|
|
15
|
+
*
|
|
16
|
+
* @param o
|
|
17
|
+
* Object.
|
|
18
|
+
*
|
|
19
|
+
* @param keys
|
|
20
|
+
* Keys to omit or pick.
|
|
21
|
+
*
|
|
22
|
+
* @returns
|
|
23
|
+
* Edited object.
|
|
24
|
+
*/
|
|
25
|
+
function omitOrPick<Omitting extends boolean, T extends object, K extends keyof T>(omitting: Omitting, o: T, ...keys: K[]): Omitting extends true ? Omit<T, K> : Pick<T, K> {
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Key and value types are known.
|
|
27
|
+
return Object.fromEntries(Object.entries(o).filter(([key]) => keys.includes(key as K) !== omitting)) as ReturnType<typeof omitOrPick<Omitting, T, K>>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Create an object with omitted entries.
|
|
32
|
+
*
|
|
33
|
+
* @template T
|
|
34
|
+
* Object type.
|
|
35
|
+
*
|
|
36
|
+
* @template K
|
|
37
|
+
* Object key type.
|
|
38
|
+
*
|
|
39
|
+
* @param o
|
|
40
|
+
* Object.
|
|
41
|
+
*
|
|
42
|
+
* @param keys
|
|
43
|
+
* Keys to omit.
|
|
44
|
+
*
|
|
45
|
+
* @returns
|
|
46
|
+
* Edited object.
|
|
47
|
+
*/
|
|
48
|
+
export function omit<T extends object, K extends keyof T>(o: T, ...keys: K[]): Omit<T, K> {
|
|
49
|
+
return omitOrPick(true, o, ...keys);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Create an object with picked entries.
|
|
54
|
+
*
|
|
55
|
+
* @template T
|
|
56
|
+
* Object type.
|
|
57
|
+
*
|
|
58
|
+
* @template K
|
|
59
|
+
* Object key type.
|
|
60
|
+
*
|
|
61
|
+
* @param o
|
|
62
|
+
* Object.
|
|
63
|
+
*
|
|
64
|
+
* @param keys
|
|
65
|
+
* Keys to pick.
|
|
66
|
+
*
|
|
67
|
+
* @returns
|
|
68
|
+
* Edited object.
|
|
69
|
+
*/
|
|
70
|
+
export function pick<T extends object, K extends keyof T>(o: T, ...keys: K[]): Pick<T, K> {
|
|
71
|
+
return omitOrPick(false, o, ...keys);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Cast a property as a more narrow type.
|
|
76
|
+
*
|
|
77
|
+
* @template T
|
|
78
|
+
* Object type.
|
|
79
|
+
*
|
|
80
|
+
* @template K
|
|
81
|
+
* Object key type.
|
|
82
|
+
*
|
|
83
|
+
* @template TAsType
|
|
84
|
+
* Desired type.
|
|
85
|
+
*
|
|
86
|
+
* @param o
|
|
87
|
+
* Object.
|
|
88
|
+
*
|
|
89
|
+
* @param key
|
|
90
|
+
* Key of property to cast.
|
|
91
|
+
*
|
|
92
|
+
* @returns
|
|
93
|
+
* Single-key object with property cast as desired type.
|
|
94
|
+
*/
|
|
95
|
+
export function propertyAs<T extends object, K extends keyof T, TAsType extends T[K]>(o: T, key: K): Readonly<Omit<T, K> extends T ? Partial<Record<K, TAsType>> : Record<K, TAsType>> {
|
|
96
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Type is determined by condition.
|
|
97
|
+
return (key in o ?
|
|
98
|
+
{
|
|
99
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Force cast.
|
|
100
|
+
[key]: o[key] as TAsType
|
|
101
|
+
} :
|
|
102
|
+
{}
|
|
103
|
+
) as ReturnType<typeof propertyAs<T, K, TAsType>>;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Determine if argument is nullish. Application extension may pass `null` or `undefined` to missing parameters.
|
|
108
|
+
*
|
|
109
|
+
* @param argument
|
|
110
|
+
* Argument.
|
|
111
|
+
*
|
|
112
|
+
* @returns
|
|
113
|
+
* True if argument is undefined or null.
|
|
114
|
+
*/
|
|
115
|
+
export function isNullish(argument: unknown): argument is null | undefined {
|
|
116
|
+
return argument === null || argument === undefined;
|
|
117
|
+
}
|
package/src/type.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed function, applicable to any function, stricter than {@linkcode Function}.
|
|
3
|
+
*
|
|
4
|
+
* @template TFunction
|
|
5
|
+
* Function type.
|
|
6
|
+
*/
|
|
7
|
+
export type TypedFunction<TFunction extends (...args: Parameters<TFunction>) => ReturnType<TFunction>> = (...args: Parameters<TFunction>) => ReturnType<TFunction>;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Typed synchronous function, applicable to any function that doesn't return a {@linkcode Promise}.
|
|
11
|
+
*
|
|
12
|
+
* @template TFunction
|
|
13
|
+
* Function type.
|
|
14
|
+
*/
|
|
15
|
+
export type TypedSyncFunction<TFunction extends TypedFunction<TFunction>> = [ReturnType<TFunction>] extends [PromiseLike<unknown>] ? never : TypedFunction<TFunction>;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Determine the fundamental promised type. This is stricter than `Awaited<Type>` in that it requires a {@linkcode
|
|
19
|
+
* Promise}.
|
|
20
|
+
*
|
|
21
|
+
* @template T
|
|
22
|
+
* Promised type.
|
|
23
|
+
*/
|
|
24
|
+
export type PromisedType<T> = [T] extends [PromiseLike<infer TPromised>] ? TPromised : never;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Typed asynchronous function, applicable to any function that returns a {@linkcode Promise}.
|
|
28
|
+
*
|
|
29
|
+
* @template TFunction
|
|
30
|
+
* Function type.
|
|
31
|
+
*/
|
|
32
|
+
export type TypedAsyncFunction<TMethod extends (...args: Parameters<TMethod>) => PromiseLike<PromisedType<ReturnType<TMethod>>>> = (...args: Parameters<TMethod>) => Promise<PromisedType<ReturnType<TMethod>>>;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Nullishable type. Extends a type by allowing `null` and `undefined`.
|
|
36
|
+
*
|
|
37
|
+
* @template T
|
|
38
|
+
* Type.
|
|
39
|
+
*/
|
|
40
|
+
export type Nullishable<T> = T | null | undefined;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Non-nullishable type. If T is an object type, it is spread and attributes within it are made non-nullishable.
|
|
44
|
+
* Equivalent to a deep `Required<T>` for an object and `NonNullable<T>` for any other type.
|
|
45
|
+
*
|
|
46
|
+
* @template T
|
|
47
|
+
* Type.
|
|
48
|
+
*/
|
|
49
|
+
export type NonNullishable<T> = T extends object ? {
|
|
50
|
+
[P in keyof T]-?: NonNullishable<T[P]>
|
|
51
|
+
} : NonNullable<T>;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Make some keys within a type optional.
|
|
55
|
+
*
|
|
56
|
+
* @template T
|
|
57
|
+
* Object type.
|
|
58
|
+
*
|
|
59
|
+
* @template K
|
|
60
|
+
* Object key type.
|
|
61
|
+
*/
|
|
62
|
+
export type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Type to restrict property keys to those that are strings and that support a specified type.
|
|
66
|
+
*
|
|
67
|
+
* @template T
|
|
68
|
+
* Object type.
|
|
69
|
+
*
|
|
70
|
+
* @template P
|
|
71
|
+
* Object property type.
|
|
72
|
+
*/
|
|
73
|
+
export type PropertyKeys<T, P> = {
|
|
74
|
+
[K in keyof T]: K extends string ? T[K] extends P ? K : never : never;
|
|
75
|
+
}[keyof T];
|
package/tsup.config.ts
ADDED
package/typedoc.json
CHANGED
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,cAAc,kBAAkB,CAAC"}
|
package/dist/locale/i18n.d.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import type { i18n, Resource } from "i18next";
|
|
2
|
-
/**
|
|
3
|
-
* Locale strings type for generic manipulation.
|
|
4
|
-
*/
|
|
5
|
-
export interface LocaleResources {
|
|
6
|
-
[key: string]: LocaleResources | string;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Internationalization operating environments.
|
|
10
|
-
*/
|
|
11
|
-
export declare const I18nEnvironments: {
|
|
12
|
-
/**
|
|
13
|
-
* Command-line interface (e.g., unit tests).
|
|
14
|
-
*/
|
|
15
|
-
readonly CLI: 0;
|
|
16
|
-
/**
|
|
17
|
-
* Web server.
|
|
18
|
-
*/
|
|
19
|
-
readonly Server: 1;
|
|
20
|
-
/**
|
|
21
|
-
* Web browser.
|
|
22
|
-
*/
|
|
23
|
-
readonly Browser: 2;
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Internationalization operating environment.
|
|
27
|
-
*/
|
|
28
|
-
export type I18nEnvironment = typeof I18nEnvironments[keyof typeof I18nEnvironments];
|
|
29
|
-
/**
|
|
30
|
-
* Assert that language resources are a type match for English (default) resources.
|
|
31
|
-
*
|
|
32
|
-
* @param enResources
|
|
33
|
-
* English resources.
|
|
34
|
-
*
|
|
35
|
-
* @param lng
|
|
36
|
-
* Language.
|
|
37
|
-
*
|
|
38
|
-
* @param lngResources
|
|
39
|
-
* Language resources.
|
|
40
|
-
*
|
|
41
|
-
* @param parent
|
|
42
|
-
* Parent key name (set recursively).
|
|
43
|
-
*/
|
|
44
|
-
export declare function i18nAssertValidResources(enResources: object, lng: string, lngResources: object, parent?: string): void;
|
|
45
|
-
/**
|
|
46
|
-
* Initialize internationalization.
|
|
47
|
-
*
|
|
48
|
-
* @param i18next
|
|
49
|
-
* Internationalization object. As multiple objects exists, this parameter represents the one for the module for which
|
|
50
|
-
* internationalization is being initialized.
|
|
51
|
-
*
|
|
52
|
-
* @param environment
|
|
53
|
-
* Environment in which the application is running.
|
|
54
|
-
*
|
|
55
|
-
* @param debug
|
|
56
|
-
* Debug setting.
|
|
57
|
-
*
|
|
58
|
-
* @param defaultNS
|
|
59
|
-
* Default namespace.
|
|
60
|
-
*
|
|
61
|
-
* @param resources
|
|
62
|
-
* Resources.
|
|
63
|
-
*
|
|
64
|
-
* @returns
|
|
65
|
-
* Void promise.
|
|
66
|
-
*/
|
|
67
|
-
export declare function i18nCoreInit(i18next: i18n, environment: I18nEnvironment, debug: boolean, defaultNS: string, ...resources: Resource[]): Promise<void>;
|
|
68
|
-
//# sourceMappingURL=i18n.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/locale/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAA0B,QAAQ,EAAE,MAAM,SAAS,CAAC;AAItE;;GAEG;AACH,MAAM,WAAW,eAAe;IAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,GAAG,MAAM,CAAC;CAC3C;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB;IACzB;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAEG,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,gBAAgB,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAC;AAyBrF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAmDtH;AAgBD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,eAAe,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAiD1J"}
|
package/dist/locale/i18n.js
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
import I18nextBrowserLanguageDetector from "i18next-browser-languagedetector";
|
|
2
|
-
import I18nextCLILanguageDetector from "i18next-cli-language-detector";
|
|
3
|
-
/**
|
|
4
|
-
* Internationalization operating environments.
|
|
5
|
-
*/
|
|
6
|
-
export const I18nEnvironments = {
|
|
7
|
-
/**
|
|
8
|
-
* Command-line interface (e.g., unit tests).
|
|
9
|
-
*/
|
|
10
|
-
CLI: 0,
|
|
11
|
-
/**
|
|
12
|
-
* Web server.
|
|
13
|
-
*/
|
|
14
|
-
Server: 1,
|
|
15
|
-
/**
|
|
16
|
-
* Web browser.
|
|
17
|
-
*/
|
|
18
|
-
Browser: 2
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Parse parameter names in a resource string.
|
|
22
|
-
*
|
|
23
|
-
* @param s
|
|
24
|
-
* Resource string.
|
|
25
|
-
*
|
|
26
|
-
* @returns
|
|
27
|
-
* Array of parameter names.
|
|
28
|
-
*/
|
|
29
|
-
function parseParameterNames(s) {
|
|
30
|
-
const parameterRegExp = /\{\{.+?}}/g;
|
|
31
|
-
const parameterNames = [];
|
|
32
|
-
let match;
|
|
33
|
-
while ((match = parameterRegExp.exec(s)) !== null) {
|
|
34
|
-
parameterNames.push(match[1]);
|
|
35
|
-
}
|
|
36
|
-
return parameterNames;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Assert that language resources are a type match for English (default) resources.
|
|
40
|
-
*
|
|
41
|
-
* @param enResources
|
|
42
|
-
* English resources.
|
|
43
|
-
*
|
|
44
|
-
* @param lng
|
|
45
|
-
* Language.
|
|
46
|
-
*
|
|
47
|
-
* @param lngResources
|
|
48
|
-
* Language resources.
|
|
49
|
-
*
|
|
50
|
-
* @param parent
|
|
51
|
-
* Parent key name (set recursively).
|
|
52
|
-
*/
|
|
53
|
-
export function i18nAssertValidResources(enResources, lng, lngResources, parent) {
|
|
54
|
-
const enResourcesMap = new Map(Object.entries(enResources));
|
|
55
|
-
const lngResourcesMap = new Map(Object.entries(lngResources));
|
|
56
|
-
const isLocale = lng.includes("-");
|
|
57
|
-
for (const [enKey, enValue] of enResourcesMap) {
|
|
58
|
-
const enFullKey = `${parent === undefined ? "" : `${parent}.`}${enKey}`;
|
|
59
|
-
const lngValue = lngResourcesMap.get(enKey);
|
|
60
|
-
if (lngValue !== undefined) {
|
|
61
|
-
const enValueType = typeof enValue;
|
|
62
|
-
const lngValueType = typeof lngValue;
|
|
63
|
-
if (lngValueType !== enValueType) {
|
|
64
|
-
throw new Error(`Mismatched value type ${lngValueType} for key ${enFullKey} in ${lng} resources (expected ${enValueType})`);
|
|
65
|
-
}
|
|
66
|
-
if (enValueType === "string") {
|
|
67
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Value is known to be string.
|
|
68
|
-
const enParameterNames = parseParameterNames(enValue);
|
|
69
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Value is known to be string.
|
|
70
|
-
const lngParameterNames = parseParameterNames(lngValue);
|
|
71
|
-
for (const enParameterName of enParameterNames) {
|
|
72
|
-
if (!lngParameterNames.includes(enParameterName)) {
|
|
73
|
-
throw new Error(`Missing parameter ${enParameterName} for key ${enFullKey} in ${lng} resources`);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
for (const lngParameterName of lngParameterNames) {
|
|
77
|
-
if (!enParameterNames.includes(lngParameterName)) {
|
|
78
|
-
throw new Error(`Extraneous parameter ${lngParameterName} for key ${enFullKey} in ${lng} resources`);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
else if (enValueType === "object") {
|
|
83
|
-
i18nAssertValidResources(enValue, lng, lngValue, `${parent === undefined ? "" : `${parent}.`}${enKey}`);
|
|
84
|
-
}
|
|
85
|
-
// Locale falls back to raw language so ignore if missing.
|
|
86
|
-
}
|
|
87
|
-
else if (!isLocale) {
|
|
88
|
-
throw new Error(`Missing key ${enFullKey} in ${lng} resources`);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
for (const [lngKey] of lngResourcesMap) {
|
|
92
|
-
if (!enResourcesMap.has(lngKey)) {
|
|
93
|
-
throw new Error(`Extraneous key ${parent === undefined ? "" : `${parent}.`}${lngKey} in ${lng} resources`);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Convert a string to lower case, skipping words that are all upper case.
|
|
99
|
-
*
|
|
100
|
-
* @param s
|
|
101
|
-
* String.
|
|
102
|
-
*
|
|
103
|
-
* @returns
|
|
104
|
-
* Lower case string.
|
|
105
|
-
*/
|
|
106
|
-
function toLowerCase(s) {
|
|
107
|
-
// Words with no lower case letters are preserved as they are likely mnemonics.
|
|
108
|
-
return s.split(" ").map(word => /[a-z]/.test(word) ? word.toLowerCase() : word).join(" ");
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Initialize internationalization.
|
|
112
|
-
*
|
|
113
|
-
* @param i18next
|
|
114
|
-
* Internationalization object. As multiple objects exists, this parameter represents the one for the module for which
|
|
115
|
-
* internationalization is being initialized.
|
|
116
|
-
*
|
|
117
|
-
* @param environment
|
|
118
|
-
* Environment in which the application is running.
|
|
119
|
-
*
|
|
120
|
-
* @param debug
|
|
121
|
-
* Debug setting.
|
|
122
|
-
*
|
|
123
|
-
* @param defaultNS
|
|
124
|
-
* Default namespace.
|
|
125
|
-
*
|
|
126
|
-
* @param resources
|
|
127
|
-
* Resources.
|
|
128
|
-
*
|
|
129
|
-
* @returns
|
|
130
|
-
* Void promise.
|
|
131
|
-
*/
|
|
132
|
-
export async function i18nCoreInit(i18next, environment, debug, defaultNS, ...resources) {
|
|
133
|
-
// Initialization may be called more than once.
|
|
134
|
-
if (!i18next.isInitialized) {
|
|
135
|
-
const mergedResource = {};
|
|
136
|
-
// Merge resources.
|
|
137
|
-
for (const resource of resources) {
|
|
138
|
-
// Merge languages.
|
|
139
|
-
for (const [language, resourceLanguage] of Object.entries(resource)) {
|
|
140
|
-
if (!(language in mergedResource)) {
|
|
141
|
-
mergedResource[language] = {};
|
|
142
|
-
}
|
|
143
|
-
const mergedResourceLanguage = mergedResource[language];
|
|
144
|
-
// Merge namespaces.
|
|
145
|
-
for (const [namespace, resourceKey] of Object.entries(resourceLanguage)) {
|
|
146
|
-
mergedResourceLanguage[namespace] = resourceKey;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
let module;
|
|
151
|
-
switch (environment) {
|
|
152
|
-
case I18nEnvironments.CLI:
|
|
153
|
-
// TODO Refactor when https://github.com/neet/i18next-cli-language-detector/issues/281 resolved.
|
|
154
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Per above.
|
|
155
|
-
module = I18nextCLILanguageDetector;
|
|
156
|
-
break;
|
|
157
|
-
case I18nEnvironments.Browser:
|
|
158
|
-
module = I18nextBrowserLanguageDetector;
|
|
159
|
-
break;
|
|
160
|
-
default:
|
|
161
|
-
throw new Error("Not supported");
|
|
162
|
-
}
|
|
163
|
-
await i18next.use(module).init({
|
|
164
|
-
debug,
|
|
165
|
-
resources: mergedResource,
|
|
166
|
-
fallbackLng: "en",
|
|
167
|
-
defaultNS
|
|
168
|
-
}).then(() => {
|
|
169
|
-
// Add toLowerCase function.
|
|
170
|
-
i18next.services.formatter?.add("toLowerCase", value => typeof value === "string" ? toLowerCase(value) : String(value));
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
//# sourceMappingURL=i18n.js.map
|
package/dist/locale/i18n.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.js","sourceRoot":"","sources":["../../src/locale/i18n.ts"],"names":[],"mappings":"AACA,OAAO,8BAA8B,MAAM,kCAAkC,CAAC;AAC9E,OAAO,0BAA0B,MAAM,+BAA+B,CAAC;AASvE;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC5B;;OAEG;IACH,GAAG,EAAE,CAAC;IAEN;;OAEG;IACH,MAAM,EAAE,CAAC;IAET;;OAEG;IACH,OAAO,EAAE,CAAC;CACJ,CAAC;AAOX;;;;;;;;GAQG;AACH,SAAS,mBAAmB,CAAC,CAAS;IAClC,MAAM,eAAe,GAAG,YAAY,CAAC;IAErC,MAAM,cAAc,GAAa,EAAE,CAAC;IAEpC,IAAI,KAA6B,CAAC;IAElC,OAAO,CAAC,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QAChD,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAClC,CAAC;IAED,OAAO,cAAc,CAAC;AAC1B,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MA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