@akanjs/dictionary 0.9.56 → 0.9.58-canary.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/cjs/src/base.dictionary.js +28 -45
- package/cjs/src/dictInfo.js +484 -0
- package/cjs/src/dictionary.js +5 -4
- package/cjs/src/index.js +4 -0
- package/cjs/src/locale.js +33 -0
- package/cjs/src/serverTranslator.js +1 -4
- package/cjs/src/trans.js +23 -103
- package/esm/src/base.dictionary.js +28 -45
- package/esm/src/dictInfo.js +465 -0
- package/esm/src/dictionary.js +5 -4
- package/esm/src/index.js +13 -1
- package/esm/src/locale.js +14 -0
- package/esm/src/serverTranslator.js +2 -5
- package/esm/src/trans.js +24 -104
- package/package.json +1 -1
- package/src/base.dictionary.d.ts +1 -93
- package/src/dictInfo.d.ts +204 -0
- package/src/dictionary.d.ts +12 -111
- package/src/index.d.ts +3 -1
- package/src/locale.d.ts +107 -0
- package/src/serverTranslator.d.ts +1 -1
- package/src/trans.d.ts +20 -82
package/src/dictionary.d.ts
CHANGED
|
@@ -1,117 +1,18 @@
|
|
|
1
|
+
import type { BaseEndpoint } from "@akanjs/signal";
|
|
1
2
|
export declare const dictionary: {
|
|
2
|
-
|
|
3
|
-
"api-publishPing": [string, string];
|
|
4
|
-
"apidesc-publishPing": [string, string];
|
|
5
|
-
"api-ping": [string, string];
|
|
6
|
-
"apidesc-ping": [string, string];
|
|
7
|
-
"api-pingBody": [string, string];
|
|
8
|
-
"apidesc-pingBody": [string, string];
|
|
9
|
-
"arg-pingBody-data": [string, string];
|
|
10
|
-
"argdesc-pingBody-data": [string, string];
|
|
11
|
-
"api-pingParam": [string, string];
|
|
12
|
-
"apidesc-pingParam": [string, string];
|
|
13
|
-
"arg-pingParam-id": [string, string];
|
|
14
|
-
"argdesc-pingParam-id": [string, string];
|
|
15
|
-
"api-pingQuery": [string, string];
|
|
16
|
-
"apidesc-pingQuery": [string, string];
|
|
17
|
-
"arg-pingQuery-id": [string, string];
|
|
18
|
-
"argdesc-pingQuery-id": [string, string];
|
|
19
|
-
"api-pingEvery": [string, string];
|
|
20
|
-
"apidesc-pingEvery": [string, string];
|
|
21
|
-
"api-pingUser": [string, string];
|
|
22
|
-
"apidesc-pingUser": [string, string];
|
|
23
|
-
"api-pingAdmin": [string, string];
|
|
24
|
-
"apidesc-pingAdmin": [string, string];
|
|
25
|
-
"api-cleanup": [string, string];
|
|
26
|
-
"apidesc-cleanup": [string, string];
|
|
27
|
-
"api-wsPing": [string, string];
|
|
28
|
-
"apidesc-wsPing": [string, string];
|
|
29
|
-
"arg-wsPing-data": [string, string];
|
|
30
|
-
"argdesc-wsPing-data": [string, string];
|
|
31
|
-
"api-pubsubPing": [string, string];
|
|
32
|
-
"apidesc-pubsubPing": [string, string];
|
|
33
|
-
"api-getDictionary": [string, string];
|
|
34
|
-
"apidesc-getDictionary": [string, string];
|
|
35
|
-
"arg-getDictionary-lang": [string, string];
|
|
36
|
-
"argdesc-getDictionary-lang": [string, string];
|
|
37
|
-
"api-getAllDictionary": [string, string];
|
|
38
|
-
"apidesc-getAllDictionary": [string, string];
|
|
39
|
-
"api-getSignals": [string, string];
|
|
40
|
-
"apidesc-getSignals": [string, string];
|
|
41
|
-
somethingWrong: [string, string];
|
|
42
|
-
connecting: [string, string];
|
|
43
|
-
connected: [string, string];
|
|
44
|
-
serverDisconnected: [string, string];
|
|
45
|
-
refreshing: [string, string];
|
|
46
|
-
tryReconnecting: [string, string];
|
|
47
|
-
serverHasProblem: [string, string];
|
|
48
|
-
checkServerStatus: [string, string];
|
|
49
|
-
success: [string, string];
|
|
50
|
-
failed: [string, string];
|
|
51
|
-
processing: [string, string];
|
|
52
|
-
processed: [string, string];
|
|
53
|
-
noData: [string, string];
|
|
54
|
-
error: [string, string];
|
|
55
|
-
invalidValueError: [string, string];
|
|
56
|
-
emailInvalidError: [string, string];
|
|
57
|
-
phoneInvalidError: [string, string];
|
|
58
|
-
ok: [string, string];
|
|
59
|
-
cancel: [string, string];
|
|
60
|
-
unauthorized: [string, string];
|
|
61
|
-
confirmClose: [string, string];
|
|
62
|
-
textTooShortError: [string, string];
|
|
63
|
-
textTooLongError: [string, string];
|
|
64
|
-
selectTooShortError: [string, string];
|
|
65
|
-
selectTooLongError: [string, string];
|
|
66
|
-
numberTooSmallError: [string, string];
|
|
67
|
-
numberTooBigError: [string, string];
|
|
68
|
-
passwordNotMatchError: [string, string];
|
|
69
|
-
selectDateError: [string, string];
|
|
70
|
-
priceUnit: [string, string];
|
|
71
|
-
password: [string, string];
|
|
72
|
-
passwordConfirm: [string, string];
|
|
73
|
-
noOptions: [string, string];
|
|
74
|
-
addModel: [string, string];
|
|
75
|
-
createModel: [string, string];
|
|
76
|
-
createSuccess: [string, string];
|
|
77
|
-
updateModel: [string, string];
|
|
78
|
-
removeModel: [string, string];
|
|
79
|
-
updateSuccess: [string, string];
|
|
80
|
-
removeSuccess: [string, string];
|
|
81
|
-
sureToRemove: [string, string];
|
|
82
|
-
irreversibleOps: [string, string];
|
|
83
|
-
typeNameToRemove: [string, string];
|
|
84
|
-
yesRemove: [string, string];
|
|
85
|
-
removeMsg: [string, string];
|
|
86
|
-
confirmMsg: [string, string];
|
|
87
|
-
perPage: [string, string];
|
|
88
|
-
actions: [string, string];
|
|
89
|
-
new: [string, string];
|
|
90
|
-
edit: [string, string];
|
|
91
|
-
save: [string, string];
|
|
92
|
-
remove: [string, string];
|
|
93
|
-
view: [string, string];
|
|
94
|
-
};
|
|
3
|
+
base: import("./locale").DictModule<import("./locale").ServiceTranslatorKey<"base", BaseEndpoint, "error" | "password" | "save" | "remove" | "ok" | "new" | "somethingWrong" | "connecting" | "connected" | "serverDisconnected" | "refreshing" | "tryReconnecting" | "serverHasProblem" | "checkServerStatus" | "success" | "failed" | "processing" | "processed" | "noData" | "invalidValueError" | "emailInvalidError" | "phoneInvalidError" | "cancel" | "unauthorized" | "confirmClose" | "textTooShortError" | "textTooLongError" | "selectTooShortError" | "selectTooLongError" | "numberTooSmallError" | "numberTooBigError" | "passwordNotMatchError" | "selectDateError" | "priceUnit" | "passwordConfirm" | "noOptions" | "addModel" | "createModel" | "createSuccess" | "updateModel" | "removeModel" | "updateSuccess" | "removeSuccess" | "sureToRemove" | "irreversibleOps" | "typeNameToRemove" | "yesRemove" | "removeMsg" | "confirmMsg" | "perPage" | "actions" | "edit" | "view">, never>;
|
|
95
4
|
};
|
|
96
5
|
export declare const Revert: {
|
|
97
|
-
new (key:
|
|
6
|
+
new (key: never, data?: any): Error;
|
|
98
7
|
prototype: Error;
|
|
99
|
-
}, translate: (lang: "en" | "ko" | "zhChs" | "zhCht", key: "
|
|
8
|
+
}, translate: (lang: "en" | "ko" | "zhChs" | "zhCht", key: import("./locale").ServiceTranslatorKey<"base", BaseEndpoint, "error" | "password" | "save" | "remove" | "ok" | "new" | "somethingWrong" | "connecting" | "connected" | "serverDisconnected" | "refreshing" | "tryReconnecting" | "serverHasProblem" | "checkServerStatus" | "success" | "failed" | "processing" | "processed" | "noData" | "invalidValueError" | "emailInvalidError" | "phoneInvalidError" | "cancel" | "unauthorized" | "confirmClose" | "textTooShortError" | "textTooLongError" | "selectTooShortError" | "selectTooLongError" | "numberTooSmallError" | "numberTooBigError" | "passwordNotMatchError" | "selectDateError" | "priceUnit" | "passwordConfirm" | "noOptions" | "addModel" | "createModel" | "createSuccess" | "updateModel" | "removeModel" | "updateSuccess" | "removeSuccess" | "sureToRemove" | "irreversibleOps" | "typeNameToRemove" | "yesRemove" | "removeMsg" | "confirmMsg" | "perPage" | "actions" | "edit" | "view">, data?: {
|
|
100
9
|
[key: string]: any;
|
|
101
10
|
}) => string, msg: {
|
|
102
|
-
info: (key: "
|
|
103
|
-
success: (key: "
|
|
104
|
-
error: (key: "
|
|
105
|
-
warning: (key: "
|
|
106
|
-
loading: (key: "
|
|
107
|
-
}, getDictionary: (lang: "en" | "ko" | "zhChs" | "zhCht") => {
|
|
108
|
-
[key: string]:
|
|
109
|
-
|
|
110
|
-
};
|
|
111
|
-
}, getAllDictionary: () => {
|
|
112
|
-
[key: string]: {
|
|
113
|
-
[key: string]: {
|
|
114
|
-
[key: string]: string;
|
|
115
|
-
};
|
|
116
|
-
};
|
|
117
|
-
};
|
|
11
|
+
info: (key: import("./locale").ServiceTranslatorKey<"base", BaseEndpoint, "error" | "password" | "save" | "remove" | "ok" | "new" | "somethingWrong" | "connecting" | "connected" | "serverDisconnected" | "refreshing" | "tryReconnecting" | "serverHasProblem" | "checkServerStatus" | "success" | "failed" | "processing" | "processed" | "noData" | "invalidValueError" | "emailInvalidError" | "phoneInvalidError" | "cancel" | "unauthorized" | "confirmClose" | "textTooShortError" | "textTooLongError" | "selectTooShortError" | "selectTooLongError" | "numberTooSmallError" | "numberTooBigError" | "passwordNotMatchError" | "selectDateError" | "priceUnit" | "passwordConfirm" | "noOptions" | "addModel" | "createModel" | "createSuccess" | "updateModel" | "removeModel" | "updateSuccess" | "removeSuccess" | "sureToRemove" | "irreversibleOps" | "typeNameToRemove" | "yesRemove" | "removeMsg" | "confirmMsg" | "perPage" | "actions" | "edit" | "view">, option?: import("./trans").TransMessageOption) => void;
|
|
12
|
+
success: (key: import("./locale").ServiceTranslatorKey<"base", BaseEndpoint, "error" | "password" | "save" | "remove" | "ok" | "new" | "somethingWrong" | "connecting" | "connected" | "serverDisconnected" | "refreshing" | "tryReconnecting" | "serverHasProblem" | "checkServerStatus" | "success" | "failed" | "processing" | "processed" | "noData" | "invalidValueError" | "emailInvalidError" | "phoneInvalidError" | "cancel" | "unauthorized" | "confirmClose" | "textTooShortError" | "textTooLongError" | "selectTooShortError" | "selectTooLongError" | "numberTooSmallError" | "numberTooBigError" | "passwordNotMatchError" | "selectDateError" | "priceUnit" | "passwordConfirm" | "noOptions" | "addModel" | "createModel" | "createSuccess" | "updateModel" | "removeModel" | "updateSuccess" | "removeSuccess" | "sureToRemove" | "irreversibleOps" | "typeNameToRemove" | "yesRemove" | "removeMsg" | "confirmMsg" | "perPage" | "actions" | "edit" | "view">, option?: import("./trans").TransMessageOption) => void;
|
|
13
|
+
error: (key: import("./locale").ServiceTranslatorKey<"base", BaseEndpoint, "error" | "password" | "save" | "remove" | "ok" | "new" | "somethingWrong" | "connecting" | "connected" | "serverDisconnected" | "refreshing" | "tryReconnecting" | "serverHasProblem" | "checkServerStatus" | "success" | "failed" | "processing" | "processed" | "noData" | "invalidValueError" | "emailInvalidError" | "phoneInvalidError" | "cancel" | "unauthorized" | "confirmClose" | "textTooShortError" | "textTooLongError" | "selectTooShortError" | "selectTooLongError" | "numberTooSmallError" | "numberTooBigError" | "passwordNotMatchError" | "selectDateError" | "priceUnit" | "passwordConfirm" | "noOptions" | "addModel" | "createModel" | "createSuccess" | "updateModel" | "removeModel" | "updateSuccess" | "removeSuccess" | "sureToRemove" | "irreversibleOps" | "typeNameToRemove" | "yesRemove" | "removeMsg" | "confirmMsg" | "perPage" | "actions" | "edit" | "view">, option?: import("./trans").TransMessageOption) => void;
|
|
14
|
+
warning: (key: import("./locale").ServiceTranslatorKey<"base", BaseEndpoint, "error" | "password" | "save" | "remove" | "ok" | "new" | "somethingWrong" | "connecting" | "connected" | "serverDisconnected" | "refreshing" | "tryReconnecting" | "serverHasProblem" | "checkServerStatus" | "success" | "failed" | "processing" | "processed" | "noData" | "invalidValueError" | "emailInvalidError" | "phoneInvalidError" | "cancel" | "unauthorized" | "confirmClose" | "textTooShortError" | "textTooLongError" | "selectTooShortError" | "selectTooLongError" | "numberTooSmallError" | "numberTooBigError" | "passwordNotMatchError" | "selectDateError" | "priceUnit" | "passwordConfirm" | "noOptions" | "addModel" | "createModel" | "createSuccess" | "updateModel" | "removeModel" | "updateSuccess" | "removeSuccess" | "sureToRemove" | "irreversibleOps" | "typeNameToRemove" | "yesRemove" | "removeMsg" | "confirmMsg" | "perPage" | "actions" | "edit" | "view">, option?: import("./trans").TransMessageOption) => void;
|
|
15
|
+
loading: (key: import("./locale").ServiceTranslatorKey<"base", BaseEndpoint, "error" | "password" | "save" | "remove" | "ok" | "new" | "somethingWrong" | "connecting" | "connected" | "serverDisconnected" | "refreshing" | "tryReconnecting" | "serverHasProblem" | "checkServerStatus" | "success" | "failed" | "processing" | "processed" | "noData" | "invalidValueError" | "emailInvalidError" | "phoneInvalidError" | "cancel" | "unauthorized" | "confirmClose" | "textTooShortError" | "textTooLongError" | "selectTooShortError" | "selectTooLongError" | "numberTooSmallError" | "numberTooBigError" | "passwordNotMatchError" | "selectDateError" | "priceUnit" | "passwordConfirm" | "noOptions" | "addModel" | "createModel" | "createSuccess" | "updateModel" | "removeModel" | "updateSuccess" | "removeSuccess" | "sureToRemove" | "irreversibleOps" | "typeNameToRemove" | "yesRemove" | "removeMsg" | "confirmMsg" | "perPage" | "actions" | "edit" | "view">, option?: import("./trans").TransMessageOption) => void;
|
|
16
|
+
}, getDictionary: (lang: "en" | "ko" | "zhChs" | "zhCht") => object, getAllDictionary: () => {
|
|
17
|
+
[key: string]: object;
|
|
18
|
+
}, __Dict_Key__: import("./locale").ServiceTranslatorKey<"base", BaseEndpoint, "error" | "password" | "save" | "remove" | "ok" | "new" | "somethingWrong" | "connecting" | "connected" | "serverDisconnected" | "refreshing" | "tryReconnecting" | "serverHasProblem" | "checkServerStatus" | "success" | "failed" | "processing" | "processed" | "noData" | "invalidValueError" | "emailInvalidError" | "phoneInvalidError" | "cancel" | "unauthorized" | "confirmClose" | "textTooShortError" | "textTooLongError" | "selectTooShortError" | "selectTooLongError" | "numberTooSmallError" | "numberTooBigError" | "passwordNotMatchError" | "selectDateError" | "priceUnit" | "passwordConfirm" | "noOptions" | "addModel" | "createModel" | "createSuccess" | "updateModel" | "removeModel" | "updateSuccess" | "removeSuccess" | "sureToRemove" | "irreversibleOps" | "typeNameToRemove" | "yesRemove" | "removeMsg" | "confirmMsg" | "perPage" | "actions" | "edit" | "view">, __Error_Key__: never;
|
package/src/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export * from "./trans";
|
|
2
|
-
export { Revert, translate, dictionary, getDictionary, getAllDictionary } from "./dictionary";
|
|
2
|
+
export { Revert, translate, dictionary, getDictionary, getAllDictionary, __Dict_Key__, __Error_Key__, } from "./dictionary";
|
|
3
3
|
export * from "./serverTranslator";
|
|
4
|
+
export * from "./dictInfo";
|
|
5
|
+
export * from "./locale";
|
package/src/locale.d.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { BaseInsight, BaseObject, GetStateObject, MergedValues } from "@akanjs/base";
|
|
2
|
+
import { FilterInfo, FilterInstance } from "@akanjs/document";
|
|
3
|
+
import { ApiInfo, SliceInfo } from "@akanjs/signal";
|
|
4
|
+
import { ModelDictInfo, ScalarDictInfo, ServiceDictInfo } from ".";
|
|
5
|
+
interface Trans {
|
|
6
|
+
t: string;
|
|
7
|
+
}
|
|
8
|
+
interface FieldTrans {
|
|
9
|
+
t: string;
|
|
10
|
+
desc?: string;
|
|
11
|
+
}
|
|
12
|
+
interface FnTrans<ArgKey extends string> {
|
|
13
|
+
t: string;
|
|
14
|
+
desc?: string;
|
|
15
|
+
arg?: {
|
|
16
|
+
[key in ArgKey]: FieldTrans;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
type FilterTranslatorKey<Filter extends FilterInstance> = {
|
|
20
|
+
[Key in keyof Filter["query"] & string]: `${Key}` | `${Key}.desc` | (Filter["query"][Key] extends FilterInfo<infer ArgNames, any> ? ArgNames[number] extends string ? `${Key}.arg.${ArgNames[number]}` | `${Key}.arg.${ArgNames[number]}.desc` : never : never);
|
|
21
|
+
}[keyof Filter["query"] & string];
|
|
22
|
+
type EndpointTranslatorKey<Endpoint> = {
|
|
23
|
+
[Key in keyof Endpoint & string]: `${Key}` | `${Key}.desc` | (Endpoint[Key] extends ApiInfo<any, any, infer ArgNames, any, any, any, any, any, any> ? ArgNames[number] extends string ? `${Key}.arg.${ArgNames[number]}` | `${Key}.arg.${ArgNames[number]}.desc` : never : never);
|
|
24
|
+
}[keyof Endpoint & string];
|
|
25
|
+
type SliceTranslatorKey<Slice> = {
|
|
26
|
+
[Key in keyof Slice & string]: Slice[Key] extends SliceInfo<infer T, any, any, any, any, infer ArgNames, any, any, any> ? `${T}List${Capitalize<Key>}` | `${T}List${Capitalize<Key>}.desc` | `${T}List${Capitalize<Key>}.arg.${ArgNames[number] | "skip" | "limit" | "sort"}` | `${T}List${Capitalize<Key>}.arg.${ArgNames[number] | "skip" | "limit" | "sort"}.desc` | `${T}Insight${Capitalize<Key>}` | `${T}Insight${Capitalize<Key>}.desc` | `${T}Insight${Capitalize<Key>}.arg.${ArgNames[number]}` | `${T}Insight${Capitalize<Key>}.arg.${ArgNames[number]}.desc` : never;
|
|
27
|
+
}[keyof Slice & string];
|
|
28
|
+
type SliceApiTrans<T extends string, Suffix extends string, ArgName extends string, _CapitalizedSuffix extends string = Capitalize<Suffix>> = {
|
|
29
|
+
[K in `${T}List${_CapitalizedSuffix}`]: FnTrans<ArgName | "skip" | "limit" | "sort">;
|
|
30
|
+
} & {
|
|
31
|
+
[K in `${T}Insight${_CapitalizedSuffix}`]: FnTrans<ArgName>;
|
|
32
|
+
};
|
|
33
|
+
type BaseModelCrudGetApiTrans<T extends string> = {
|
|
34
|
+
[K in T]: FnTrans<`${T}Id`>;
|
|
35
|
+
} & {
|
|
36
|
+
[K in `light${T}`]: FnTrans<`${T}Id`>;
|
|
37
|
+
} & {
|
|
38
|
+
[K in `create${T}`]: FnTrans<"data">;
|
|
39
|
+
} & {
|
|
40
|
+
[K in `update${T}`]: FnTrans<`${T}Id` | "data">;
|
|
41
|
+
} & {
|
|
42
|
+
[K in `remove${T}`]: FnTrans<`${T}Id`>;
|
|
43
|
+
};
|
|
44
|
+
export type ModelTrans<T extends string, Model extends BaseObject, Insight extends BaseInsight, Filter extends FilterInstance, Slice, Endpoint, ErrorKey extends string, EtcKey extends string> = {
|
|
45
|
+
modelName: Trans;
|
|
46
|
+
modelDesc: Trans;
|
|
47
|
+
model: {
|
|
48
|
+
[K in keyof GetStateObject<Model>]: FieldTrans;
|
|
49
|
+
};
|
|
50
|
+
insight: {
|
|
51
|
+
[K in keyof GetStateObject<Insight>]: FieldTrans;
|
|
52
|
+
};
|
|
53
|
+
query: {
|
|
54
|
+
[K in keyof Filter["query"]]: Filter["query"][K] extends FilterInfo<infer ArgNames, any> ? FnTrans<ArgNames[number]> : never;
|
|
55
|
+
};
|
|
56
|
+
sort: {
|
|
57
|
+
[K in keyof Filter["sort"]]: FieldTrans;
|
|
58
|
+
};
|
|
59
|
+
api: {
|
|
60
|
+
[K in keyof Endpoint]: Endpoint[K] extends ApiInfo<any, any, infer ArgNames, any, any, any, any, any, any> ? FnTrans<ArgNames[number]> : never;
|
|
61
|
+
} & BaseModelCrudGetApiTrans<T> & MergedValues<{
|
|
62
|
+
[K in keyof Slice]: Slice[K] extends SliceInfo<infer T, any, any, any, any, infer ArgNames, any, any, any> ? SliceApiTrans<T, K & string, ArgNames[number]> : never;
|
|
63
|
+
}>;
|
|
64
|
+
error: {
|
|
65
|
+
[K in ErrorKey]: Trans;
|
|
66
|
+
};
|
|
67
|
+
} & {
|
|
68
|
+
[K in EtcKey]: Trans;
|
|
69
|
+
};
|
|
70
|
+
export type ModelTranslatorKey<T extends string, Model, Insight, Filter extends FilterInstance, Slice, Endpoint, EtcKey extends string> = `${T}.modelName` | `${T}.modelDesc` | `${T}.${keyof GetStateObject<Model> & string}${"" | ".desc"}` | `${T}.insight.${keyof GetStateObject<Insight> & string}${"" | ".desc"}` | `${T}.query.${FilterTranslatorKey<Filter>}` | `${T}.sort.${keyof Filter["sort"] & string}${"" | ".desc"}` | `${T}.signal.${EndpointTranslatorKey<Endpoint> | SliceTranslatorKey<Slice>}` | `${T}.${EtcKey}`;
|
|
71
|
+
export type ScalarTrans<T extends string, Model, ErrorKey extends string, EtcKey extends string> = {
|
|
72
|
+
name: Trans;
|
|
73
|
+
desc: Trans;
|
|
74
|
+
model: {
|
|
75
|
+
[K in keyof GetStateObject<Model>]: FieldTrans;
|
|
76
|
+
};
|
|
77
|
+
error: {
|
|
78
|
+
[K in ErrorKey]: Trans;
|
|
79
|
+
};
|
|
80
|
+
} & {
|
|
81
|
+
[K in EtcKey]: Trans;
|
|
82
|
+
};
|
|
83
|
+
export type ScalarTranslatorKey<T extends string, Model, EtcKey extends string> = `${T}.modelName` | `${T}.modelDesc` | `${T}.${keyof GetStateObject<Model> & string}${"" | ".desc"}` | `${T}.${EtcKey}`;
|
|
84
|
+
export type ServiceTrans<T extends string, Endpoint, ErrorKey extends string, EtcKey extends string> = {
|
|
85
|
+
api: {
|
|
86
|
+
[K in keyof Endpoint]: Endpoint[K] extends ApiInfo<any, any, infer ArgNames, any, any, any, any, any, any> ? FnTrans<ArgNames[number]> : never;
|
|
87
|
+
};
|
|
88
|
+
error: {
|
|
89
|
+
[K in ErrorKey]: Trans;
|
|
90
|
+
};
|
|
91
|
+
} & {
|
|
92
|
+
[K in EtcKey]: Trans;
|
|
93
|
+
};
|
|
94
|
+
export type ServiceTranslatorKey<T extends string, Endpoint, EtcKey extends string> = `${T}.signal.${EndpointTranslatorKey<Endpoint>}` | `${T}.${EtcKey}`;
|
|
95
|
+
export type EnumTrans<EnumValue extends string | number> = {
|
|
96
|
+
[key in EnumValue]: Trans;
|
|
97
|
+
};
|
|
98
|
+
export type EnumTranslatorKey<EnumKey extends string> = `${EnumKey}.${string}${"" | ".desc"}`;
|
|
99
|
+
export interface DictModule<DictKey extends string, ErrorKey extends string> {
|
|
100
|
+
__Dict_Key__: DictKey;
|
|
101
|
+
__Error_Key__: ErrorKey;
|
|
102
|
+
dict: ModelDictInfo<any> | ScalarDictInfo<any> | ServiceDictInfo<any>;
|
|
103
|
+
}
|
|
104
|
+
export declare const registerModelTrans: <T extends string, Model extends BaseObject, Insight extends BaseInsight, Filter extends FilterInstance, Slice, Endpoint, ModelDict extends ModelDictInfo<any>>(modelDict: ModelDict) => ModelDict extends ModelDictInfo<any, any, any, any, any, infer EnumKey, any, any, any, infer ErrorKey, infer EtcKey> ? DictModule<ModelTranslatorKey<T, Model, Insight, Filter, Slice, Endpoint, EtcKey> | EnumTranslatorKey<EnumKey>, `${T}.error.${ErrorKey}`> : never;
|
|
105
|
+
export declare const registerScalarTrans: <T extends string, Model, ScalarDict>(scalarDict: ScalarDict) => ScalarDict extends ScalarDictInfo<any, any, infer EnumKey, infer ErrorKey, infer EtcKey> ? DictModule<ScalarTranslatorKey<T, Model, EtcKey> | EnumTranslatorKey<EnumKey>, `${T}.error.${ErrorKey}`> : never;
|
|
106
|
+
export declare const registerServiceTrans: <T extends string, Endpoint, ServiceDict>(serviceDict: ServiceDict) => ServiceDict extends ServiceDictInfo<any, any, infer ErrorKey, infer EtcKey> ? DictModule<ServiceTranslatorKey<T, Endpoint, EtcKey>, `${T}.error.${ErrorKey}`> : never;
|
|
107
|
+
export {};
|
|
@@ -13,7 +13,7 @@ export declare class ServerTranslator {
|
|
|
13
13
|
hasTranslator(lang: string): boolean;
|
|
14
14
|
setTranslator(lang: string, dictionary: Dictionary): {
|
|
15
15
|
dictionary: Dictionary;
|
|
16
|
-
translate: (dictKey:
|
|
16
|
+
translate: (dictKey: string) => string;
|
|
17
17
|
};
|
|
18
18
|
getTransSync(lang: string, key: string, param?: Record<string, string | number>): string | undefined;
|
|
19
19
|
getTrans(lang: string, key: string, param?: Record<string, string | number>): Promise<string>;
|
package/src/trans.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import
|
|
3
|
-
import { DefaultSignal } from "@akanjs/signal";
|
|
1
|
+
import type { GetStateObject, ObjectAssign, Prettify } from "@akanjs/base";
|
|
2
|
+
import { DictModule } from "./locale";
|
|
4
3
|
type TranslationSingle = readonly [string, string] | readonly [string, string, string, string];
|
|
5
4
|
type TranslationWithParam = readonly [string, string, {
|
|
6
5
|
[key: string]: string | number;
|
|
@@ -11,65 +10,12 @@ export type Translate<Checker> = {
|
|
|
11
10
|
} & Record<string, Translation> & {
|
|
12
11
|
modelName: Translation;
|
|
13
12
|
};
|
|
14
|
-
export type ExtendModelDictionary<Model, Insight = unknown, Filter = unknown> = {
|
|
15
|
-
[K in keyof Omit<GetStateObject<Model & Insight & Filter>, BaseFilterKey> as K extends string ? K | `desc-${K}` : never]: Translation;
|
|
16
|
-
} & {
|
|
17
|
-
[K in keyof Omit<GetActionObject<Filter>, BaseFilterKey> as K extends string ? `qry-${K}` | `qrydesc-${K}` : never]: Translation;
|
|
18
|
-
} & Record<string, Translation>;
|
|
19
|
-
export type ModelDictionary<Model, Insight = unknown, Filter = unknown> = {
|
|
20
|
-
[K in keyof Omit<GetStateObject<Model & Insight & Filter>, BaseFilterKey> as K extends string ? K | `desc-${K}` : never]: Translation;
|
|
21
|
-
} & {
|
|
22
|
-
[K in keyof Omit<GetActionObject<Filter>, BaseFilterKey> as K extends string ? `qry-${K}` | `qrydesc-${K}` : never]: Translation;
|
|
23
|
-
} & Record<string, Translation> & {
|
|
24
|
-
modelName: Translation;
|
|
25
|
-
modelDesc: Translation;
|
|
26
|
-
};
|
|
27
|
-
export type SignalDictionary<Checker, Model = unknown> = {
|
|
28
|
-
[K in keyof Omit<GetActionObject<Checker>, keyof Model> as K extends string ? `apidesc-${K}` | `api-${K}` : never]: Translation;
|
|
29
|
-
} & Record<string, Translation>;
|
|
30
13
|
export type TransMessage<Locale extends Record<string, any>> = {
|
|
31
14
|
[K in keyof Locale]-?: `${K & string}${Locale[K] extends Record<string, any> ? `.${keyof Locale[K] & string}` : ""}`;
|
|
32
15
|
}[keyof Locale];
|
|
33
|
-
export declare const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
readonly createdAt: readonly ["CreatedAt", "생성일"];
|
|
37
|
-
readonly "desc-createdAt": readonly ["Data created time", "데이터 생성 시각"];
|
|
38
|
-
readonly updatedAt: readonly ["UpdatedAt", "수정일"];
|
|
39
|
-
readonly "desc-updatedAt": readonly ["Data updated time", "데이터 마지막 수정 시각"];
|
|
40
|
-
readonly removedAt: readonly ["RemovedAt", "삭제일"];
|
|
41
|
-
readonly "desc-removedAt": readonly ["Data removed time", "데이터 삭제 시각"];
|
|
42
|
-
readonly status: readonly ["Status", "상태"];
|
|
43
|
-
readonly "desc-status": readonly ["Data status", "데이터 상태"];
|
|
44
|
-
readonly count: readonly ["Count", "개수"];
|
|
45
|
-
readonly "desc-count": readonly ["Data count", "데이터 개수"];
|
|
46
|
-
readonly latest: readonly ["latest", "최신순"];
|
|
47
|
-
readonly "desc-latest": readonly ["latest", "최신순"];
|
|
48
|
-
readonly oldest: readonly ["oldest", "오래된순"];
|
|
49
|
-
readonly "desc-oldest": readonly ["oldest", "오래된순"];
|
|
50
|
-
readonly "qry-any": readonly ["All", "전체"];
|
|
51
|
-
readonly "qrydesc-any": readonly ["All", "전체"];
|
|
52
|
-
readonly "qry-byStatuses": readonly ["By Statuses", "상태별 조회"];
|
|
53
|
-
readonly "qrydesc-byStatuses": readonly ["By Statuses", "상태별 조회"];
|
|
54
|
-
readonly "qarg-byStatuses-statuses": readonly ["Statuses", "상태"];
|
|
55
|
-
readonly "qargdesc-byStatuses-statuses": readonly ["Statuses", "상태"];
|
|
56
|
-
};
|
|
57
|
-
type BaseSignalTrans<T extends string> = {
|
|
58
|
-
[K in keyof DefaultSignal<T, any, any, any, any, any> as K extends string ? `apidesc-${K}` | `api-${K}` : never]: Translation;
|
|
59
|
-
};
|
|
60
|
-
export declare const getBaseSignalTrans: <T extends string>(modelName: T) => BaseSignalTrans<T>;
|
|
61
|
-
interface DictType {
|
|
62
|
-
[key: string]: {
|
|
63
|
-
[key: string]: Translation;
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
type MergeTwo<T, U> = T & U;
|
|
67
|
-
type MergeAll<T extends readonly DictType[]> = T extends readonly [
|
|
68
|
-
infer First extends DictType,
|
|
69
|
-
...infer Rest extends readonly DictType[]
|
|
70
|
-
] ? Rest extends readonly [] ? First : MergeTwo<First, MergeAll<Rest>> : never;
|
|
71
|
-
export declare const rootDictionary: DictType;
|
|
72
|
-
export declare const makeDictionary: <T extends readonly [DictType, ...DictType[]]>(...dicts: T) => MergeAll<T>;
|
|
16
|
+
export declare const makeDictionary: <Dicts extends {
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
}[]>(...dicts: Dicts) => Prettify<ObjectAssign<Dicts>>;
|
|
73
19
|
declare const languages: readonly ["en", "ko", "zhChs", "zhCht"];
|
|
74
20
|
type Language = (typeof languages)[number];
|
|
75
21
|
export interface TransMessageOption {
|
|
@@ -86,37 +32,29 @@ export declare const msg: {
|
|
|
86
32
|
warning: (key: TransMessage<any>, option?: TransMessageOption) => void;
|
|
87
33
|
loading: (key: TransMessage<any>, option?: TransMessageOption) => void;
|
|
88
34
|
};
|
|
89
|
-
export declare const makeTrans: <
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}>(locale: Locale) => {
|
|
94
|
-
revert: (key: TransMessage<Locale>, data?: any) => never;
|
|
35
|
+
export declare const makeTrans: <GlobalTransMap extends Record<string, DictModule<string, string>>, _DictKey extends string = GlobalTransMap[keyof GlobalTransMap]["__Dict_Key__"], _ErrorKey extends string = GlobalTransMap[keyof GlobalTransMap]["__Error_Key__"]>(transMap: GlobalTransMap, { build }?: {
|
|
36
|
+
build?: boolean;
|
|
37
|
+
}) => {
|
|
38
|
+
revert: (key: _ErrorKey, data?: any) => never;
|
|
95
39
|
Revert: {
|
|
96
|
-
new (key:
|
|
40
|
+
new (key: _ErrorKey, data?: any): Error;
|
|
97
41
|
prototype: Error;
|
|
98
42
|
};
|
|
99
|
-
translate: (lang: Language, key:
|
|
43
|
+
translate: (lang: Language, key: _DictKey, data?: {
|
|
100
44
|
[key: string]: any;
|
|
101
45
|
}) => string;
|
|
102
46
|
msg: {
|
|
103
|
-
info: (key:
|
|
104
|
-
success: (key:
|
|
105
|
-
error: (key:
|
|
106
|
-
warning: (key:
|
|
107
|
-
loading: (key:
|
|
108
|
-
};
|
|
109
|
-
getDictionary: (lang: Language) => {
|
|
110
|
-
[key: string]: {
|
|
111
|
-
[key: string]: string;
|
|
112
|
-
};
|
|
47
|
+
info: (key: _DictKey, option?: TransMessageOption) => void;
|
|
48
|
+
success: (key: _DictKey, option?: TransMessageOption) => void;
|
|
49
|
+
error: (key: _DictKey, option?: TransMessageOption) => void;
|
|
50
|
+
warning: (key: _DictKey, option?: TransMessageOption) => void;
|
|
51
|
+
loading: (key: _DictKey, option?: TransMessageOption) => void;
|
|
113
52
|
};
|
|
53
|
+
getDictionary: (lang: Language) => object;
|
|
114
54
|
getAllDictionary: () => {
|
|
115
|
-
[key: string]:
|
|
116
|
-
[key: string]: {
|
|
117
|
-
[key: string]: string;
|
|
118
|
-
};
|
|
119
|
-
};
|
|
55
|
+
[key: string]: object;
|
|
120
56
|
};
|
|
57
|
+
__Dict_Key__: _DictKey;
|
|
58
|
+
__Error_Key__: _ErrorKey;
|
|
121
59
|
};
|
|
122
60
|
export {};
|