@formatjs/intl 1.6.4 → 1.6.8
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/lib/src/create-intl.d.ts.map +1 -1
- package/lib/src/create-intl.js +3 -2
- package/lib/src/dateTime.js +6 -6
- package/lib/src/displayName.js +2 -2
- package/lib/src/error.d.ts +1 -1
- package/lib/src/error.d.ts.map +1 -1
- package/lib/src/error.js +5 -5
- package/lib/src/list.js +2 -2
- package/lib/src/number.js +3 -3
- package/package.json +4 -4
- package/src/create-intl.d.ts.map +1 -1
- package/src/create-intl.js +3 -2
- package/src/dateTime.js +5 -5
- package/src/displayName.js +1 -1
- package/src/error.d.ts +1 -1
- package/src/error.d.ts.map +1 -1
- package/src/error.js +5 -5
- package/src/list.js +1 -1
- package/src/number.js +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-intl.d.ts","sourceRoot":"","sources":["../../../../../../../packages/intl/src/create-intl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAC,MAAM,SAAS,CAAC;AAkB7E,MAAM,WAAW,YAAY,CAC3B,CAAC,GAAG,MAAM,EACV,CAAC,SAAS,kBAAkB,CAAC,CAAC,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,EACvD,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC;IAErC,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC;CACnC;AAuBD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,CAAC,GAAG,MAAM,EACnC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC,EAC7B,KAAK,CAAC,EAAE,SAAS,GAChB,SAAS,CAAC,CAAC,CAAC,GAAG;IAChB;;;OAGG;IACH,aAAa,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;CAC1D,
|
|
1
|
+
{"version":3,"file":"create-intl.d.ts","sourceRoot":"","sources":["../../../../../../../packages/intl/src/create-intl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAC,MAAM,SAAS,CAAC;AAkB7E,MAAM,WAAW,YAAY,CAC3B,CAAC,GAAG,MAAM,EACV,CAAC,SAAS,kBAAkB,CAAC,CAAC,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,EACvD,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC;IAErC,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC;CACnC;AAuBD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,CAAC,GAAG,MAAM,EACnC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC,EAC7B,KAAK,CAAC,EAAE,SAAS,GAChB,SAAS,CAAC,CAAC,CAAC,GAAG;IAChB;;;OAGG;IACH,aAAa,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;CAC1D,CAuHA"}
|
package/lib/src/create-intl.js
CHANGED
|
@@ -56,7 +56,8 @@ export function createIntl(config, cache) {
|
|
|
56
56
|
(!existingMessagesContainAst && mergingMessagesContainAst))) {
|
|
57
57
|
config.onError(new InvalidConfigError("Cannot mix AST & non-AST messages for locale " + resolvedConfig.locale));
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
Object.keys(messages).forEach(function (k) {
|
|
60
|
+
resolvedConfig.messages[k] = messages[k];
|
|
61
|
+
});
|
|
61
62
|
} });
|
|
62
63
|
}
|
package/lib/src/dateTime.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __assign } from "tslib";
|
|
2
2
|
import { filterProps, getNamedFormat } from './utils';
|
|
3
|
-
import { IntlError } from './error';
|
|
3
|
+
import { IntlError, IntlErrorCode } from './error';
|
|
4
4
|
var DATE_TIME_FORMAT_OPTIONS = [
|
|
5
5
|
'localeMatcher',
|
|
6
6
|
'formatMatcher',
|
|
@@ -51,7 +51,7 @@ export function formatDate(config, getDateTimeFormat) {
|
|
|
51
51
|
return getFormatter(config, 'date', getDateTimeFormat, options).format(date);
|
|
52
52
|
}
|
|
53
53
|
catch (e) {
|
|
54
|
-
config.onError(new IntlError(
|
|
54
|
+
config.onError(new IntlError(IntlErrorCode.FORMAT_ERROR, 'Error formatting date.', e));
|
|
55
55
|
}
|
|
56
56
|
return String(date);
|
|
57
57
|
}
|
|
@@ -66,7 +66,7 @@ export function formatTime(config, getDateTimeFormat) {
|
|
|
66
66
|
return getFormatter(config, 'time', getDateTimeFormat, options).format(date);
|
|
67
67
|
}
|
|
68
68
|
catch (e) {
|
|
69
|
-
config.onError(new IntlError(
|
|
69
|
+
config.onError(new IntlError(IntlErrorCode.FORMAT_ERROR, 'Error formatting time.', e));
|
|
70
70
|
}
|
|
71
71
|
return String(date);
|
|
72
72
|
}
|
|
@@ -82,7 +82,7 @@ export function formatDateTimeRange(config, getDateTimeFormat) {
|
|
|
82
82
|
return getDateTimeFormat(locale, filteredOptions).formatRange(from, to);
|
|
83
83
|
}
|
|
84
84
|
catch (e) {
|
|
85
|
-
onError(new IntlError(
|
|
85
|
+
onError(new IntlError(IntlErrorCode.FORMAT_ERROR, 'Error formatting date time range.', e));
|
|
86
86
|
}
|
|
87
87
|
return String(from);
|
|
88
88
|
}
|
|
@@ -97,7 +97,7 @@ export function formatDateToParts(config, getDateTimeFormat) {
|
|
|
97
97
|
return getFormatter(config, 'date', getDateTimeFormat, options).formatToParts(date);
|
|
98
98
|
}
|
|
99
99
|
catch (e) {
|
|
100
|
-
config.onError(new IntlError(
|
|
100
|
+
config.onError(new IntlError(IntlErrorCode.FORMAT_ERROR, 'Error formatting date.', e));
|
|
101
101
|
}
|
|
102
102
|
return [];
|
|
103
103
|
}
|
|
@@ -112,7 +112,7 @@ export function formatTimeToParts(config, getDateTimeFormat) {
|
|
|
112
112
|
return getFormatter(config, 'time', getDateTimeFormat, options).formatToParts(date);
|
|
113
113
|
}
|
|
114
114
|
catch (e) {
|
|
115
|
-
config.onError(new IntlError(
|
|
115
|
+
config.onError(new IntlError(IntlErrorCode.FORMAT_ERROR, 'Error formatting time.', e));
|
|
116
116
|
}
|
|
117
117
|
return [];
|
|
118
118
|
}
|
package/lib/src/displayName.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { filterProps } from './utils';
|
|
2
2
|
import { FormatError } from 'intl-messageformat';
|
|
3
|
-
import { IntlError } from './error';
|
|
3
|
+
import { IntlErrorCode, IntlError } from './error';
|
|
4
4
|
var DISPLAY_NAMES_OPTONS = [
|
|
5
5
|
'localeMatcher',
|
|
6
6
|
'style',
|
|
@@ -18,6 +18,6 @@ export function formatDisplayName(_a, getDisplayNames, value, options) {
|
|
|
18
18
|
return getDisplayNames(locale, filteredOptions).of(value);
|
|
19
19
|
}
|
|
20
20
|
catch (e) {
|
|
21
|
-
onError(new IntlError(
|
|
21
|
+
onError(new IntlError(IntlErrorCode.FORMAT_ERROR, 'Error formatting display name.', e));
|
|
22
22
|
}
|
|
23
23
|
}
|
package/lib/src/error.d.ts
CHANGED
package/lib/src/error.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../../../../../packages/intl/src/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,SAAS,CAAC;AAE1C,
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../../../../../packages/intl/src/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,SAAS,CAAC;AAE1C,oBAAY,aAAa;IACvB,YAAY,iBAAiB;IAC7B,qBAAqB,0BAA0B;IAC/C,cAAc,mBAAmB;IACjC,YAAY,iBAAiB;IAC7B,mBAAmB,wBAAwB;CAC5C;AAED,qBAAa,SAAS,CACpB,CAAC,SAAS,aAAa,GAAG,aAAa,CAAC,YAAY,CACpD,SAAQ,KAAK;IACb,SAAgB,IAAI,EAAE,CAAC,CAAC;gBAEZ,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,KAAK;CAUxD;AAED,qBAAa,yBAA0B,SAAQ,SAAS,CAAC,aAAa,CAAC,qBAAqB,CAAC;gBAC/E,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,KAAK;CAG/C;AAED,qBAAa,kBAAmB,SAAQ,SAAS,CAAC,aAAa,CAAC,cAAc,CAAC;gBACjE,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,KAAK;CAG/C;AAED,qBAAa,gBAAiB,SAAQ,SAAS,CAAC,aAAa,CAAC,YAAY,CAAC;gBAC7D,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,KAAK;CAG/C;AAED,qBAAa,kBAAmB,SAAQ,SAAS,CAAC,aAAa,CAAC,YAAY,CAAC;IAC3E,SAAgB,UAAU,CAAC,EAAE,iBAAiB,CAAC;gBAE7C,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,UAAU,CAAC,EAAE,iBAAiB,EAC9B,SAAS,CAAC,EAAE,KAAK;CAcpB;AAED,qBAAa,uBAAwB,SAAQ,SAAS,CAAC,aAAa,CAAC,mBAAmB,CAAC;IACvF,SAAgB,UAAU,CAAC,EAAE,iBAAiB,CAAC;gBACnC,UAAU,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM;CAS1D"}
|
package/lib/src/error.js
CHANGED
|
@@ -23,7 +23,7 @@ export { IntlError };
|
|
|
23
23
|
var UnsupportedFormatterError = /** @class */ (function (_super) {
|
|
24
24
|
__extends(UnsupportedFormatterError, _super);
|
|
25
25
|
function UnsupportedFormatterError(message, exception) {
|
|
26
|
-
return _super.call(this,
|
|
26
|
+
return _super.call(this, IntlErrorCode.UNSUPPORTED_FORMATTER, message, exception) || this;
|
|
27
27
|
}
|
|
28
28
|
return UnsupportedFormatterError;
|
|
29
29
|
}(IntlError));
|
|
@@ -31,7 +31,7 @@ export { UnsupportedFormatterError };
|
|
|
31
31
|
var InvalidConfigError = /** @class */ (function (_super) {
|
|
32
32
|
__extends(InvalidConfigError, _super);
|
|
33
33
|
function InvalidConfigError(message, exception) {
|
|
34
|
-
return _super.call(this,
|
|
34
|
+
return _super.call(this, IntlErrorCode.INVALID_CONFIG, message, exception) || this;
|
|
35
35
|
}
|
|
36
36
|
return InvalidConfigError;
|
|
37
37
|
}(IntlError));
|
|
@@ -39,7 +39,7 @@ export { InvalidConfigError };
|
|
|
39
39
|
var MissingDataError = /** @class */ (function (_super) {
|
|
40
40
|
__extends(MissingDataError, _super);
|
|
41
41
|
function MissingDataError(message, exception) {
|
|
42
|
-
return _super.call(this,
|
|
42
|
+
return _super.call(this, IntlErrorCode.MISSING_DATA, message, exception) || this;
|
|
43
43
|
}
|
|
44
44
|
return MissingDataError;
|
|
45
45
|
}(IntlError));
|
|
@@ -47,7 +47,7 @@ export { MissingDataError };
|
|
|
47
47
|
var MessageFormatError = /** @class */ (function (_super) {
|
|
48
48
|
__extends(MessageFormatError, _super);
|
|
49
49
|
function MessageFormatError(message, locale, descriptor, exception) {
|
|
50
|
-
var _this = _super.call(this,
|
|
50
|
+
var _this = _super.call(this, IntlErrorCode.FORMAT_ERROR, message + " \nLocale: " + locale + "\nMessageID: " + (descriptor === null || descriptor === void 0 ? void 0 : descriptor.id) + "\nDefault Message: " + (descriptor === null || descriptor === void 0 ? void 0 : descriptor.defaultMessage) + "\nDescription: " + (descriptor === null || descriptor === void 0 ? void 0 : descriptor.description) + " \n", exception) || this;
|
|
51
51
|
_this.descriptor = descriptor;
|
|
52
52
|
return _this;
|
|
53
53
|
}
|
|
@@ -57,7 +57,7 @@ export { MessageFormatError };
|
|
|
57
57
|
var MissingTranslationError = /** @class */ (function (_super) {
|
|
58
58
|
__extends(MissingTranslationError, _super);
|
|
59
59
|
function MissingTranslationError(descriptor, locale) {
|
|
60
|
-
var _this = _super.call(this,
|
|
60
|
+
var _this = _super.call(this, IntlErrorCode.MISSING_TRANSLATION, "Missing message: \"" + descriptor.id + "\" for locale \"" + locale + "\", using " + (descriptor.defaultMessage ? 'default message' : 'id') + " as fallback.") || this;
|
|
61
61
|
_this.descriptor = descriptor;
|
|
62
62
|
return _this;
|
|
63
63
|
}
|
package/lib/src/list.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { filterProps } from './utils';
|
|
2
2
|
import { FormatError } from 'intl-messageformat';
|
|
3
|
-
import { IntlError } from './error';
|
|
3
|
+
import { IntlError, IntlErrorCode } from './error';
|
|
4
4
|
var LIST_FORMAT_OPTIONS = [
|
|
5
5
|
'localeMatcher',
|
|
6
6
|
'type',
|
|
@@ -47,7 +47,7 @@ export function formatList(_a, getListFormat, values, options) {
|
|
|
47
47
|
}, []);
|
|
48
48
|
}
|
|
49
49
|
catch (e) {
|
|
50
|
-
onError(new IntlError(
|
|
50
|
+
onError(new IntlError(IntlErrorCode.FORMAT_ERROR, 'Error formatting list.', e));
|
|
51
51
|
}
|
|
52
52
|
// @ts-ignore
|
|
53
53
|
return values;
|
package/lib/src/number.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getNamedFormat, filterProps } from './utils';
|
|
2
|
-
import { IntlError } from './error';
|
|
2
|
+
import { IntlError, IntlErrorCode } from './error';
|
|
3
3
|
var NUMBER_FORMAT_OPTIONS = [
|
|
4
4
|
'localeMatcher',
|
|
5
5
|
'style',
|
|
@@ -38,7 +38,7 @@ export function formatNumber(config, getNumberFormat, value, options) {
|
|
|
38
38
|
return getFormatter(config, getNumberFormat, options).format(value);
|
|
39
39
|
}
|
|
40
40
|
catch (e) {
|
|
41
|
-
config.onError(new IntlError(
|
|
41
|
+
config.onError(new IntlError(IntlErrorCode.FORMAT_ERROR, 'Error formatting number.', e));
|
|
42
42
|
}
|
|
43
43
|
return String(value);
|
|
44
44
|
}
|
|
@@ -48,7 +48,7 @@ export function formatNumberToParts(config, getNumberFormat, value, options) {
|
|
|
48
48
|
return getFormatter(config, getNumberFormat, options).formatToParts(value);
|
|
49
49
|
}
|
|
50
50
|
catch (e) {
|
|
51
|
-
config.onError(new IntlError(
|
|
51
|
+
config.onError(new IntlError(IntlErrorCode.FORMAT_ERROR, 'Error formatting number.', e));
|
|
52
52
|
}
|
|
53
53
|
return [];
|
|
54
54
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formatjs/intl",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.8",
|
|
4
4
|
"description": "Internationalize JS apps. This library provides an API to format dates, numbers, and strings, including pluralization and handling translations.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"intl",
|
|
@@ -30,13 +30,13 @@
|
|
|
30
30
|
"sideEffects": false,
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@formatjs/ecma402-abstract": "1.5.2",
|
|
33
|
-
"@formatjs/intl-datetimeformat": "3.2.
|
|
33
|
+
"@formatjs/intl-datetimeformat": "3.2.7",
|
|
34
34
|
"@formatjs/intl-displaynames": "4.0.5",
|
|
35
35
|
"@formatjs/intl-listformat": "5.0.5",
|
|
36
36
|
"@formatjs/intl-relativetimeformat": "8.0.4",
|
|
37
37
|
"fast-memoize": "^2.5.2",
|
|
38
|
-
"intl-messageformat": "9.4.
|
|
39
|
-
"intl-messageformat-parser": "6.3.
|
|
38
|
+
"intl-messageformat": "9.4.7",
|
|
39
|
+
"intl-messageformat-parser": "6.3.2",
|
|
40
40
|
"tslib": "^2.0.1"
|
|
41
41
|
}
|
|
42
42
|
}
|
package/src/create-intl.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-intl.d.ts","sourceRoot":"","sources":["../../../../../../packages/intl/src/create-intl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAC,MAAM,SAAS,CAAC;AAkB7E,MAAM,WAAW,YAAY,CAC3B,CAAC,GAAG,MAAM,EACV,CAAC,SAAS,kBAAkB,CAAC,CAAC,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,EACvD,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC;IAErC,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC;CACnC;AAuBD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,CAAC,GAAG,MAAM,EACnC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC,EAC7B,KAAK,CAAC,EAAE,SAAS,GAChB,SAAS,CAAC,CAAC,CAAC,GAAG;IAChB;;;OAGG;IACH,aAAa,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;CAC1D,
|
|
1
|
+
{"version":3,"file":"create-intl.d.ts","sourceRoot":"","sources":["../../../../../../packages/intl/src/create-intl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAC,MAAM,SAAS,CAAC;AAkB7E,MAAM,WAAW,YAAY,CAC3B,CAAC,GAAG,MAAM,EACV,CAAC,SAAS,kBAAkB,CAAC,CAAC,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,EACvD,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC;IAErC,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC;CACnC;AAuBD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,CAAC,GAAG,MAAM,EACnC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC,EAC7B,KAAK,CAAC,EAAE,SAAS,GAChB,SAAS,CAAC,CAAC,CAAC,GAAG;IAChB;;;OAGG;IACH,aAAa,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;CAC1D,CAuHA"}
|
package/src/create-intl.js
CHANGED
|
@@ -59,8 +59,9 @@ function createIntl(config, cache) {
|
|
|
59
59
|
(!existingMessagesContainAst && mergingMessagesContainAst))) {
|
|
60
60
|
config.onError(new error_1.InvalidConfigError("Cannot mix AST & non-AST messages for locale " + resolvedConfig.locale));
|
|
61
61
|
}
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
Object.keys(messages).forEach(function (k) {
|
|
63
|
+
resolvedConfig.messages[k] = messages[k];
|
|
64
|
+
});
|
|
64
65
|
} });
|
|
65
66
|
}
|
|
66
67
|
exports.createIntl = createIntl;
|
package/src/dateTime.js
CHANGED
|
@@ -55,7 +55,7 @@ function formatDate(config, getDateTimeFormat) {
|
|
|
55
55
|
return getFormatter(config, 'date', getDateTimeFormat, options).format(date);
|
|
56
56
|
}
|
|
57
57
|
catch (e) {
|
|
58
|
-
config.onError(new error_1.IntlError(
|
|
58
|
+
config.onError(new error_1.IntlError(error_1.IntlErrorCode.FORMAT_ERROR, 'Error formatting date.', e));
|
|
59
59
|
}
|
|
60
60
|
return String(date);
|
|
61
61
|
}
|
|
@@ -71,7 +71,7 @@ function formatTime(config, getDateTimeFormat) {
|
|
|
71
71
|
return getFormatter(config, 'time', getDateTimeFormat, options).format(date);
|
|
72
72
|
}
|
|
73
73
|
catch (e) {
|
|
74
|
-
config.onError(new error_1.IntlError(
|
|
74
|
+
config.onError(new error_1.IntlError(error_1.IntlErrorCode.FORMAT_ERROR, 'Error formatting time.', e));
|
|
75
75
|
}
|
|
76
76
|
return String(date);
|
|
77
77
|
}
|
|
@@ -88,7 +88,7 @@ function formatDateTimeRange(config, getDateTimeFormat) {
|
|
|
88
88
|
return getDateTimeFormat(locale, filteredOptions).formatRange(from, to);
|
|
89
89
|
}
|
|
90
90
|
catch (e) {
|
|
91
|
-
onError(new error_1.IntlError(
|
|
91
|
+
onError(new error_1.IntlError(error_1.IntlErrorCode.FORMAT_ERROR, 'Error formatting date time range.', e));
|
|
92
92
|
}
|
|
93
93
|
return String(from);
|
|
94
94
|
}
|
|
@@ -104,7 +104,7 @@ function formatDateToParts(config, getDateTimeFormat) {
|
|
|
104
104
|
return getFormatter(config, 'date', getDateTimeFormat, options).formatToParts(date);
|
|
105
105
|
}
|
|
106
106
|
catch (e) {
|
|
107
|
-
config.onError(new error_1.IntlError(
|
|
107
|
+
config.onError(new error_1.IntlError(error_1.IntlErrorCode.FORMAT_ERROR, 'Error formatting date.', e));
|
|
108
108
|
}
|
|
109
109
|
return [];
|
|
110
110
|
}
|
|
@@ -120,7 +120,7 @@ function formatTimeToParts(config, getDateTimeFormat) {
|
|
|
120
120
|
return getFormatter(config, 'time', getDateTimeFormat, options).formatToParts(date);
|
|
121
121
|
}
|
|
122
122
|
catch (e) {
|
|
123
|
-
config.onError(new error_1.IntlError(
|
|
123
|
+
config.onError(new error_1.IntlError(error_1.IntlErrorCode.FORMAT_ERROR, 'Error formatting time.', e));
|
|
124
124
|
}
|
|
125
125
|
return [];
|
|
126
126
|
}
|
package/src/displayName.js
CHANGED
|
@@ -21,7 +21,7 @@ function formatDisplayName(_a, getDisplayNames, value, options) {
|
|
|
21
21
|
return getDisplayNames(locale, filteredOptions).of(value);
|
|
22
22
|
}
|
|
23
23
|
catch (e) {
|
|
24
|
-
onError(new error_1.IntlError(
|
|
24
|
+
onError(new error_1.IntlError(error_1.IntlErrorCode.FORMAT_ERROR, 'Error formatting display name.', e));
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
exports.formatDisplayName = formatDisplayName;
|
package/src/error.d.ts
CHANGED
package/src/error.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../../../../packages/intl/src/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,SAAS,CAAC;AAE1C,
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../../../../packages/intl/src/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,SAAS,CAAC;AAE1C,oBAAY,aAAa;IACvB,YAAY,iBAAiB;IAC7B,qBAAqB,0BAA0B;IAC/C,cAAc,mBAAmB;IACjC,YAAY,iBAAiB;IAC7B,mBAAmB,wBAAwB;CAC5C;AAED,qBAAa,SAAS,CACpB,CAAC,SAAS,aAAa,GAAG,aAAa,CAAC,YAAY,CACpD,SAAQ,KAAK;IACb,SAAgB,IAAI,EAAE,CAAC,CAAC;gBAEZ,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,KAAK;CAUxD;AAED,qBAAa,yBAA0B,SAAQ,SAAS,CAAC,aAAa,CAAC,qBAAqB,CAAC;gBAC/E,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,KAAK;CAG/C;AAED,qBAAa,kBAAmB,SAAQ,SAAS,CAAC,aAAa,CAAC,cAAc,CAAC;gBACjE,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,KAAK;CAG/C;AAED,qBAAa,gBAAiB,SAAQ,SAAS,CAAC,aAAa,CAAC,YAAY,CAAC;gBAC7D,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,KAAK;CAG/C;AAED,qBAAa,kBAAmB,SAAQ,SAAS,CAAC,aAAa,CAAC,YAAY,CAAC;IAC3E,SAAgB,UAAU,CAAC,EAAE,iBAAiB,CAAC;gBAE7C,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,UAAU,CAAC,EAAE,iBAAiB,EAC9B,SAAS,CAAC,EAAE,KAAK;CAcpB;AAED,qBAAa,uBAAwB,SAAQ,SAAS,CAAC,aAAa,CAAC,mBAAmB,CAAC;IACvF,SAAgB,UAAU,CAAC,EAAE,iBAAiB,CAAC;gBACnC,UAAU,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM;CAS1D"}
|
package/src/error.js
CHANGED
|
@@ -26,7 +26,7 @@ exports.IntlError = IntlError;
|
|
|
26
26
|
var UnsupportedFormatterError = /** @class */ (function (_super) {
|
|
27
27
|
tslib_1.__extends(UnsupportedFormatterError, _super);
|
|
28
28
|
function UnsupportedFormatterError(message, exception) {
|
|
29
|
-
return _super.call(this,
|
|
29
|
+
return _super.call(this, IntlErrorCode.UNSUPPORTED_FORMATTER, message, exception) || this;
|
|
30
30
|
}
|
|
31
31
|
return UnsupportedFormatterError;
|
|
32
32
|
}(IntlError));
|
|
@@ -34,7 +34,7 @@ exports.UnsupportedFormatterError = UnsupportedFormatterError;
|
|
|
34
34
|
var InvalidConfigError = /** @class */ (function (_super) {
|
|
35
35
|
tslib_1.__extends(InvalidConfigError, _super);
|
|
36
36
|
function InvalidConfigError(message, exception) {
|
|
37
|
-
return _super.call(this,
|
|
37
|
+
return _super.call(this, IntlErrorCode.INVALID_CONFIG, message, exception) || this;
|
|
38
38
|
}
|
|
39
39
|
return InvalidConfigError;
|
|
40
40
|
}(IntlError));
|
|
@@ -42,7 +42,7 @@ exports.InvalidConfigError = InvalidConfigError;
|
|
|
42
42
|
var MissingDataError = /** @class */ (function (_super) {
|
|
43
43
|
tslib_1.__extends(MissingDataError, _super);
|
|
44
44
|
function MissingDataError(message, exception) {
|
|
45
|
-
return _super.call(this,
|
|
45
|
+
return _super.call(this, IntlErrorCode.MISSING_DATA, message, exception) || this;
|
|
46
46
|
}
|
|
47
47
|
return MissingDataError;
|
|
48
48
|
}(IntlError));
|
|
@@ -50,7 +50,7 @@ exports.MissingDataError = MissingDataError;
|
|
|
50
50
|
var MessageFormatError = /** @class */ (function (_super) {
|
|
51
51
|
tslib_1.__extends(MessageFormatError, _super);
|
|
52
52
|
function MessageFormatError(message, locale, descriptor, exception) {
|
|
53
|
-
var _this = _super.call(this,
|
|
53
|
+
var _this = _super.call(this, IntlErrorCode.FORMAT_ERROR, message + " \nLocale: " + locale + "\nMessageID: " + (descriptor === null || descriptor === void 0 ? void 0 : descriptor.id) + "\nDefault Message: " + (descriptor === null || descriptor === void 0 ? void 0 : descriptor.defaultMessage) + "\nDescription: " + (descriptor === null || descriptor === void 0 ? void 0 : descriptor.description) + " \n", exception) || this;
|
|
54
54
|
_this.descriptor = descriptor;
|
|
55
55
|
return _this;
|
|
56
56
|
}
|
|
@@ -60,7 +60,7 @@ exports.MessageFormatError = MessageFormatError;
|
|
|
60
60
|
var MissingTranslationError = /** @class */ (function (_super) {
|
|
61
61
|
tslib_1.__extends(MissingTranslationError, _super);
|
|
62
62
|
function MissingTranslationError(descriptor, locale) {
|
|
63
|
-
var _this = _super.call(this,
|
|
63
|
+
var _this = _super.call(this, IntlErrorCode.MISSING_TRANSLATION, "Missing message: \"" + descriptor.id + "\" for locale \"" + locale + "\", using " + (descriptor.defaultMessage ? 'default message' : 'id') + " as fallback.") || this;
|
|
64
64
|
_this.descriptor = descriptor;
|
|
65
65
|
return _this;
|
|
66
66
|
}
|
package/src/list.js
CHANGED
|
@@ -50,7 +50,7 @@ function formatList(_a, getListFormat, values, options) {
|
|
|
50
50
|
}, []);
|
|
51
51
|
}
|
|
52
52
|
catch (e) {
|
|
53
|
-
onError(new error_1.IntlError(
|
|
53
|
+
onError(new error_1.IntlError(error_1.IntlErrorCode.FORMAT_ERROR, 'Error formatting list.', e));
|
|
54
54
|
}
|
|
55
55
|
// @ts-ignore
|
|
56
56
|
return values;
|
package/src/number.js
CHANGED
|
@@ -42,7 +42,7 @@ function formatNumber(config, getNumberFormat, value, options) {
|
|
|
42
42
|
return getFormatter(config, getNumberFormat, options).format(value);
|
|
43
43
|
}
|
|
44
44
|
catch (e) {
|
|
45
|
-
config.onError(new error_1.IntlError(
|
|
45
|
+
config.onError(new error_1.IntlError(error_1.IntlErrorCode.FORMAT_ERROR, 'Error formatting number.', e));
|
|
46
46
|
}
|
|
47
47
|
return String(value);
|
|
48
48
|
}
|
|
@@ -53,7 +53,7 @@ function formatNumberToParts(config, getNumberFormat, value, options) {
|
|
|
53
53
|
return getFormatter(config, getNumberFormat, options).formatToParts(value);
|
|
54
54
|
}
|
|
55
55
|
catch (e) {
|
|
56
|
-
config.onError(new error_1.IntlError(
|
|
56
|
+
config.onError(new error_1.IntlError(error_1.IntlErrorCode.FORMAT_ERROR, 'Error formatting number.', e));
|
|
57
57
|
}
|
|
58
58
|
return [];
|
|
59
59
|
}
|