@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/trans.js CHANGED
@@ -17,98 +17,14 @@ var __copyProps = (to, from, except, desc) => {
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
18
  var trans_exports = {};
19
19
  __export(trans_exports, {
20
- baseTrans: () => baseTrans,
21
- getBaseSignalTrans: () => getBaseSignalTrans,
22
20
  makeDictionary: () => makeDictionary,
23
21
  makeTrans: () => makeTrans,
24
- msg: () => msg,
25
- rootDictionary: () => rootDictionary
22
+ msg: () => msg
26
23
  });
27
24
  module.exports = __toCommonJS(trans_exports);
28
25
  var import_common = require("@akanjs/common");
29
- const baseTrans = {
30
- id: ["Id", "\uC544\uC774\uB514"],
31
- "desc-id": ["Unique ID value", "\uC720\uB2C8\uD06C\uD55C \uC544\uC774\uB514\uAC12"],
32
- createdAt: ["CreatedAt", "\uC0DD\uC131\uC77C"],
33
- "desc-createdAt": ["Data created time", "\uB370\uC774\uD130 \uC0DD\uC131 \uC2DC\uAC01"],
34
- updatedAt: ["UpdatedAt", "\uC218\uC815\uC77C"],
35
- "desc-updatedAt": ["Data updated time", "\uB370\uC774\uD130 \uB9C8\uC9C0\uB9C9 \uC218\uC815 \uC2DC\uAC01"],
36
- removedAt: ["RemovedAt", "\uC0AD\uC81C\uC77C"],
37
- "desc-removedAt": ["Data removed time", "\uB370\uC774\uD130 \uC0AD\uC81C \uC2DC\uAC01"],
38
- status: ["Status", "\uC0C1\uD0DC"],
39
- "desc-status": ["Data status", "\uB370\uC774\uD130 \uC0C1\uD0DC"],
40
- count: ["Count", "\uAC1C\uC218"],
41
- "desc-count": ["Data count", "\uB370\uC774\uD130 \uAC1C\uC218"],
42
- latest: ["latest", "\uCD5C\uC2E0\uC21C"],
43
- "desc-latest": ["latest", "\uCD5C\uC2E0\uC21C"],
44
- oldest: ["oldest", "\uC624\uB798\uB41C\uC21C"],
45
- "desc-oldest": ["oldest", "\uC624\uB798\uB41C\uC21C"],
46
- "qry-any": ["All", "\uC804\uCCB4"],
47
- "qrydesc-any": ["All", "\uC804\uCCB4"],
48
- "qry-byStatuses": ["By Statuses", "\uC0C1\uD0DC\uBCC4 \uC870\uD68C"],
49
- "qrydesc-byStatuses": ["By Statuses", "\uC0C1\uD0DC\uBCC4 \uC870\uD68C"],
50
- "qarg-byStatuses-statuses": ["Statuses", "\uC0C1\uD0DC"],
51
- "qargdesc-byStatuses-statuses": ["Statuses", "\uC0C1\uD0DC"]
52
- };
53
- const getBaseSignalTrans = (modelName) => {
54
- const className = (0, import_common.capitalize)(modelName);
55
- return {
56
- // * ==================== Endpoint ==================== * //
57
- [`api-light${className}`]: [`Get light version of ${modelName}`, `${modelName} \uACBD\uB7C9\uD654 \uBC84\uC804 \uC870\uD68C`],
58
- [`apidesc-light${className}`]: [`Get light version of ${modelName}`, `${modelName} \uACBD\uB7C9\uD654 \uBC84\uC804 \uC870\uD68C`],
59
- [`arg-light${className}-${modelName}Id`]: [`Id of ${modelName}`, `${modelName} \uC544\uC774\uB514`],
60
- [`argdesc-light${className}-${modelName}Id`]: [`Id of ${modelName}`, `${modelName} \uC544\uC774\uB514`],
61
- [`api-${modelName}`]: [`Get ${modelName}`, `${modelName} \uC870\uD68C`],
62
- [`apidesc-${modelName}`]: [`Get ${modelName}`, `${modelName} \uC870\uD68C`],
63
- [`arg-${modelName}-${modelName}Id`]: [`Id of ${modelName}`, `${modelName} \uC544\uC774\uB514`],
64
- [`argdesc-${modelName}-${modelName}Id`]: [`Id of ${modelName}`, `${modelName} \uC544\uC774\uB514`],
65
- [`api-${modelName}List`]: [`Get ${modelName} list`, `${modelName} \uB9AC\uC2A4\uD2B8 \uC870\uD68C`],
66
- [`apidesc-${modelName}List`]: [`Get ${modelName} list`, `${modelName} \uB9AC\uC2A4\uD2B8 \uC870\uD68C`],
67
- [`arg-${modelName}List-query`]: [`Query of ${modelName}`, `${modelName} \uCFFC\uB9AC`],
68
- [`argdesc-${modelName}List-query`]: [`Query of ${modelName}`, `${modelName} \uCFFC\uB9AC`],
69
- [`arg-${modelName}List-skip`]: [`Skip of ${modelName}`, `${modelName} \uC2A4\uD0B5`],
70
- [`argdesc-${modelName}List-skip`]: [`Skip of ${modelName}`, `${modelName} \uC2A4\uD0B5`],
71
- [`arg-${modelName}List-limit`]: [`Limit of ${modelName}`, `${modelName} \uC81C\uD55C`],
72
- [`argdesc-${modelName}List-limit`]: [`Limit of ${modelName}`, `${modelName} \uC81C\uD55C`],
73
- [`arg-${modelName}List-sort`]: [`Sort of ${modelName}`, `${modelName} \uC815\uB82C`],
74
- [`argdesc-${modelName}List-sort`]: [`Sort of ${modelName}`, `${modelName} \uC815\uB82C`],
75
- [`api-${modelName}Insight`]: [`Get ${modelName} insight`, `${modelName} \uC778\uC0AC\uC774\uD2B8 \uC870\uD68C`],
76
- [`apidesc-${modelName}Insight`]: [`Get ${modelName} insight`, `${modelName} \uC778\uC0AC\uC774\uD2B8 \uC870\uD68C`],
77
- [`arg-${modelName}Insight-query`]: [`Query of ${modelName}`, `${modelName} \uCFFC\uB9AC`],
78
- [`argdesc-${modelName}Insight-query`]: [`Query of ${modelName}`, `${modelName} \uCFFC\uB9AC`],
79
- [`api-${modelName}Exists`]: [`Check ${modelName} exists`, `${modelName} \uC874\uC7AC \uC5EC\uBD80 \uD655\uC778`],
80
- [`apidesc-${modelName}Exists`]: [`Check ${modelName} exists`, `${modelName} \uC874\uC7AC \uC5EC\uBD80 \uD655\uC778`],
81
- [`arg-${modelName}Exists-query`]: [`Query of ${modelName}`, `${modelName} \uCFFC\uB9AC`],
82
- [`argdesc-${modelName}Exists-query`]: [`Query of ${modelName}`, `${modelName} \uCFFC\uB9AC`],
83
- [`api-create${className}`]: [`Create ${modelName}`, `${modelName} \uC0DD\uC131`],
84
- [`apidesc-create${className}`]: [`Create ${modelName}`, `${modelName} \uC0DD\uC131`],
85
- [`arg-create${className}-data`]: [`Data of ${modelName}`, `${modelName} \uB370\uC774\uD130`],
86
- [`argdesc-create${className}-data`]: [`Data of ${modelName}`, `${modelName} \uB370\uC774\uD130`],
87
- [`api-update${className}`]: [`Update ${modelName}`, `${modelName} \uC218\uC815`],
88
- [`apidesc-update${className}`]: [`Update ${modelName}`, `${modelName} \uC218\uC815`],
89
- [`arg-update${className}-${modelName}Id`]: [`Id of ${modelName}`, `${modelName} \uC544\uC774\uB514`],
90
- [`argdesc-update${className}-${modelName}Id`]: [`Id of ${modelName}`, `${modelName} \uC544\uC774\uB514`],
91
- [`arg-update${className}-data`]: [`Data of ${modelName}`, `${modelName} \uB370\uC774\uD130`],
92
- [`argdesc-update${className}-data`]: [`Data of ${modelName}`, `${modelName} \uB370\uC774\uD130`],
93
- [`api-remove${className}`]: [`Remove ${modelName}`, `${modelName} \uC0AD\uC81C`],
94
- [`apidesc-remove${className}`]: [`Remove ${modelName}`, `${modelName} \uC0AD\uC81C`],
95
- [`arg-remove${className}-${modelName}Id`]: [`Id of ${modelName}`, `${modelName} \uC544\uC774\uB514`],
96
- [`argdesc-remove${className}-${modelName}Id`]: [`Id of ${modelName}`, `${modelName} \uC544\uC774\uB514`]
97
- // * ==================== Endpoint ==================== * //
98
- };
99
- };
100
- const rootDictionary = {};
101
26
  const makeDictionary = (...dicts) => {
102
- const [rootDict, ...additionalDicts] = dicts;
103
- additionalDicts.forEach((dict) => {
104
- Object.entries(dict).forEach(([key, value]) => {
105
- if (!rootDict[key])
106
- rootDict[key] = value;
107
- else
108
- rootDict[key] = { ...rootDict[key], ...value };
109
- });
110
- });
111
- return rootDict;
27
+ return Object.assign(...dicts);
112
28
  };
113
29
  const languages = ["en", "ko", "zhChs", "zhCht"];
114
30
  const msg = {
@@ -118,7 +34,11 @@ const msg = {
118
34
  warning: () => null,
119
35
  loading: () => null
120
36
  };
121
- const makeTrans = (locale) => {
37
+ const rootDictionary = {};
38
+ const makeTrans = (transMap, { build = false } = {}) => {
39
+ Object.entries(transMap).forEach(([refName, trans]) => {
40
+ trans.dict._registerToRoot(refName, rootDictionary);
41
+ });
122
42
  const revert = (key, data) => {
123
43
  throw new Error(key);
124
44
  };
@@ -128,26 +48,26 @@ const makeTrans = (locale) => {
128
48
  }
129
49
  }
130
50
  const translate = (lang, key, data) => {
131
- const langIdx = languages.indexOf(lang);
132
51
  const [modelName, msgKey] = key.split(".");
133
- const model = locale[modelName];
134
- const message = model[msgKey][langIdx];
135
- if (!message)
136
- throw new Error("Invalid message");
137
- return message;
52
+ const langDict = rootDictionary[lang] ?? {};
53
+ const model = langDict[modelName] ?? {};
54
+ const message = (0, import_common.pathGet)(msgKey, model, ".", { t: key });
55
+ return message.t;
138
56
  };
139
57
  const getDictionary = (lang) => {
140
- const langIdx = languages.indexOf(lang);
141
- const dictionary = {};
142
- Object.entries(locale).forEach(([key, value]) => {
143
- dictionary[key] = Object.fromEntries(
144
- Object.entries(value).map(([key2, value2]) => [key2, value2[langIdx]])
145
- );
146
- });
147
- return dictionary;
58
+ return rootDictionary[lang];
148
59
  };
149
60
  const getAllDictionary = () => {
150
- return Object.fromEntries(languages.map((lang) => [lang, getDictionary(lang)]));
61
+ return rootDictionary;
62
+ };
63
+ return {
64
+ revert,
65
+ Revert,
66
+ translate,
67
+ msg,
68
+ getDictionary,
69
+ getAllDictionary,
70
+ __Dict_Key__: null,
71
+ __Error_Key__: null
151
72
  };
152
- return { revert, Revert, translate, msg, getDictionary, getAllDictionary };
153
73
  };
@@ -1,46 +1,30 @@
1
- const baseDictionary = {
2
- // * ==================== Endpoint ==================== * //
3
- "api-publishPing": ["Publish Ping", "Publish Ping"],
4
- "apidesc-publishPing": ["Publish Ping", "Publish Ping"],
5
- "api-ping": ["Ping", "Ping"],
6
- "apidesc-ping": ["Ping", "Ping"],
7
- "api-pingBody": ["Ping Body", "Ping Body"],
8
- "apidesc-pingBody": ["Ping Body", "Ping Body"],
9
- "arg-pingBody-data": ["Body data", "\uBC14\uB514 \uB370\uC774\uD130"],
10
- "argdesc-pingBody-data": ["Body data", "\uBC14\uB514 \uB370\uC774\uD130"],
11
- "api-pingParam": ["Ping Param", "Ping Param"],
12
- "apidesc-pingParam": ["Ping Param", "Ping Param"],
13
- "arg-pingParam-id": ["ID", "\uC544\uC774\uB514"],
14
- "argdesc-pingParam-id": ["ID", "\uC544\uC774\uB514"],
15
- "api-pingQuery": ["Ping Query", "Ping Query"],
16
- "apidesc-pingQuery": ["Ping Query", "Ping Query"],
17
- "arg-pingQuery-id": ["ID", "\uC544\uC774\uB514"],
18
- "argdesc-pingQuery-id": ["ID", "\uC544\uC774\uB514"],
19
- "api-pingEvery": ["Ping Every", "Ping Every"],
20
- "apidesc-pingEvery": ["Ping Every", "Ping Every"],
21
- "api-pingUser": ["Ping User", "Ping User"],
22
- "apidesc-pingUser": ["Ping User", "Ping User"],
23
- "api-pingAdmin": ["Ping Admin", "Ping Admin"],
24
- "apidesc-pingAdmin": ["Ping Admin", "Ping Admin"],
25
- "api-cleanup": ["Cleanup", "Cleanup"],
26
- "apidesc-cleanup": ["Cleanup", "Cleanup"],
27
- "api-wsPing": ["Socket.io Ping", "Socket.io Ping"],
28
- "apidesc-wsPing": ["Socket.io Ping", "Socket.io Ping"],
29
- "arg-wsPing-data": ["Data", "\uB370\uC774\uD130"],
30
- "argdesc-wsPing-data": ["Data", "\uB370\uC774\uD130"],
31
- "api-pubsubPing": ["Pubsub Ping", "Pubsub Ping"],
32
- "apidesc-pubsubPing": ["Pubsub Ping", "Pubsub Ping"],
33
- "api-getDictionary": ["Get Dictionary", "Get Dictionary"],
34
- "apidesc-getDictionary": ["Get Dictionary", "Get Dictionary"],
35
- "arg-getDictionary-lang": ["Language", "\uC5B8\uC5B4"],
36
- "argdesc-getDictionary-lang": ["Language", "\uC5B8\uC5B4"],
37
- "api-getAllDictionary": ["Get All Dictionary", "Get All Dictionary"],
38
- "apidesc-getAllDictionary": ["Get All Dictionary", "Get All Dictionary"],
39
- "api-getSignals": ["Get Signals", "Get Signals"],
40
- "apidesc-getSignals": ["Get Signals", "Get Signals"],
41
- // * ==================== Endpoint ==================== * //
42
- // * ==================== Etc ==================== * //
43
- // new: ["New", "신규"],
1
+ import { serviceDictionary } from "./dictInfo";
2
+ const baseDictionary = serviceDictionary(["en", "ko"]).endpoint((fn) => ({
3
+ publishPing: fn(["Publish Ping", "Publish Ping"]),
4
+ ping: fn(["Ping", "Ping"]),
5
+ pingBody: fn(["Ping Body", "Ping Body"]).arg((t) => ({
6
+ data: t(["Body data", "\uBC14\uB514 \uB370\uC774\uD130"])
7
+ })),
8
+ pingParam: fn(["Ping Param", "Ping Param"]).arg((t) => ({
9
+ id: t(["ID", "\uC544\uC774\uB514"])
10
+ })),
11
+ pingQuery: fn(["Ping Query", "Ping Query"]).arg((t) => ({
12
+ id: t(["ID", "\uC544\uC774\uB514"])
13
+ })),
14
+ pingEvery: fn(["Ping Every", "Ping Every"]),
15
+ pingUser: fn(["Ping User", "Ping User"]),
16
+ pingAdmin: fn(["Ping Admin", "Ping Admin"]),
17
+ getDictionary: fn(["Get Dictionary", "Get Dictionary"]).arg((t) => ({
18
+ lang: t(["Language", "\uC5B8\uC5B4"])
19
+ })),
20
+ getAllDictionary: fn(["Get All Dictionary", "Get All Dictionary"]),
21
+ cleanup: fn(["Cleanup", "Cleanup"]),
22
+ wsPing: fn(["Socket.io Ping", "Socket.io Ping"]).arg((t) => ({
23
+ data: t(["Data", "\uB370\uC774\uD130"])
24
+ })),
25
+ pubsubPing: fn(["Pubsub Ping", "Pubsub Ping"]),
26
+ getSignals: fn(["Get Signals", "Get Signals"])
27
+ })).translate({
44
28
  somethingWrong: ["Something's wrong!", "\uBB38\uC81C\uAC00 \uC0DD\uACBC\uC5B4\uC694!"],
45
29
  connecting: ["Connecting...", "\uC5F0\uACB0 \uC911..."],
46
30
  connected: ["Connected!", "\uC5F0\uACB0\uB418\uC5C8\uC2B5\uB2C8\uB2E4!"],
@@ -100,8 +84,7 @@ const baseDictionary = {
100
84
  save: ["Save", "\uC800\uC7A5"],
101
85
  remove: ["Remove", "\uC0AD\uC81C"],
102
86
  view: ["View", "\uBCF4\uAE30"]
103
- // * ==================== Etc ==================== * //
104
- };
87
+ });
105
88
  export {
106
89
  baseDictionary
107
90
  };