@aidc-toolkit/core 0.9.18-beta → 0.9.19-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 +106 -21
- package/dist/locale/i18n.d.ts +2 -2
- package/dist/locale/i18n.js +8 -8
- package/dist/locale/i18n.js.map +1 -1
- package/package.json +4 -4
- package/resource/icon.svg +1957 -0
- package/src/locale/i18n.ts +5 -5
package/src/locale/i18n.ts
CHANGED
|
@@ -12,7 +12,7 @@ export interface LocaleStrings {
|
|
|
12
12
|
/**
|
|
13
13
|
* Internationalization operating environment.
|
|
14
14
|
*/
|
|
15
|
-
export enum
|
|
15
|
+
export enum I18nEnvironment {
|
|
16
16
|
/**
|
|
17
17
|
* Command-line interface (e.g., unit tests).
|
|
18
18
|
*/
|
|
@@ -64,7 +64,7 @@ export function i18nAssertValidResources(enResources: object, lng: string, lngRe
|
|
|
64
64
|
if (enValueType === "object") {
|
|
65
65
|
i18nAssertValidResources(enValue, lng, lngValue, `${parent === undefined ? "" : `${parent}.`}${enKey}`);
|
|
66
66
|
}
|
|
67
|
-
|
|
67
|
+
// Locale falls back to raw language so ignore if missing.
|
|
68
68
|
} else if (!isLocale) {
|
|
69
69
|
throw new Error(`Missing key ${parent === undefined ? "" : `${parent}.`}${enKey} from ${lng} resources`);
|
|
70
70
|
}
|
|
@@ -113,7 +113,7 @@ function toLowerCase(s: string): string {
|
|
|
113
113
|
* @returns
|
|
114
114
|
* Void promise.
|
|
115
115
|
*/
|
|
116
|
-
export async function i18nCoreInit(i18next: i18n, environment:
|
|
116
|
+
export async function i18nCoreInit(i18next: i18n, environment: I18nEnvironment, debug: boolean, defaultNS: string, ...resources: Resource[]): Promise<void> {
|
|
117
117
|
// Initialization may be called more than once.
|
|
118
118
|
if (!i18next.isInitialized) {
|
|
119
119
|
const mergedResource: Resource = {};
|
|
@@ -138,13 +138,13 @@ export async function i18nCoreInit(i18next: i18n, environment: I18NEnvironment,
|
|
|
138
138
|
let module: Parameters<typeof i18next.use>[0];
|
|
139
139
|
|
|
140
140
|
switch (environment) {
|
|
141
|
-
case
|
|
141
|
+
case I18nEnvironment.CLI:
|
|
142
142
|
// TODO Refactor when https://github.com/neet/i18next-cli-language-detector/issues/281 resolved.
|
|
143
143
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Per above.
|
|
144
144
|
module = I18nextCLILanguageDetector as unknown as LanguageDetectorModule;
|
|
145
145
|
break;
|
|
146
146
|
|
|
147
|
-
case
|
|
147
|
+
case I18nEnvironment.Browser:
|
|
148
148
|
module = I18nextBrowserLanguageDetector;
|
|
149
149
|
break;
|
|
150
150
|
|