@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.
@@ -20,49 +20,33 @@ __export(base_dictionary_exports, {
20
20
  baseDictionary: () => baseDictionary
21
21
  });
22
22
  module.exports = __toCommonJS(base_dictionary_exports);
23
- const baseDictionary = {
24
- // * ==================== Endpoint ==================== * //
25
- "api-publishPing": ["Publish Ping", "Publish Ping"],
26
- "apidesc-publishPing": ["Publish Ping", "Publish Ping"],
27
- "api-ping": ["Ping", "Ping"],
28
- "apidesc-ping": ["Ping", "Ping"],
29
- "api-pingBody": ["Ping Body", "Ping Body"],
30
- "apidesc-pingBody": ["Ping Body", "Ping Body"],
31
- "arg-pingBody-data": ["Body data", "\uBC14\uB514 \uB370\uC774\uD130"],
32
- "argdesc-pingBody-data": ["Body data", "\uBC14\uB514 \uB370\uC774\uD130"],
33
- "api-pingParam": ["Ping Param", "Ping Param"],
34
- "apidesc-pingParam": ["Ping Param", "Ping Param"],
35
- "arg-pingParam-id": ["ID", "\uC544\uC774\uB514"],
36
- "argdesc-pingParam-id": ["ID", "\uC544\uC774\uB514"],
37
- "api-pingQuery": ["Ping Query", "Ping Query"],
38
- "apidesc-pingQuery": ["Ping Query", "Ping Query"],
39
- "arg-pingQuery-id": ["ID", "\uC544\uC774\uB514"],
40
- "argdesc-pingQuery-id": ["ID", "\uC544\uC774\uB514"],
41
- "api-pingEvery": ["Ping Every", "Ping Every"],
42
- "apidesc-pingEvery": ["Ping Every", "Ping Every"],
43
- "api-pingUser": ["Ping User", "Ping User"],
44
- "apidesc-pingUser": ["Ping User", "Ping User"],
45
- "api-pingAdmin": ["Ping Admin", "Ping Admin"],
46
- "apidesc-pingAdmin": ["Ping Admin", "Ping Admin"],
47
- "api-cleanup": ["Cleanup", "Cleanup"],
48
- "apidesc-cleanup": ["Cleanup", "Cleanup"],
49
- "api-wsPing": ["Socket.io Ping", "Socket.io Ping"],
50
- "apidesc-wsPing": ["Socket.io Ping", "Socket.io Ping"],
51
- "arg-wsPing-data": ["Data", "\uB370\uC774\uD130"],
52
- "argdesc-wsPing-data": ["Data", "\uB370\uC774\uD130"],
53
- "api-pubsubPing": ["Pubsub Ping", "Pubsub Ping"],
54
- "apidesc-pubsubPing": ["Pubsub Ping", "Pubsub Ping"],
55
- "api-getDictionary": ["Get Dictionary", "Get Dictionary"],
56
- "apidesc-getDictionary": ["Get Dictionary", "Get Dictionary"],
57
- "arg-getDictionary-lang": ["Language", "\uC5B8\uC5B4"],
58
- "argdesc-getDictionary-lang": ["Language", "\uC5B8\uC5B4"],
59
- "api-getAllDictionary": ["Get All Dictionary", "Get All Dictionary"],
60
- "apidesc-getAllDictionary": ["Get All Dictionary", "Get All Dictionary"],
61
- "api-getSignals": ["Get Signals", "Get Signals"],
62
- "apidesc-getSignals": ["Get Signals", "Get Signals"],
63
- // * ==================== Endpoint ==================== * //
64
- // * ==================== Etc ==================== * //
65
- // new: ["New", "신규"],
23
+ var import_dictInfo = require("./dictInfo");
24
+ const baseDictionary = (0, import_dictInfo.serviceDictionary)(["en", "ko"]).endpoint((fn) => ({
25
+ publishPing: fn(["Publish Ping", "Publish Ping"]),
26
+ ping: fn(["Ping", "Ping"]),
27
+ pingBody: fn(["Ping Body", "Ping Body"]).arg((t) => ({
28
+ data: t(["Body data", "\uBC14\uB514 \uB370\uC774\uD130"])
29
+ })),
30
+ pingParam: fn(["Ping Param", "Ping Param"]).arg((t) => ({
31
+ id: t(["ID", "\uC544\uC774\uB514"])
32
+ })),
33
+ pingQuery: fn(["Ping Query", "Ping Query"]).arg((t) => ({
34
+ id: t(["ID", "\uC544\uC774\uB514"])
35
+ })),
36
+ pingEvery: fn(["Ping Every", "Ping Every"]),
37
+ pingUser: fn(["Ping User", "Ping User"]),
38
+ pingAdmin: fn(["Ping Admin", "Ping Admin"]),
39
+ getDictionary: fn(["Get Dictionary", "Get Dictionary"]).arg((t) => ({
40
+ lang: t(["Language", "\uC5B8\uC5B4"])
41
+ })),
42
+ getAllDictionary: fn(["Get All Dictionary", "Get All Dictionary"]),
43
+ cleanup: fn(["Cleanup", "Cleanup"]),
44
+ wsPing: fn(["Socket.io Ping", "Socket.io Ping"]).arg((t) => ({
45
+ data: t(["Data", "\uB370\uC774\uD130"])
46
+ })),
47
+ pubsubPing: fn(["Pubsub Ping", "Pubsub Ping"]),
48
+ getSignals: fn(["Get Signals", "Get Signals"])
49
+ })).translate({
66
50
  somethingWrong: ["Something's wrong!", "\uBB38\uC81C\uAC00 \uC0DD\uACBC\uC5B4\uC694!"],
67
51
  connecting: ["Connecting...", "\uC5F0\uACB0 \uC911..."],
68
52
  connected: ["Connected!", "\uC5F0\uACB0\uB418\uC5C8\uC2B5\uB2C8\uB2E4!"],
@@ -122,5 +106,4 @@ const baseDictionary = {
122
106
  save: ["Save", "\uC800\uC7A5"],
123
107
  remove: ["Remove", "\uC0AD\uC81C"],
124
108
  view: ["View", "\uBCF4\uAE30"]
125
- // * ==================== Etc ==================== * //
126
- };
109
+ });
@@ -0,0 +1,484 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var dictInfo_exports = {};
19
+ __export(dictInfo_exports, {
20
+ ModelDictInfo: () => ModelDictInfo,
21
+ ScalarDictInfo: () => ScalarDictInfo,
22
+ ServiceDictInfo: () => ServiceDictInfo,
23
+ modelDictionary: () => modelDictionary,
24
+ scalarDictionary: () => scalarDictionary,
25
+ serviceDictionary: () => serviceDictionary
26
+ });
27
+ module.exports = __toCommonJS(dictInfo_exports);
28
+ var import_common = require("@akanjs/common");
29
+ class FieldTranslation {
30
+ static translate = (trans) => new FieldTranslation(trans);
31
+ trans;
32
+ descTrans;
33
+ constructor(trans) {
34
+ this.trans = trans;
35
+ }
36
+ desc(descTrans) {
37
+ this.descTrans = descTrans;
38
+ return this;
39
+ }
40
+ }
41
+ class FunctionTranslation {
42
+ trans;
43
+ descTrans;
44
+ argTrans = {};
45
+ constructor(trans) {
46
+ this.trans = trans;
47
+ }
48
+ desc(descTrans) {
49
+ this.descTrans = descTrans;
50
+ return this;
51
+ }
52
+ arg(translate) {
53
+ Object.assign(this.argTrans, translate(FieldTranslation.translate));
54
+ return this;
55
+ }
56
+ }
57
+ const fn = (trans) => new FunctionTranslation(trans);
58
+ class ModelDictInfo {
59
+ static baseModelDictionary = {
60
+ id: FieldTranslation.translate(["ID", "\uC544\uC774\uB514"]).desc(["Unique ID value", "\uC720\uB2C8\uD06C\uD55C \uC544\uC774\uB514\uAC12"]),
61
+ createdAt: FieldTranslation.translate(["CreatedAt", "\uC0DD\uC131\uC77C"]).desc(["Data created time", "\uB370\uC774\uD130 \uC0DD\uC131 \uC2DC\uAC01"]),
62
+ updatedAt: FieldTranslation.translate(["UpdatedAt", "\uC218\uC815\uC77C"]).desc([
63
+ "Data updated time",
64
+ "\uB370\uC774\uD130 \uB9C8\uC9C0\uB9C9 \uC218\uC815 \uC2DC\uAC01"
65
+ ]),
66
+ removedAt: FieldTranslation.translate(["RemovedAt", "\uC0AD\uC81C\uC77C"]).desc(["Data removed time", "\uB370\uC774\uD130 \uC0AD\uC81C \uC2DC\uAC01"])
67
+ };
68
+ static baseInsightDictionary = {
69
+ count: FieldTranslation.translate(["Count", "\uAC1C\uC218"]).desc(["Total number of items", "\uCD1D \uC544\uC774\uD15C \uAC1C\uC218"])
70
+ };
71
+ static baseQueryDictionary = {
72
+ any: fn(["Any", "\uC804\uCCB4"]).desc(["All", "\uC804\uCCB4"])
73
+ };
74
+ static baseSortDictionary = {
75
+ latest: FieldTranslation.translate(["Latest", "\uCD5C\uC2E0\uC21C"]).desc(["Latest", "\uCD5C\uC2E0\uC21C"]),
76
+ oldest: FieldTranslation.translate(["Oldest", "\uC624\uB798\uB41C\uC21C"]).desc(["Oldest", "\uC624\uB798\uB41C\uC21C"])
77
+ };
78
+ static getBaseSignalDictionary(refName) {
79
+ return {
80
+ [refName]: fn([`Get ${refName}`, `${refName} \uC870\uD68C`]).desc([`Get ${refName}`, `${refName} \uC870\uD68C`]).arg((t) => ({ [`${refName}Id`]: t(["Id", "\uC544\uC774\uB514"]).desc([`Id of ${refName}`, `${refName} \uC544\uC774\uB514`]) })),
81
+ [`light${refName}`]: fn([`Get light version of ${refName}`, `${refName} \uACBD\uB7C9\uD654 \uBC84\uC804 \uC870\uD68C`]).desc([`Get light version of ${refName}`, `${refName} \uACBD\uB7C9\uD654 \uBC84\uC804 \uC870\uD68C`]).arg((t) => ({ [`${refName}Id`]: t(["Id", "\uC544\uC774\uB514"]).desc([`Id of ${refName}`, `${refName} \uC544\uC774\uB514`]) })),
82
+ [`create${refName}`]: fn([`Create ${refName}`, `${refName} \uC0DD\uC131`]).desc([`Create ${refName}`, `${refName} \uC0DD\uC131`]).arg((t) => ({ data: t(["Data", "\uB370\uC774\uD130"]).desc([`Data of ${refName}`, `${refName} \uB370\uC774\uD130`]) })),
83
+ [`update${refName}`]: fn([`Update ${refName}`, `${refName} \uC218\uC815`]).desc([`Update ${refName}`, `${refName} \uC218\uC815`]).arg((t) => ({
84
+ [`${refName}Id`]: t(["Id", "\uC544\uC774\uB514"]).desc([`Id of ${refName}`, `${refName} \uC544\uC774\uB514`]),
85
+ data: t(["Data", "\uB370\uC774\uD130"]).desc([`Data of ${refName}`, `${refName} \uB370\uC774\uD130`])
86
+ })),
87
+ [`remove${refName}`]: fn([`Remove ${refName}`, `${refName} \uC0AD\uC81C`]).desc([`Remove ${refName}`, `${refName} \uC0AD\uC81C`]).arg((t) => ({ [`${refName}Id`]: t(["Id", "\uC544\uC774\uB514"]).desc([`Id of ${refName}`, `${refName} \uC544\uC774\uB514`]) }))
88
+ };
89
+ }
90
+ static baseSliceDictionary = {
91
+ [""]: fn(["Universal", "\uC720\uB2C8\uBC84\uC124"]).desc(["Universal Slice", "\uC720\uB2C8\uBC84\uC124 \uC2AC\uB77C\uC774\uC2A4"]).arg((t) => ({ query: t(["Query", "\uCFFC\uB9AC"]).desc(["Query Description", "\uCFFC\uB9AC \uC124\uBA85"]) }))
92
+ };
93
+ languages;
94
+ modelTranslation;
95
+ modelDictionary = {};
96
+ insightDictionary = {};
97
+ queryDictionary = {};
98
+ sortDictionary = {};
99
+ enumDictionary = {};
100
+ baseSignalDictionary = {};
101
+ sliceDictionary = {};
102
+ endpointDictionary = {};
103
+ errorDictionary = {};
104
+ etcDictionary = {};
105
+ constructor(languages) {
106
+ this.languages = languages;
107
+ }
108
+ of(translate) {
109
+ this.modelTranslation = translate(FieldTranslation.translate);
110
+ return this;
111
+ }
112
+ model(translate) {
113
+ Object.assign(
114
+ this.modelDictionary,
115
+ translate(FieldTranslation.translate),
116
+ ModelDictInfo.baseModelDictionary
117
+ );
118
+ return this;
119
+ }
120
+ insight(translate) {
121
+ Object.assign(
122
+ this.insightDictionary,
123
+ translate(FieldTranslation.translate),
124
+ ModelDictInfo.baseInsightDictionary
125
+ );
126
+ return this;
127
+ }
128
+ query(translate) {
129
+ Object.assign(this.queryDictionary, translate(fn), ModelDictInfo.baseQueryDictionary);
130
+ return this;
131
+ }
132
+ sort(translate) {
133
+ Object.assign(
134
+ this.sortDictionary,
135
+ translate(FieldTranslation.translate),
136
+ ModelDictInfo.baseSortDictionary
137
+ );
138
+ return this;
139
+ }
140
+ enum(enumName, translate) {
141
+ Object.assign(this.enumDictionary, { [enumName]: translate(FieldTranslation.translate) });
142
+ return this;
143
+ }
144
+ slice(translate) {
145
+ Object.assign(this.sliceDictionary, translate(fn), ModelDictInfo.baseSliceDictionary);
146
+ return this;
147
+ }
148
+ endpoint(translate) {
149
+ Object.assign(this.endpointDictionary, translate(fn));
150
+ return this;
151
+ }
152
+ error(errorDictionary) {
153
+ Object.assign(this.errorDictionary, errorDictionary);
154
+ return this;
155
+ }
156
+ translate(etcDictionary) {
157
+ Object.assign(this.etcDictionary, etcDictionary);
158
+ return this;
159
+ }
160
+ _applyBaseSignal(refName) {
161
+ Object.assign(this.baseSignalDictionary, ModelDictInfo.getBaseSignalDictionary(refName));
162
+ return this;
163
+ }
164
+ _registerToRoot(refName, rootDict) {
165
+ this.languages.forEach((language) => {
166
+ rootDict[language] ??= {};
167
+ rootDict[language][refName] ??= {};
168
+ });
169
+ if (this.modelTranslation) {
170
+ this.modelTranslation.trans.forEach((t, idx) => rootDict[this.languages[idx]][refName].modelName = { t });
171
+ this.modelTranslation.descTrans?.forEach((t, idx) => rootDict[this.languages[idx]][refName].modelDesc = { t });
172
+ }
173
+ this.#registerInsightToRoot(refName, rootDict);
174
+ this.#registerQueryToRoot(refName, rootDict);
175
+ this.#registerSortToRoot(refName, rootDict);
176
+ this.#registerEnumToRoot(rootDict);
177
+ this.#registerBaseSignalToRoot(refName, rootDict);
178
+ this.#registerSliceToRoot(refName, rootDict);
179
+ this.#registerEndpointToRoot(refName, rootDict);
180
+ this.#registerErrorToRoot(refName, rootDict);
181
+ this.#registerModelToRoot(refName, rootDict);
182
+ this.#registerEtcToRoot(refName, rootDict);
183
+ }
184
+ #registerModelToRoot(refName, rootDict) {
185
+ Object.entries(this.modelDictionary).forEach(([key, value]) => {
186
+ value.trans.forEach((t, idx) => rootDict[this.languages[idx]][refName][key] = { t });
187
+ value.descTrans?.forEach((t, idx) => rootDict[this.languages[idx]][refName][key].desc = { t });
188
+ });
189
+ }
190
+ #registerInsightToRoot(refName, rootDict) {
191
+ this.languages.forEach((language) => rootDict[language][refName].insight ??= {});
192
+ Object.entries(this.insightDictionary).forEach(([key, value]) => {
193
+ value.trans.forEach((t, idx) => rootDict[this.languages[idx]][refName].insight[key] = { t });
194
+ value.descTrans?.forEach((t, idx) => rootDict[this.languages[idx]][refName].insight[key].desc = { t });
195
+ });
196
+ }
197
+ #registerQueryToRoot(refName, rootDict) {
198
+ this.languages.forEach((language) => rootDict[language][refName].query ??= {});
199
+ Object.entries(this.queryDictionary).forEach(
200
+ ([key, value]) => {
201
+ value.trans.forEach((t, idx) => rootDict[this.languages[idx]][refName].query[key] = { t, arg: {} });
202
+ value.descTrans?.forEach((t, idx) => rootDict[this.languages[idx]][refName].query[key].desc = { t });
203
+ Object.entries(value.argTrans).forEach(
204
+ ([argKey, argTrans]) => {
205
+ argTrans.trans.forEach((t, idx) => rootDict[this.languages[idx]][refName].query[key].arg[argKey] = { t });
206
+ argTrans.descTrans?.forEach(
207
+ (t, idx) => rootDict[this.languages[idx]][refName].query[key].arg[argKey].desc = { t }
208
+ );
209
+ }
210
+ );
211
+ }
212
+ );
213
+ }
214
+ #registerSortToRoot(refName, rootDict) {
215
+ this.languages.forEach((language) => rootDict[language][refName].sort ??= {});
216
+ Object.entries(this.sortDictionary).forEach(([key, value]) => {
217
+ value.trans.forEach((t, idx) => rootDict[this.languages[idx]][refName].sort[key] = { t });
218
+ value.descTrans?.forEach((t, idx) => rootDict[this.languages[idx]][refName].sort[key].desc = { t });
219
+ });
220
+ }
221
+ #registerEnumToRoot(rootDict) {
222
+ Object.entries(this.enumDictionary).forEach(
223
+ ([refName, enumTrans]) => {
224
+ this.languages.forEach((language) => rootDict[language][refName] ??= {});
225
+ Object.entries(enumTrans).forEach(([enumKey, enumValue]) => {
226
+ enumValue.trans.forEach((t, idx) => rootDict[this.languages[idx]][refName][enumKey] = { t });
227
+ enumValue.descTrans?.forEach((t, idx) => rootDict[this.languages[idx]][refName][enumKey].desc = { t });
228
+ });
229
+ }
230
+ );
231
+ }
232
+ #registerBaseSignalToRoot(refName, rootDict) {
233
+ this.languages.forEach((language) => rootDict[language][refName].api ??= {});
234
+ Object.entries(this.baseSignalDictionary).forEach(
235
+ ([key, value]) => {
236
+ value.trans.forEach((t, idx) => rootDict[this.languages[idx]][refName].api[key] = { t, arg: {} });
237
+ value.descTrans?.forEach((t, idx) => rootDict[this.languages[idx]][refName].api[key].desc = { t });
238
+ Object.entries(value.argTrans).forEach(
239
+ ([argKey, argTrans]) => {
240
+ argTrans.trans.forEach((t, idx) => rootDict[this.languages[idx]][refName].api[key].arg[argKey] = { t });
241
+ argTrans.descTrans?.forEach(
242
+ (t, idx) => rootDict[this.languages[idx]][refName].api[key].arg[argKey].desc = { t }
243
+ );
244
+ }
245
+ );
246
+ }
247
+ );
248
+ }
249
+ #registerSliceToRoot(refName, rootDict) {
250
+ this.languages.forEach((language) => rootDict[language][refName].api ??= {});
251
+ Object.entries(this.sliceDictionary).forEach(
252
+ ([sliceKey, sliceTrans]) => {
253
+ const listKey = `${refName}List${(0, import_common.capitalize)(sliceKey)}`;
254
+ const insightKey = `${refName}Insight${(0, import_common.capitalize)(sliceKey)}`;
255
+ sliceTrans.trans.forEach(
256
+ (t, idx) => rootDict[this.languages[idx]][refName].api[listKey] = { t: `Slice List - ${t}`, arg: {} }
257
+ );
258
+ sliceTrans.descTrans?.forEach(
259
+ (t, idx) => rootDict[this.languages[idx]][refName].api[listKey].desc = { t: `Slice List - ${t}` }
260
+ );
261
+ sliceTrans.trans.forEach(
262
+ (t, idx) => rootDict[this.languages[idx]][refName].api[insightKey] = { t: `Slice Insight - ${t}`, arg: {} }
263
+ );
264
+ sliceTrans.descTrans?.forEach(
265
+ (t, idx) => rootDict[this.languages[idx]][refName].api[insightKey].desc = { t: `Slice Insight - ${t}` }
266
+ );
267
+ Object.entries(sliceTrans.argTrans).forEach(
268
+ ([argKey, argTrans]) => {
269
+ argTrans.trans.forEach(
270
+ (t, idx) => rootDict[this.languages[idx]][refName].api[listKey].arg[argKey] = { t }
271
+ );
272
+ argTrans.descTrans?.forEach(
273
+ (t, idx) => rootDict[this.languages[idx]][refName].api[listKey].arg[argKey].desc = { t }
274
+ );
275
+ ["skip", "limit", "sort"].forEach((argKey2) => {
276
+ argTrans.trans.forEach(
277
+ (t, idx) => rootDict[this.languages[idx]][refName].api[listKey].arg[argKey2] = { t: argKey2 }
278
+ );
279
+ argTrans.descTrans?.forEach(
280
+ (t, idx) => rootDict[this.languages[idx]][refName].api[listKey].arg[argKey2].desc = { t: argKey2 }
281
+ );
282
+ });
283
+ argTrans.trans.forEach(
284
+ (t, idx) => rootDict[this.languages[idx]][refName].api[insightKey].arg[argKey] = { t }
285
+ );
286
+ argTrans.descTrans?.forEach(
287
+ (t, idx) => rootDict[this.languages[idx]][refName].api[insightKey].arg[argKey].desc = { t }
288
+ );
289
+ }
290
+ );
291
+ }
292
+ );
293
+ }
294
+ #registerEndpointToRoot(refName, rootDict) {
295
+ this.languages.forEach((language) => rootDict[language][refName].api ??= {});
296
+ Object.entries(this.endpointDictionary).forEach(
297
+ ([key, value]) => {
298
+ value.trans.forEach((t, idx) => rootDict[this.languages[idx]][refName].api[key] = { t, arg: {} });
299
+ value.descTrans?.forEach((t, idx) => rootDict[this.languages[idx]][refName].api[key].desc = { t });
300
+ Object.entries(value.argTrans).forEach(
301
+ ([argKey, argTrans]) => {
302
+ argTrans.trans.forEach((t, idx) => rootDict[this.languages[idx]][refName].api[key].arg[argKey] = { t });
303
+ argTrans.descTrans?.forEach(
304
+ (t, idx) => rootDict[this.languages[idx]][refName].api[key].arg[argKey].desc = { t }
305
+ );
306
+ }
307
+ );
308
+ }
309
+ );
310
+ }
311
+ #registerErrorToRoot(refName, rootDict) {
312
+ this.languages.forEach((language) => rootDict[language][refName].error ??= {});
313
+ Object.entries(this.errorDictionary).forEach(([key, value]) => {
314
+ value.forEach((t, idx) => {
315
+ rootDict[this.languages[idx]][refName].error[key] ??= {};
316
+ rootDict[this.languages[idx]][refName].error[key].t = t;
317
+ });
318
+ });
319
+ }
320
+ #registerEtcToRoot(refName, rootDict) {
321
+ Object.entries(this.etcDictionary).forEach(([key, value]) => {
322
+ value.forEach((t, idx) => {
323
+ rootDict[this.languages[idx]][refName][key] ??= {};
324
+ rootDict[this.languages[idx]][refName][key].t = t;
325
+ });
326
+ });
327
+ }
328
+ }
329
+ const modelDictionary = (languages = ["en"], ...extendModelDicts) => {
330
+ const modelDictionary2 = extendModelDicts.at(0) ?? new ModelDictInfo(languages);
331
+ return modelDictionary2;
332
+ };
333
+ class ScalarDictInfo {
334
+ languages;
335
+ modelTranslation;
336
+ modelDictionary = {};
337
+ enumDictionary = {};
338
+ errorDictionary = {};
339
+ etcDictionary = {};
340
+ constructor(languages) {
341
+ this.languages = languages;
342
+ }
343
+ of(translate) {
344
+ this.modelTranslation = translate(FieldTranslation.translate);
345
+ return this;
346
+ }
347
+ model(translate) {
348
+ Object.assign(
349
+ this.modelDictionary,
350
+ translate(FieldTranslation.translate),
351
+ ModelDictInfo.baseModelDictionary
352
+ );
353
+ return this;
354
+ }
355
+ enum(enumName, translate) {
356
+ Object.assign(this.enumDictionary, { [enumName]: translate(FieldTranslation.translate) });
357
+ return this;
358
+ }
359
+ error(errorDictionary) {
360
+ Object.assign(this.errorDictionary, errorDictionary);
361
+ return this;
362
+ }
363
+ translate(etcDictionary) {
364
+ Object.assign(this.etcDictionary, etcDictionary);
365
+ return this;
366
+ }
367
+ _registerToRoot(refName, rootDict) {
368
+ this.languages.forEach((language) => {
369
+ rootDict[language] ??= {};
370
+ rootDict[language][refName] ??= {};
371
+ });
372
+ if (this.modelTranslation) {
373
+ this.modelTranslation.trans.forEach((t, idx) => rootDict[this.languages[idx]][refName].modelName = { t });
374
+ this.modelTranslation.descTrans?.forEach((t, idx) => rootDict[this.languages[idx]][refName].modelDesc = { t });
375
+ }
376
+ this.#registerEnumToRoot(rootDict);
377
+ this.#registerErrorToRoot(refName, rootDict);
378
+ this.#registerModelToRoot(refName, rootDict);
379
+ this.#registerEtcToRoot(refName, rootDict);
380
+ }
381
+ #registerModelToRoot(refName, rootDict) {
382
+ Object.entries(this.modelDictionary).forEach(([key, value]) => {
383
+ value.trans.forEach((t, idx) => rootDict[this.languages[idx]][refName][key] = { t });
384
+ value.descTrans?.forEach((t, idx) => rootDict[this.languages[idx]][refName][key].desc = { t });
385
+ });
386
+ }
387
+ #registerEnumToRoot(rootDict) {
388
+ Object.entries(this.enumDictionary).forEach(
389
+ ([refName, enumTrans]) => {
390
+ this.languages.forEach((language) => rootDict[language][refName] ??= {});
391
+ Object.entries(enumTrans).forEach(([enumKey, enumValue]) => {
392
+ enumValue.trans.forEach((t, idx) => rootDict[this.languages[idx]][refName][enumKey] = { t });
393
+ enumValue.descTrans?.forEach((t, idx) => rootDict[this.languages[idx]][refName][enumKey].desc = { t });
394
+ });
395
+ }
396
+ );
397
+ }
398
+ #registerErrorToRoot(refName, rootDict) {
399
+ this.languages.forEach((language) => rootDict[language][refName].error ??= {});
400
+ Object.entries(this.errorDictionary).forEach(([key, value]) => {
401
+ value.forEach((t, idx) => {
402
+ rootDict[this.languages[idx]][refName].error[key] ??= {};
403
+ rootDict[this.languages[idx]][refName].error[key].t = t;
404
+ });
405
+ });
406
+ }
407
+ #registerEtcToRoot(refName, rootDict) {
408
+ Object.entries(this.etcDictionary).forEach(([key, value]) => {
409
+ value.forEach((t, idx) => {
410
+ rootDict[this.languages[idx]][refName][key] ??= {};
411
+ rootDict[this.languages[idx]][refName][key].t = t;
412
+ });
413
+ });
414
+ }
415
+ }
416
+ const scalarDictionary = (languages = ["en"]) => new ScalarDictInfo(languages);
417
+ class ServiceDictInfo {
418
+ languages;
419
+ endpointDictionary = {};
420
+ errorDictionary = {};
421
+ etcDictionary = {};
422
+ constructor(languages) {
423
+ this.languages = languages;
424
+ }
425
+ endpoint(translate) {
426
+ Object.assign(this.endpointDictionary, translate(fn));
427
+ return this;
428
+ }
429
+ error(errorDictionary) {
430
+ Object.assign(this.errorDictionary, errorDictionary);
431
+ return this;
432
+ }
433
+ translate(etcDictionary) {
434
+ Object.assign(this.etcDictionary, etcDictionary);
435
+ return this;
436
+ }
437
+ _toTranslation() {
438
+ return Object.assign({}, this.errorDictionary, this.etcDictionary);
439
+ }
440
+ _registerToRoot(refName, rootDict) {
441
+ this.languages.forEach((language) => {
442
+ rootDict[language] ??= {};
443
+ rootDict[language][refName] ??= {};
444
+ });
445
+ this.#registerEndpointToRoot(refName, rootDict);
446
+ this.#registerErrorToRoot(refName, rootDict);
447
+ this.#registerEtcToRoot(refName, rootDict);
448
+ }
449
+ #registerEndpointToRoot(refName, rootDict) {
450
+ this.languages.forEach((language) => rootDict[language][refName].api ??= {});
451
+ Object.entries(this.endpointDictionary).forEach(
452
+ ([key, value]) => {
453
+ value.trans.forEach((t, idx) => rootDict[this.languages[idx]][refName].api[key] = { t, arg: {} });
454
+ value.descTrans?.forEach((t, idx) => rootDict[this.languages[idx]][refName].api[key].desc = { t });
455
+ Object.entries(value.argTrans).forEach(
456
+ ([argKey, argTrans]) => {
457
+ argTrans.trans.forEach((t, idx) => rootDict[this.languages[idx]][refName].api[key].arg[argKey] = { t });
458
+ argTrans.descTrans?.forEach(
459
+ (t, idx) => rootDict[this.languages[idx]][refName].api[key].arg[argKey].desc = { t }
460
+ );
461
+ }
462
+ );
463
+ }
464
+ );
465
+ }
466
+ #registerErrorToRoot(refName, rootDict) {
467
+ this.languages.forEach((language) => rootDict[language][refName].error ??= {});
468
+ Object.entries(this.errorDictionary).forEach(([key, value]) => {
469
+ value.forEach((t, idx) => {
470
+ rootDict[this.languages[idx]][refName].error[key] ??= {};
471
+ rootDict[this.languages[idx]][refName].error[key].t = t;
472
+ });
473
+ });
474
+ }
475
+ #registerEtcToRoot(refName, rootDict) {
476
+ Object.entries(this.etcDictionary).forEach(([key, value]) => {
477
+ value.forEach((t, idx) => {
478
+ rootDict[this.languages[idx]][refName][key] ??= {};
479
+ rootDict[this.languages[idx]][refName][key].t = t;
480
+ });
481
+ });
482
+ }
483
+ }
484
+ const serviceDictionary = (languages = ["en"]) => new ServiceDictInfo(languages);
@@ -18,6 +18,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
18
18
  var dictionary_exports = {};
19
19
  __export(dictionary_exports, {
20
20
  Revert: () => Revert,
21
+ __Dict_Key__: () => __Dict_Key__,
22
+ __Error_Key__: () => __Error_Key__,
21
23
  dictionary: () => dictionary,
22
24
  getAllDictionary: () => getAllDictionary,
23
25
  getDictionary: () => getDictionary,
@@ -26,8 +28,7 @@ __export(dictionary_exports, {
26
28
  });
27
29
  module.exports = __toCommonJS(dictionary_exports);
28
30
  var import_base = require("./base.dictionary");
31
+ var import_locale = require("./locale");
29
32
  var import_trans = require("./trans");
30
- const dictionary = {
31
- base: import_base.baseDictionary
32
- };
33
- const { Revert, translate, msg, getDictionary, getAllDictionary } = (0, import_trans.makeTrans)(dictionary);
33
+ const dictionary = { base: (0, import_locale.registerServiceTrans)(import_base.baseDictionary) };
34
+ const { Revert, translate, msg, getDictionary, getAllDictionary, __Dict_Key__, __Error_Key__ } = (0, import_trans.makeTrans)(dictionary);
package/cjs/src/index.js CHANGED
@@ -19,6 +19,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  var src_exports = {};
20
20
  __export(src_exports, {
21
21
  Revert: () => import_dictionary.Revert,
22
+ __Dict_Key__: () => import_dictionary.__Dict_Key__,
23
+ __Error_Key__: () => import_dictionary.__Error_Key__,
22
24
  dictionary: () => import_dictionary.dictionary,
23
25
  getAllDictionary: () => import_dictionary.getAllDictionary,
24
26
  getDictionary: () => import_dictionary.getDictionary,
@@ -28,3 +30,5 @@ module.exports = __toCommonJS(src_exports);
28
30
  __reExport(src_exports, require("./trans"), module.exports);
29
31
  var import_dictionary = require("./dictionary");
30
32
  __reExport(src_exports, require("./serverTranslator"), module.exports);
33
+ __reExport(src_exports, require("./dictInfo"), module.exports);
34
+ __reExport(src_exports, require("./locale"), module.exports);
@@ -0,0 +1,33 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var locale_exports = {};
19
+ __export(locale_exports, {
20
+ registerModelTrans: () => registerModelTrans,
21
+ registerScalarTrans: () => registerScalarTrans,
22
+ registerServiceTrans: () => registerServiceTrans
23
+ });
24
+ module.exports = __toCommonJS(locale_exports);
25
+ const registerModelTrans = (modelDict) => {
26
+ return { dict: modelDict };
27
+ };
28
+ const registerScalarTrans = (scalarDict) => {
29
+ return { dict: scalarDict };
30
+ };
31
+ const registerServiceTrans = (serviceDict) => {
32
+ return { dict: serviceDict };
33
+ };
@@ -51,10 +51,7 @@ class ServerTranslator {
51
51
  const trans = {
52
52
  dictionary,
53
53
  translate: (dictKey) => {
54
- const keyParts = dictKey.split(".");
55
- const model = keyParts[0];
56
- const key = keyParts.slice(1).join(".");
57
- return dictionary[model]?.[key] ?? dictKey;
54
+ return (0, import_common.pathGet)(dictKey, dictionary, ".", { t: dictKey }).t;
58
55
  }
59
56
  };
60
57
  ServerTranslator.#langTransMap.set(lang, trans);