@webiny/i18n 0.0.0-mt-2 → 0.0.0-unstable.06b2ede40f
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/I18n.d.ts +7 -40
- package/I18n.js +88 -157
- package/I18n.js.map +1 -0
- package/extractor/extract.d.ts +1 -1
- package/extractor/extract.js +9 -13
- package/extractor/extract.js.map +1 -0
- package/extractor/index.d.ts +6 -3
- package/extractor/index.js +17 -36
- package/extractor/index.js.map +1 -0
- package/index.js +5 -10
- package/index.js.map +1 -0
- package/modifiers/countModifier.d.ts +2 -2
- package/modifiers/countModifier.js +27 -28
- package/modifiers/countModifier.js.map +1 -0
- package/modifiers/dateModifier.d.ts +2 -4
- package/modifiers/dateModifier.js +2 -4
- package/modifiers/dateModifier.js.map +1 -0
- package/modifiers/dateTimeModifier.d.ts +2 -4
- package/modifiers/dateTimeModifier.js +2 -4
- package/modifiers/dateTimeModifier.js.map +1 -0
- package/modifiers/genderModifier.d.ts +2 -2
- package/modifiers/genderModifier.js +10 -8
- package/modifiers/genderModifier.js.map +1 -0
- package/modifiers/ifModifier.d.ts +2 -2
- package/modifiers/ifModifier.js +10 -8
- package/modifiers/ifModifier.js.map +1 -0
- package/modifiers/index.d.ts +2 -1
- package/modifiers/index.js +4 -14
- package/modifiers/index.js.map +1 -0
- package/modifiers/numberModifier.d.ts +2 -4
- package/modifiers/numberModifier.js +2 -4
- package/modifiers/numberModifier.js.map +1 -0
- package/modifiers/pluralModifier.d.ts +2 -2
- package/modifiers/pluralModifier.js +25 -27
- package/modifiers/pluralModifier.js.map +1 -0
- package/modifiers/priceModifier.d.ts +2 -4
- package/modifiers/priceModifier.js +2 -4
- package/modifiers/priceModifier.js.map +1 -0
- package/modifiers/timeModifier.d.ts +2 -4
- package/modifiers/timeModifier.js +2 -4
- package/modifiers/timeModifier.js.map +1 -0
- package/package.json +13 -18
- package/processors/default.d.ts +1 -1
- package/processors/default.js +11 -27
- package/processors/default.js.map +1 -0
- package/types.d.ts +29 -24
- package/types.js +3 -1
- package/types.js.map +1 -0
|
@@ -4,35 +4,33 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _default = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
7
|
+
var _default = () => {
|
|
8
|
+
return {
|
|
9
|
+
name: "plural",
|
|
10
|
+
execute(value, parameters) {
|
|
11
|
+
// Numbers can be single number or ranges.
|
|
12
|
+
for (let i = 0; i < parameters.length; i = i + 2) {
|
|
13
|
+
const current = parameters[i];
|
|
14
|
+
if (current === "default") {
|
|
15
|
+
return parameters[i + 1];
|
|
16
|
+
}
|
|
17
|
+
const numbers = current.split("-");
|
|
18
|
+
|
|
19
|
+
// If we are dealing with a numbers range, then let's check if we are in it.
|
|
20
|
+
if (numbers.length === 2) {
|
|
21
|
+
if (value >= numbers[0] && value <= numbers[1]) {
|
|
22
|
+
return parameters[i + 1];
|
|
23
|
+
}
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
if (String(value) === numbers[0]) {
|
|
23
27
|
return parameters[i + 1];
|
|
24
28
|
}
|
|
25
|
-
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (String(value) === numbers[0]) {
|
|
30
|
-
return parameters[i + 1];
|
|
31
29
|
}
|
|
30
|
+
return "";
|
|
32
31
|
}
|
|
33
|
-
|
|
34
|
-
return "";
|
|
35
|
-
}
|
|
36
|
-
|
|
32
|
+
};
|
|
37
33
|
};
|
|
38
|
-
exports.default = _default;
|
|
34
|
+
exports.default = _default;
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=pluralModifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_default","name","execute","value","parameters","i","length","current","numbers","split","String","exports","default"],"sources":["pluralModifier.ts"],"sourcesContent":["import type { Modifier } from \"~/types\";\n\nexport default (): Modifier => {\n return {\n name: \"plural\",\n execute(value: string, parameters: Array<string>) {\n // Numbers can be single number or ranges.\n for (let i = 0; i < parameters.length; i = i + 2) {\n const current = parameters[i];\n if (current === \"default\") {\n return parameters[i + 1];\n }\n\n const numbers = current.split(\"-\");\n\n // If we are dealing with a numbers range, then let's check if we are in it.\n if (numbers.length === 2) {\n if (value >= numbers[0] && value <= numbers[1]) {\n return parameters[i + 1];\n }\n continue;\n }\n\n if (String(value) === numbers[0]) {\n return parameters[i + 1];\n }\n }\n\n return \"\";\n }\n };\n};\n"],"mappings":";;;;;;eAEeA,CAAA,KAAgB;EAC3B,OAAO;IACHC,IAAI,EAAE,QAAQ;IACdC,OAAOA,CAACC,KAAa,EAAEC,UAAyB,EAAE;MAC9C;MACA,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGD,UAAU,CAACE,MAAM,EAAED,CAAC,GAAGA,CAAC,GAAG,CAAC,EAAE;QAC9C,MAAME,OAAO,GAAGH,UAAU,CAACC,CAAC,CAAC;QAC7B,IAAIE,OAAO,KAAK,SAAS,EAAE;UACvB,OAAOH,UAAU,CAACC,CAAC,GAAG,CAAC,CAAC;QAC5B;QAEA,MAAMG,OAAO,GAAGD,OAAO,CAACE,KAAK,CAAC,GAAG,CAAC;;QAElC;QACA,IAAID,OAAO,CAACF,MAAM,KAAK,CAAC,EAAE;UACtB,IAAIH,KAAK,IAAIK,OAAO,CAAC,CAAC,CAAC,IAAIL,KAAK,IAAIK,OAAO,CAAC,CAAC,CAAC,EAAE;YAC5C,OAAOJ,UAAU,CAACC,CAAC,GAAG,CAAC,CAAC;UAC5B;UACA;QACJ;QAEA,IAAIK,MAAM,CAACP,KAAK,CAAC,KAAKK,OAAO,CAAC,CAAC,CAAC,EAAE;UAC9B,OAAOJ,UAAU,CAACC,CAAC,GAAG,CAAC,CAAC;QAC5B;MACJ;MAEA,OAAO,EAAE;IACb;EACJ,CAAC;AACL,CAAC;AAAAM,OAAA,CAAAC,OAAA,GAAAZ,QAAA","ignoreList":[]}
|
|
@@ -4,16 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _default = ({
|
|
9
8
|
i18n
|
|
10
9
|
}) => ({
|
|
11
10
|
name: "price",
|
|
12
|
-
|
|
13
11
|
execute(value) {
|
|
14
12
|
return i18n.price(value);
|
|
15
13
|
}
|
|
16
|
-
|
|
17
14
|
});
|
|
15
|
+
exports.default = _default;
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
//# sourceMappingURL=priceModifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_default","i18n","name","execute","value","price","exports","default"],"sources":["priceModifier.ts"],"sourcesContent":["import type { Modifier, ModifierOptions } from \"~/types\";\n\nexport default ({ i18n }: ModifierOptions): Modifier => ({\n name: \"price\",\n execute(value: string) {\n return i18n.price(value);\n }\n});\n"],"mappings":";;;;;;eAEeA,CAAC;EAAEC;AAAsB,CAAC,MAAgB;EACrDC,IAAI,EAAE,OAAO;EACbC,OAAOA,CAACC,KAAa,EAAE;IACnB,OAAOH,IAAI,CAACI,KAAK,CAACD,KAAK,CAAC;EAC5B;AACJ,CAAC,CAAC;AAAAE,OAAA,CAAAC,OAAA,GAAAP,QAAA","ignoreList":[]}
|
|
@@ -4,16 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _default = ({
|
|
9
8
|
i18n
|
|
10
9
|
}) => ({
|
|
11
10
|
name: "time",
|
|
12
|
-
|
|
13
11
|
execute(value) {
|
|
14
12
|
return i18n.time(value);
|
|
15
13
|
}
|
|
16
|
-
|
|
17
14
|
});
|
|
15
|
+
exports.default = _default;
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
//# sourceMappingURL=timeModifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_default","i18n","name","execute","value","time","exports","default"],"sources":["timeModifier.ts"],"sourcesContent":["import type { Modifier, ModifierOptions } from \"~/types\";\n\nexport default ({ i18n }: ModifierOptions): Modifier => ({\n name: \"time\",\n execute(value: string) {\n return i18n.time(value);\n }\n});\n"],"mappings":";;;;;;eAEeA,CAAC;EAAEC;AAAsB,CAAC,MAAgB;EACrDC,IAAI,EAAE,MAAM;EACZC,OAAOA,CAACC,KAAa,EAAE;IACnB,OAAOH,IAAI,CAACI,IAAI,CAACD,KAAK,CAAC;EAC3B;AACJ,CAAC,CAAC;AAAAE,OAAA,CAAAC,OAAA,GAAAP,QAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/i18n",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-unstable.06b2ede40f",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -13,36 +13,31 @@
|
|
|
13
13
|
],
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@babel/runtime": "7.15.4",
|
|
17
16
|
"accounting": "0.4.1",
|
|
18
17
|
"fecha": "2.3.3",
|
|
19
18
|
"lodash": "4.17.21",
|
|
20
19
|
"short-hash": "1.0.0",
|
|
21
|
-
"yargs": "
|
|
20
|
+
"yargs": "17.7.2"
|
|
22
21
|
},
|
|
23
22
|
"peerDependencies": {
|
|
24
|
-
"react": "
|
|
23
|
+
"react": "18.2.0"
|
|
25
24
|
},
|
|
26
25
|
"devDependencies": {
|
|
27
|
-
"@babel/
|
|
28
|
-
"@
|
|
29
|
-
"@
|
|
30
|
-
"@
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"babel-plugin-lodash": "^3.3.4",
|
|
35
|
-
"glob": "^7.1.2",
|
|
36
|
-
"rimraf": "^3.0.2",
|
|
37
|
-
"typescript": "^4.1.3"
|
|
26
|
+
"@babel/register": "7.25.9",
|
|
27
|
+
"@types/accounting": "0.4.2",
|
|
28
|
+
"@types/lodash": "4.17.13",
|
|
29
|
+
"@webiny/project-utils": "0.0.0-unstable.06b2ede40f",
|
|
30
|
+
"glob": "7.2.3",
|
|
31
|
+
"rimraf": "6.0.1",
|
|
32
|
+
"typescript": "5.3.3"
|
|
38
33
|
},
|
|
39
34
|
"publishConfig": {
|
|
40
35
|
"access": "public",
|
|
41
36
|
"directory": "dist"
|
|
42
37
|
},
|
|
43
38
|
"scripts": {
|
|
44
|
-
"build": "
|
|
45
|
-
"watch": "
|
|
39
|
+
"build": "node ../cli/bin.js run build",
|
|
40
|
+
"watch": "node ../cli/bin.js run watch"
|
|
46
41
|
},
|
|
47
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "06b2ede40fc2212a70eeafd74afd50b56fb0ce82"
|
|
48
43
|
}
|
package/processors/default.d.ts
CHANGED
package/processors/default.js
CHANGED
|
@@ -1,69 +1,53 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
|
-
var _has2 = _interopRequireDefault(require("lodash/has"));
|
|
11
|
-
|
|
12
|
-
var _trim2 = _interopRequireDefault(require("lodash/trim"));
|
|
13
|
-
|
|
14
|
-
var _startsWith2 = _interopRequireDefault(require("lodash/startsWith"));
|
|
15
|
-
|
|
8
|
+
var _trim = _interopRequireDefault(require("lodash/trim"));
|
|
16
9
|
const processTextPart = (part, values, modifiers) => {
|
|
17
|
-
if (
|
|
10
|
+
if (part.startsWith("{") === false) {
|
|
18
11
|
return part;
|
|
19
12
|
}
|
|
20
|
-
|
|
21
|
-
const parts = (0, _trim2.default)(part, "{}").split("|");
|
|
13
|
+
const parts = (0, _trim.default)(part, "{}").split("|");
|
|
22
14
|
const [variable, modifier] = parts;
|
|
23
|
-
|
|
24
|
-
if (!(0, _has2.default)(values, variable)) {
|
|
15
|
+
if (!values[variable]) {
|
|
25
16
|
return `{${variable}}`;
|
|
26
17
|
}
|
|
27
|
-
|
|
28
18
|
const output = {
|
|
29
19
|
value: values[variable]
|
|
30
20
|
};
|
|
31
|
-
|
|
32
21
|
if (modifier) {
|
|
33
22
|
const parameters = modifier.split(":");
|
|
34
23
|
const name = parameters.shift();
|
|
35
|
-
|
|
24
|
+
if (!name) {
|
|
25
|
+
return output.value;
|
|
26
|
+
}
|
|
36
27
|
if (modifiers[name]) {
|
|
37
28
|
const modifier = modifiers[name];
|
|
38
29
|
output.value = modifier.execute(output.value, parameters);
|
|
39
30
|
}
|
|
40
31
|
}
|
|
41
|
-
|
|
42
32
|
return output.value;
|
|
43
33
|
};
|
|
44
|
-
|
|
45
34
|
const processor = {
|
|
46
35
|
name: "default",
|
|
47
|
-
|
|
48
36
|
canExecute(data) {
|
|
49
37
|
for (const key in data.values) {
|
|
50
38
|
const value = data.values[key];
|
|
51
|
-
|
|
52
39
|
if (typeof value === "string" || typeof value === "number" || value === null || value instanceof Date) {
|
|
53
40
|
continue;
|
|
54
41
|
}
|
|
55
|
-
|
|
56
42
|
return false;
|
|
57
43
|
}
|
|
58
|
-
|
|
59
44
|
return true;
|
|
60
45
|
},
|
|
61
|
-
|
|
62
46
|
execute(data) {
|
|
63
47
|
const parts = data.translation.split(/({.*?})/);
|
|
64
48
|
return parts.reduce((carry, part) => carry + processTextPart(part, data.values, data.i18n.modifiers), "");
|
|
65
49
|
}
|
|
66
|
-
|
|
67
50
|
};
|
|
68
|
-
var _default = processor;
|
|
69
|
-
|
|
51
|
+
var _default = exports.default = processor;
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=default.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_trim","_interopRequireDefault","require","processTextPart","part","values","modifiers","startsWith","parts","lodashTrim","split","variable","modifier","output","value","parameters","name","shift","execute","processor","canExecute","data","key","Date","translation","reduce","carry","i18n","_default","exports","default"],"sources":["default.ts"],"sourcesContent":["import lodashTrim from \"lodash/trim\";\nimport type { Modifier, Processor } from \"~/types\";\n\nconst processTextPart = (\n part: string,\n values: Record<string, any>,\n modifiers: Record<string, Modifier>\n): string => {\n if (part.startsWith(\"{\") === false) {\n return part;\n }\n\n const parts = lodashTrim(part, \"{}\").split(\"|\");\n\n const [variable, modifier] = parts;\n\n if (!values[variable]) {\n return `{${variable}}`;\n }\n\n const output = {\n value: values[variable]\n };\n\n if (modifier) {\n const parameters: string[] = modifier.split(\":\");\n const name = parameters.shift();\n if (!name) {\n return output.value;\n }\n if (modifiers[name]) {\n const modifier = modifiers[name];\n output.value = modifier.execute(output.value, parameters);\n }\n }\n\n return output.value;\n};\n\nconst processor: Processor = {\n name: \"default\",\n canExecute(data) {\n for (const key in data.values) {\n const value = data.values[key];\n if (\n typeof value === \"string\" ||\n typeof value === \"number\" ||\n value === null ||\n value instanceof Date\n ) {\n continue;\n }\n return false;\n }\n\n return true;\n },\n execute(data) {\n const parts = data.translation.split(/({.*?})/);\n return parts.reduce(\n (carry, part) => carry + processTextPart(part, data.values, data.i18n.modifiers),\n \"\"\n );\n }\n};\n\nexport default processor;\n"],"mappings":";;;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,MAAMC,eAAe,GAAGA,CACpBC,IAAY,EACZC,MAA2B,EAC3BC,SAAmC,KAC1B;EACT,IAAIF,IAAI,CAACG,UAAU,CAAC,GAAG,CAAC,KAAK,KAAK,EAAE;IAChC,OAAOH,IAAI;EACf;EAEA,MAAMI,KAAK,GAAG,IAAAC,aAAU,EAACL,IAAI,EAAE,IAAI,CAAC,CAACM,KAAK,CAAC,GAAG,CAAC;EAE/C,MAAM,CAACC,QAAQ,EAAEC,QAAQ,CAAC,GAAGJ,KAAK;EAElC,IAAI,CAACH,MAAM,CAACM,QAAQ,CAAC,EAAE;IACnB,OAAO,IAAIA,QAAQ,GAAG;EAC1B;EAEA,MAAME,MAAM,GAAG;IACXC,KAAK,EAAET,MAAM,CAACM,QAAQ;EAC1B,CAAC;EAED,IAAIC,QAAQ,EAAE;IACV,MAAMG,UAAoB,GAAGH,QAAQ,CAACF,KAAK,CAAC,GAAG,CAAC;IAChD,MAAMM,IAAI,GAAGD,UAAU,CAACE,KAAK,CAAC,CAAC;IAC/B,IAAI,CAACD,IAAI,EAAE;MACP,OAAOH,MAAM,CAACC,KAAK;IACvB;IACA,IAAIR,SAAS,CAACU,IAAI,CAAC,EAAE;MACjB,MAAMJ,QAAQ,GAAGN,SAAS,CAACU,IAAI,CAAC;MAChCH,MAAM,CAACC,KAAK,GAAGF,QAAQ,CAACM,OAAO,CAACL,MAAM,CAACC,KAAK,EAAEC,UAAU,CAAC;IAC7D;EACJ;EAEA,OAAOF,MAAM,CAACC,KAAK;AACvB,CAAC;AAED,MAAMK,SAAoB,GAAG;EACzBH,IAAI,EAAE,SAAS;EACfI,UAAUA,CAACC,IAAI,EAAE;IACb,KAAK,MAAMC,GAAG,IAAID,IAAI,CAAChB,MAAM,EAAE;MAC3B,MAAMS,KAAK,GAAGO,IAAI,CAAChB,MAAM,CAACiB,GAAG,CAAC;MAC9B,IACI,OAAOR,KAAK,KAAK,QAAQ,IACzB,OAAOA,KAAK,KAAK,QAAQ,IACzBA,KAAK,KAAK,IAAI,IACdA,KAAK,YAAYS,IAAI,EACvB;QACE;MACJ;MACA,OAAO,KAAK;IAChB;IAEA,OAAO,IAAI;EACf,CAAC;EACDL,OAAOA,CAACG,IAAI,EAAE;IACV,MAAMb,KAAK,GAAGa,IAAI,CAACG,WAAW,CAACd,KAAK,CAAC,SAAS,CAAC;IAC/C,OAAOF,KAAK,CAACiB,MAAM,CACf,CAACC,KAAK,EAAEtB,IAAI,KAAKsB,KAAK,GAAGvB,eAAe,CAACC,IAAI,EAAEiB,IAAI,CAAChB,MAAM,EAAEgB,IAAI,CAACM,IAAI,CAACrB,SAAS,CAAC,EAChF,EACJ,CAAC;EACL;AACJ,CAAC;AAAC,IAAAsB,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaX,SAAS","ignoreList":[]}
|
package/types.d.ts
CHANGED
|
@@ -1,51 +1,56 @@
|
|
|
1
|
-
import I18N from "./I18n";
|
|
2
|
-
import { ReactElement } from "react";
|
|
3
|
-
export
|
|
1
|
+
import type I18N from "./I18n";
|
|
2
|
+
import type { ReactElement } from "react";
|
|
3
|
+
export interface I18NDataValues {
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
}
|
|
6
|
+
export interface I18NData {
|
|
4
7
|
translation: string;
|
|
5
8
|
base: string;
|
|
6
9
|
namespace: string;
|
|
7
|
-
values:
|
|
8
|
-
[key: string]: any;
|
|
9
|
-
};
|
|
10
|
+
values: I18NDataValues;
|
|
10
11
|
i18n: I18N;
|
|
11
|
-
}
|
|
12
|
+
}
|
|
13
|
+
export interface ModifierOptions {
|
|
14
|
+
i18n: I18N;
|
|
15
|
+
}
|
|
12
16
|
/**
|
|
13
|
-
* @name Modifier
|
|
14
17
|
* @description I18N Modifier - used for modifying text dynamically.
|
|
15
18
|
*/
|
|
16
|
-
export
|
|
19
|
+
export interface Modifier {
|
|
17
20
|
name: string;
|
|
18
21
|
execute: (...args: any[]) => string;
|
|
19
|
-
}
|
|
22
|
+
}
|
|
23
|
+
export type ProcessorResult = string | ReactElement;
|
|
20
24
|
/**
|
|
21
|
-
* @name Processor
|
|
22
25
|
* @description I18N Processor - used for outputting text.
|
|
23
26
|
*/
|
|
24
|
-
export
|
|
27
|
+
export interface Processor {
|
|
25
28
|
name: string;
|
|
26
|
-
canExecute
|
|
27
|
-
execute: (data: I18NData) =>
|
|
28
|
-
}
|
|
29
|
-
export
|
|
29
|
+
canExecute: (data: I18NData) => boolean;
|
|
30
|
+
execute: (data: I18NData) => ProcessorResult;
|
|
31
|
+
}
|
|
32
|
+
export interface NumberFormat {
|
|
30
33
|
decimal: string;
|
|
31
34
|
thousand: string;
|
|
32
35
|
precision: number;
|
|
33
|
-
}
|
|
34
|
-
export
|
|
36
|
+
}
|
|
37
|
+
export interface PriceFormat {
|
|
35
38
|
symbol: string;
|
|
36
39
|
format: string;
|
|
37
40
|
decimal: string;
|
|
38
41
|
thousand: string;
|
|
39
42
|
precision: number;
|
|
40
|
-
}
|
|
41
|
-
export
|
|
43
|
+
}
|
|
44
|
+
export interface Formats {
|
|
42
45
|
date: string;
|
|
43
46
|
time: string;
|
|
44
47
|
datetime: string;
|
|
45
48
|
price: PriceFormat;
|
|
46
49
|
number: NumberFormat;
|
|
47
|
-
}
|
|
48
|
-
export
|
|
49
|
-
|
|
50
|
+
}
|
|
51
|
+
export interface Translator {
|
|
52
|
+
(base: any): any;
|
|
53
|
+
}
|
|
54
|
+
export interface Translations {
|
|
50
55
|
[key: string]: string;
|
|
51
|
-
}
|
|
56
|
+
}
|
package/types.js
CHANGED
package/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type I18N from \"./I18n\";\nimport type { ReactElement } from \"react\";\n\nexport interface I18NDataValues {\n [key: string]: any;\n}\nexport interface I18NData {\n translation: string;\n base: string;\n namespace: string;\n values: I18NDataValues;\n i18n: I18N;\n}\n\nexport interface ModifierOptions {\n i18n: I18N;\n}\n/**\n * @description I18N Modifier - used for modifying text dynamically.\n */\nexport interface Modifier {\n name: string;\n execute: (...args: any[]) => string;\n}\n\nexport type ProcessorResult = string | ReactElement;\n/**\n * @description I18N Processor - used for outputting text.\n */\nexport interface Processor {\n name: string;\n canExecute: (data: I18NData) => boolean;\n execute: (data: I18NData) => ProcessorResult;\n}\n\nexport interface NumberFormat {\n decimal: string;\n thousand: string;\n precision: number;\n}\n\nexport interface PriceFormat {\n symbol: string;\n format: string;\n decimal: string;\n thousand: string;\n precision: number;\n}\n\nexport interface Formats {\n date: string;\n time: string;\n datetime: string;\n price: PriceFormat;\n number: NumberFormat;\n}\n\nexport interface Translator {\n (base: any): any;\n}\n\nexport interface Translations {\n [key: string]: string;\n}\n"],"mappings":"","ignoreList":[]}
|