intl-messageformat 2.0.0 → 2.1.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/README.md +1 -1
- package/dist/intl-messageformat-with-locales.js +16 -2
- package/dist/intl-messageformat-with-locales.js.map +1 -1
- package/dist/intl-messageformat-with-locales.min.js +3 -3
- package/dist/intl-messageformat-with-locales.min.js.map +1 -1
- package/dist/intl-messageformat.js +16 -2
- package/dist/intl-messageformat.js.map +1 -1
- package/dist/intl-messageformat.min.js +1 -1
- package/dist/intl-messageformat.min.js.map +1 -1
- package/index.d.ts +7 -0
- package/lib/compiler.js.map +1 -0
- package/lib/core.js +15 -2
- package/lib/core.js.map +1 -0
- package/lib/en.js.map +1 -0
- package/lib/es5.js +1 -0
- package/lib/es5.js.map +1 -0
- package/lib/main.js.map +1 -0
- package/lib/utils.js.map +1 -0
- package/package.json +1 -1
- package/src/core.js +15 -2
- package/src/es5.js +2 -2
package/README.md
CHANGED
|
@@ -91,7 +91,7 @@ Usage
|
|
|
91
91
|
|
|
92
92
|
### `Intl` Dependency
|
|
93
93
|
|
|
94
|
-
This package assumes that the [`Intl`][Intl] global object exists in the runtime. `Intl` is present in all modern browsers
|
|
94
|
+
This package assumes that the [`Intl`][Intl] global object exists in the runtime. `Intl` is present in all modern browsers and there's work happening to [integrate `Intl` into Node.js][Intl-Node].
|
|
95
95
|
|
|
96
96
|
**Luckly, there's the [Intl.js][] polyfill!** You will need to conditionally load the polyfill if you want to support runtimes which `Intl` is not already built-in.
|
|
97
97
|
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
|
|
56
56
|
return obj;
|
|
57
57
|
};
|
|
58
|
+
|
|
58
59
|
var $$compiler$$default = $$compiler$$Compiler;
|
|
59
60
|
|
|
60
61
|
function $$compiler$$Compiler(locales, formats, pluralFn) {
|
|
@@ -1640,7 +1641,18 @@
|
|
|
1640
1641
|
// the other `Intl` APIs.
|
|
1641
1642
|
var messageFormat = this;
|
|
1642
1643
|
this.format = function (values) {
|
|
1644
|
+
try {
|
|
1643
1645
|
return messageFormat._format(pattern, values);
|
|
1646
|
+
} catch (e) {
|
|
1647
|
+
if (e.variableId) {
|
|
1648
|
+
throw new Error(
|
|
1649
|
+
'The intl string context variable \'' + e.variableId + '\'' +
|
|
1650
|
+
' was not provided to the string \'' + message + '\''
|
|
1651
|
+
);
|
|
1652
|
+
} else {
|
|
1653
|
+
throw e;
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1644
1656
|
};
|
|
1645
1657
|
}
|
|
1646
1658
|
|
|
@@ -1775,7 +1787,7 @@
|
|
|
1775
1787
|
|
|
1776
1788
|
$$core$$MessageFormat.prototype._format = function (pattern, values) {
|
|
1777
1789
|
var result = '',
|
|
1778
|
-
i, len, part, id, value;
|
|
1790
|
+
i, len, part, id, value, err;
|
|
1779
1791
|
|
|
1780
1792
|
for (i = 0, len = pattern.length; i < len; i += 1) {
|
|
1781
1793
|
part = pattern[i];
|
|
@@ -1790,7 +1802,9 @@
|
|
|
1790
1802
|
|
|
1791
1803
|
// Enforce that all required values are provided by the caller.
|
|
1792
1804
|
if (!(values && $$utils$$hop.call(values, id))) {
|
|
1793
|
-
|
|
1805
|
+
err = new Error('A value must be provided for: ' + id);
|
|
1806
|
+
err.variableId = id;
|
|
1807
|
+
throw err;
|
|
1794
1808
|
}
|
|
1795
1809
|
|
|
1796
1810
|
value = values[id];
|