@webiny/i18n 5.23.1-beta.0 → 5.24.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/I18n.d.ts +1 -1
- package/I18n.js +10 -1
- package/extractor/extract.d.ts +1 -1
- package/extractor/extract.js +5 -0
- package/extractor/index.d.ts +1 -1
- package/modifiers/countModifier.d.ts +1 -1
- package/modifiers/countModifier.js +25 -21
- package/modifiers/dateModifier.d.ts +2 -4
- package/modifiers/dateTimeModifier.d.ts +2 -4
- package/modifiers/genderModifier.d.ts +1 -1
- package/modifiers/genderModifier.js +9 -5
- package/modifiers/ifModifier.d.ts +1 -1
- package/modifiers/ifModifier.js +9 -5
- package/modifiers/index.d.ts +2 -1
- package/modifiers/index.js +1 -1
- package/modifiers/numberModifier.d.ts +2 -4
- package/modifiers/pluralModifier.d.ts +1 -1
- package/modifiers/pluralModifier.js +24 -20
- package/modifiers/priceModifier.d.ts +2 -4
- package/modifiers/timeModifier.d.ts +2 -4
- package/package.json +6 -4
- package/types.d.ts +3 -0
package/I18n.d.ts
CHANGED
|
@@ -89,7 +89,7 @@ export default class I18N {
|
|
|
89
89
|
* Merges given translations object with already existing.
|
|
90
90
|
* @returns {*|{}}
|
|
91
91
|
*/
|
|
92
|
-
mergeTranslations(translations: Translations):
|
|
92
|
+
mergeTranslations(translations: Translations): Translations;
|
|
93
93
|
/**
|
|
94
94
|
* Returns currently selected locale (locale's key).
|
|
95
95
|
*/
|
package/I18n.js
CHANGED
|
@@ -23,6 +23,11 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
23
23
|
|
|
24
24
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Package short-hash has no types.
|
|
28
|
+
*/
|
|
29
|
+
// @ts-ignore
|
|
30
|
+
|
|
26
31
|
/**
|
|
27
32
|
* Main class used for all I18n needs.
|
|
28
33
|
*/
|
|
@@ -225,7 +230,11 @@ class I18N {
|
|
|
225
230
|
outputFormat = (0, _assign2.default)({}, this.defaultFormats.number, outputFormat);
|
|
226
231
|
}
|
|
227
232
|
|
|
228
|
-
return _accounting.default.formatNumber(
|
|
233
|
+
return _accounting.default.formatNumber(
|
|
234
|
+
/**
|
|
235
|
+
* Cast as number because method transforms it internally.
|
|
236
|
+
*/
|
|
237
|
+
value, outputFormat.precision, outputFormat.thousand, outputFormat.decimal);
|
|
229
238
|
}
|
|
230
239
|
/**
|
|
231
240
|
* Returns translation for given text key.
|
package/extractor/extract.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: (source: string) =>
|
|
1
|
+
declare const _default: (source: string) => Record<string, string>;
|
|
2
2
|
export default _default;
|
package/extractor/extract.js
CHANGED
|
@@ -9,6 +9,11 @@ exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _shortHash = _interopRequireDefault(require("short-hash"));
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Package short-hash has no types.
|
|
14
|
+
*/
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
|
|
12
17
|
/**
|
|
13
18
|
* Searches for all declared namespaces.
|
|
14
19
|
* Result contains an object with identifiers as keys, and namespaces they represent as values, for example:
|
package/extractor/index.d.ts
CHANGED
|
@@ -4,36 +4,40 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _default = {
|
|
8
|
-
name: "count",
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const current = parameters[i];
|
|
8
|
+
var _default = () => {
|
|
9
|
+
return {
|
|
10
|
+
name: "count",
|
|
14
11
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
execute(value, parameters) {
|
|
13
|
+
// Numbers can be single number or ranges.
|
|
14
|
+
for (let i = 0; i < parameters.length; i = i + 2) {
|
|
15
|
+
const current = parameters[i];
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (numbers.length === 2) {
|
|
22
|
-
if (value >= numbers[0] && value <= numbers[1]) {
|
|
17
|
+
if (current === "default") {
|
|
23
18
|
return value + " " + parameters[i + 1];
|
|
24
19
|
}
|
|
25
20
|
|
|
26
|
-
|
|
27
|
-
}
|
|
21
|
+
const numbers = current.split("-"); // If we are dealing with a numbers range, then let's check if we are in it.
|
|
28
22
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
if (numbers.length === 2) {
|
|
24
|
+
if (value >= numbers[0] && value <= numbers[1]) {
|
|
25
|
+
return value + " " + parameters[i + 1];
|
|
26
|
+
}
|
|
33
27
|
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
34
30
|
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
if (String(value) === numbers[0]) {
|
|
32
|
+
return value + " " + parameters[i + 1];
|
|
33
|
+
}
|
|
34
|
+
} // If we didn't match any condition, let's just remove the received value.
|
|
37
35
|
|
|
36
|
+
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
};
|
|
38
41
|
};
|
|
42
|
+
|
|
39
43
|
exports.default = _default;
|
|
@@ -4,12 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _default = {
|
|
8
|
-
name: "gender",
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
var _default = () => {
|
|
9
|
+
return {
|
|
10
|
+
name: "gender",
|
|
13
11
|
|
|
12
|
+
execute(value, parameters) {
|
|
13
|
+
return value === "male" ? parameters[0] : parameters[1];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
};
|
|
14
17
|
};
|
|
18
|
+
|
|
15
19
|
exports.default = _default;
|
package/modifiers/ifModifier.js
CHANGED
|
@@ -4,12 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _default = {
|
|
8
|
-
name: "if",
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
var _default = () => {
|
|
9
|
+
return {
|
|
10
|
+
name: "if",
|
|
13
11
|
|
|
12
|
+
execute(value, parameters) {
|
|
13
|
+
return value === parameters[0] ? parameters[1] : parameters[2] || "";
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
};
|
|
14
17
|
};
|
|
18
|
+
|
|
15
19
|
exports.default = _default;
|
package/modifiers/index.d.ts
CHANGED
package/modifiers/index.js
CHANGED
|
@@ -26,6 +26,6 @@ var _numberModifier = _interopRequireDefault(require("./numberModifier"));
|
|
|
26
26
|
var _priceModifier = _interopRequireDefault(require("./priceModifier"));
|
|
27
27
|
|
|
28
28
|
// Built-in modifiers
|
|
29
|
-
var _default = options => [_countModifier.default, _genderModifier.default, _ifModifier.default, _pluralModifier.default, (0, _dateModifier.default)(options), (0, _dateTimeModifier.default)(options), (0, _timeModifier.default)(options), (0, _numberModifier.default)(options), (0, _priceModifier.default)(options)];
|
|
29
|
+
var _default = options => [(0, _countModifier.default)(), (0, _genderModifier.default)(), (0, _ifModifier.default)(), (0, _pluralModifier.default)(), (0, _dateModifier.default)(options), (0, _dateTimeModifier.default)(options), (0, _timeModifier.default)(options), (0, _numberModifier.default)(options), (0, _priceModifier.default)(options)];
|
|
30
30
|
|
|
31
31
|
exports.default = _default;
|
|
@@ -4,35 +4,39 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _default = {
|
|
8
|
-
name: "plural",
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const current = parameters[i];
|
|
8
|
+
var _default = () => {
|
|
9
|
+
return {
|
|
10
|
+
name: "plural",
|
|
14
11
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const numbers = current.split("-"); // If we are dealing with a numbers range, then let's check if we are in it.
|
|
12
|
+
execute(value, parameters) {
|
|
13
|
+
// Numbers can be single number or ranges.
|
|
14
|
+
for (let i = 0; i < parameters.length; i = i + 2) {
|
|
15
|
+
const current = parameters[i];
|
|
20
16
|
|
|
21
|
-
|
|
22
|
-
if (value >= numbers[0] && value <= numbers[1]) {
|
|
17
|
+
if (current === "default") {
|
|
23
18
|
return parameters[i + 1];
|
|
24
19
|
}
|
|
25
20
|
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
const numbers = current.split("-"); // If we are dealing with a numbers range, then let's check if we are in it.
|
|
22
|
+
|
|
23
|
+
if (numbers.length === 2) {
|
|
24
|
+
if (value >= numbers[0] && value <= numbers[1]) {
|
|
25
|
+
return parameters[i + 1];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
if (String(value) === numbers[0]) {
|
|
32
|
+
return parameters[i + 1];
|
|
33
|
+
}
|
|
31
34
|
}
|
|
32
|
-
}
|
|
33
35
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
return "";
|
|
37
|
+
}
|
|
36
38
|
|
|
39
|
+
};
|
|
37
40
|
};
|
|
41
|
+
|
|
38
42
|
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/i18n",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.24.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -29,8 +29,10 @@
|
|
|
29
29
|
"@babel/preset-env": "^7.16.4",
|
|
30
30
|
"@babel/preset-typescript": "^7.16.0",
|
|
31
31
|
"@babel/register": "^7.16.0",
|
|
32
|
-
"@
|
|
33
|
-
"@
|
|
32
|
+
"@types/accounting": "^0.4.2",
|
|
33
|
+
"@types/lodash": "^4.14.178",
|
|
34
|
+
"@webiny/cli": "^5.24.0",
|
|
35
|
+
"@webiny/project-utils": "^5.24.0",
|
|
34
36
|
"babel-plugin-lodash": "^3.3.4",
|
|
35
37
|
"glob": "^7.1.2",
|
|
36
38
|
"rimraf": "^3.0.2",
|
|
@@ -44,5 +46,5 @@
|
|
|
44
46
|
"build": "yarn webiny run build",
|
|
45
47
|
"watch": "yarn webiny run watch"
|
|
46
48
|
},
|
|
47
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "be0cbfcaa9247c658c44179af7943cc5d6d71bc7"
|
|
48
50
|
}
|