react-intl 2.6.0 → 2.8.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/dist/react-intl.js +60 -52
- package/dist/react-intl.js.map +1 -1
- package/dist/react-intl.min.js +1 -1
- package/dist/react-intl.min.js.map +1 -1
- package/lib/index.es.js +60 -52
- package/lib/index.js +60 -52
- package/locale-data/af.js +1 -1
- package/locale-data/agq.js +1 -1
- package/locale-data/ak.js +1 -1
- package/locale-data/am.js +1 -1
- package/locale-data/ar.js +1 -1
- package/locale-data/ars.js +1 -1
- package/locale-data/as.js +1 -1
- package/locale-data/asa.js +1 -1
- package/locale-data/ast.js +1 -1
- package/locale-data/az.js +1 -1
- package/locale-data/bas.js +1 -1
- package/locale-data/be.js +1 -1
- package/locale-data/bem.js +1 -1
- package/locale-data/bez.js +1 -1
- package/locale-data/bg.js +1 -1
- package/locale-data/bh.js +1 -1
- package/locale-data/bm.js +1 -1
- package/locale-data/bn.js +1 -1
- package/locale-data/bo.js +1 -1
- package/locale-data/br.js +1 -1
- package/locale-data/brx.js +1 -1
- package/locale-data/bs.js +1 -1
- package/locale-data/ca.js +1 -1
- package/locale-data/ccp.js +1 -0
- package/locale-data/ce.js +1 -1
- package/locale-data/cgg.js +1 -1
- package/locale-data/chr.js +1 -1
- package/locale-data/ckb.js +1 -1
- package/locale-data/cs.js +1 -1
- package/locale-data/cu.js +1 -1
- package/locale-data/cy.js +1 -1
- package/locale-data/da.js +1 -1
- package/locale-data/dav.js +1 -1
- package/locale-data/de.js +1 -1
- package/locale-data/dje.js +1 -1
- package/locale-data/dsb.js +1 -1
- package/locale-data/dua.js +1 -1
- package/locale-data/dv.js +1 -1
- package/locale-data/dyo.js +1 -1
- package/locale-data/dz.js +1 -1
- package/locale-data/ebu.js +1 -1
- package/locale-data/ee.js +1 -1
- package/locale-data/el.js +1 -1
- package/locale-data/en.js +1 -1
- package/locale-data/eo.js +1 -1
- package/locale-data/es.js +1 -1
- package/locale-data/et.js +1 -1
- package/locale-data/eu.js +1 -1
- package/locale-data/ewo.js +1 -1
- package/locale-data/fa.js +1 -1
- package/locale-data/ff.js +1 -1
- package/locale-data/fi.js +1 -1
- package/locale-data/fil.js +1 -1
- package/locale-data/fo.js +1 -1
- package/locale-data/fr.js +1 -1
- package/locale-data/fur.js +1 -1
- package/locale-data/fy.js +1 -1
- package/locale-data/ga.js +1 -1
- package/locale-data/gd.js +1 -1
- package/locale-data/gl.js +1 -1
- package/locale-data/gsw.js +1 -1
- package/locale-data/gu.js +1 -1
- package/locale-data/guw.js +1 -1
- package/locale-data/guz.js +1 -1
- package/locale-data/gv.js +1 -1
- package/locale-data/ha.js +1 -1
- package/locale-data/haw.js +1 -1
- package/locale-data/he.js +1 -1
- package/locale-data/hi.js +1 -1
- package/locale-data/hr.js +1 -1
- package/locale-data/hsb.js +1 -1
- package/locale-data/hu.js +1 -1
- package/locale-data/hy.js +1 -1
- package/locale-data/ia.js +1 -0
- package/locale-data/id.js +1 -1
- package/locale-data/ig.js +1 -1
- package/locale-data/ii.js +1 -1
- package/locale-data/in.js +1 -1
- package/locale-data/index.js +1 -1
- package/locale-data/io.js +1 -0
- package/locale-data/is.js +1 -1
- package/locale-data/it.js +1 -1
- package/locale-data/iu.js +1 -1
- package/locale-data/iw.js +1 -1
- package/locale-data/ja.js +1 -1
- package/locale-data/jbo.js +1 -1
- package/locale-data/jgo.js +1 -1
- package/locale-data/ji.js +1 -1
- package/locale-data/jmc.js +1 -1
- package/locale-data/jv.js +1 -1
- package/locale-data/jw.js +1 -1
- package/locale-data/ka.js +1 -1
- package/locale-data/kab.js +1 -1
- package/locale-data/kaj.js +1 -1
- package/locale-data/kam.js +1 -1
- package/locale-data/kcg.js +1 -1
- package/locale-data/kde.js +1 -1
- package/locale-data/kea.js +1 -1
- package/locale-data/khq.js +1 -1
- package/locale-data/ki.js +1 -1
- package/locale-data/kk.js +1 -1
- package/locale-data/kkj.js +1 -1
- package/locale-data/kl.js +1 -1
- package/locale-data/kln.js +1 -1
- package/locale-data/km.js +1 -1
- package/locale-data/kn.js +1 -1
- package/locale-data/ko.js +1 -1
- package/locale-data/kok.js +1 -1
- package/locale-data/ks.js +1 -1
- package/locale-data/ksb.js +1 -1
- package/locale-data/ksf.js +1 -1
- package/locale-data/ksh.js +1 -1
- package/locale-data/ku.js +1 -1
- package/locale-data/kw.js +1 -1
- package/locale-data/ky.js +1 -1
- package/locale-data/lag.js +1 -1
- package/locale-data/lb.js +1 -1
- package/locale-data/lg.js +1 -1
- package/locale-data/lkt.js +1 -1
- package/locale-data/ln.js +1 -1
- package/locale-data/lo.js +1 -1
- package/locale-data/lrc.js +1 -1
- package/locale-data/lt.js +1 -1
- package/locale-data/lu.js +1 -1
- package/locale-data/luo.js +1 -1
- package/locale-data/luy.js +1 -1
- package/locale-data/lv.js +1 -1
- package/locale-data/mas.js +1 -1
- package/locale-data/mer.js +1 -1
- package/locale-data/mfe.js +1 -1
- package/locale-data/mg.js +1 -1
- package/locale-data/mgh.js +1 -1
- package/locale-data/mgo.js +1 -1
- package/locale-data/mi.js +1 -0
- package/locale-data/mk.js +1 -1
- package/locale-data/ml.js +1 -1
- package/locale-data/mn.js +1 -1
- package/locale-data/mo.js +1 -1
- package/locale-data/mr.js +1 -1
- package/locale-data/ms.js +1 -1
- package/locale-data/mt.js +1 -1
- package/locale-data/mua.js +1 -1
- package/locale-data/my.js +1 -1
- package/locale-data/mzn.js +1 -1
- package/locale-data/nah.js +1 -1
- package/locale-data/naq.js +1 -1
- package/locale-data/nb.js +1 -1
- package/locale-data/nd.js +1 -1
- package/locale-data/nds.js +1 -1
- package/locale-data/ne.js +1 -1
- package/locale-data/nl.js +1 -1
- package/locale-data/nmg.js +1 -1
- package/locale-data/nn.js +1 -1
- package/locale-data/nnh.js +1 -1
- package/locale-data/no.js +1 -1
- package/locale-data/nqo.js +1 -1
- package/locale-data/nr.js +1 -1
- package/locale-data/nso.js +1 -1
- package/locale-data/nus.js +1 -1
- package/locale-data/ny.js +1 -1
- package/locale-data/nyn.js +1 -1
- package/locale-data/om.js +1 -1
- package/locale-data/or.js +1 -1
- package/locale-data/os.js +1 -1
- package/locale-data/pa.js +1 -1
- package/locale-data/pap.js +1 -1
- package/locale-data/pl.js +1 -1
- package/locale-data/prg.js +1 -1
- package/locale-data/ps.js +1 -1
- package/locale-data/pt.js +1 -1
- package/locale-data/qu.js +1 -1
- package/locale-data/rm.js +1 -1
- package/locale-data/rn.js +1 -1
- package/locale-data/ro.js +1 -1
- package/locale-data/rof.js +1 -1
- package/locale-data/ru.js +1 -1
- package/locale-data/rw.js +1 -1
- package/locale-data/rwk.js +1 -1
- package/locale-data/sah.js +1 -1
- package/locale-data/saq.js +1 -1
- package/locale-data/sbp.js +1 -1
- package/locale-data/sc.js +1 -0
- package/locale-data/scn.js +1 -0
- package/locale-data/sd.js +1 -0
- package/locale-data/sdh.js +1 -1
- package/locale-data/se.js +1 -1
- package/locale-data/seh.js +1 -1
- package/locale-data/ses.js +1 -1
- package/locale-data/sg.js +1 -1
- package/locale-data/sh.js +1 -1
- package/locale-data/shi.js +1 -1
- package/locale-data/si.js +1 -1
- package/locale-data/sk.js +1 -1
- package/locale-data/sl.js +1 -1
- package/locale-data/sma.js +1 -1
- package/locale-data/smi.js +1 -1
- package/locale-data/smj.js +1 -1
- package/locale-data/smn.js +1 -1
- package/locale-data/sms.js +1 -1
- package/locale-data/sn.js +1 -1
- package/locale-data/so.js +1 -1
- package/locale-data/sq.js +1 -1
- package/locale-data/sr.js +1 -1
- package/locale-data/ss.js +1 -1
- package/locale-data/ssy.js +1 -1
- package/locale-data/st.js +1 -1
- package/locale-data/sv.js +1 -1
- package/locale-data/sw.js +1 -1
- package/locale-data/syr.js +1 -1
- package/locale-data/ta.js +1 -1
- package/locale-data/te.js +1 -1
- package/locale-data/teo.js +1 -1
- package/locale-data/tg.js +1 -0
- package/locale-data/th.js +1 -1
- package/locale-data/ti.js +1 -1
- package/locale-data/tig.js +1 -1
- package/locale-data/tk.js +1 -1
- package/locale-data/tl.js +1 -1
- package/locale-data/tn.js +1 -1
- package/locale-data/to.js +1 -1
- package/locale-data/tr.js +1 -1
- package/locale-data/ts.js +1 -1
- package/locale-data/tt.js +1 -0
- package/locale-data/twq.js +1 -1
- package/locale-data/tzm.js +1 -1
- package/locale-data/ug.js +1 -1
- package/locale-data/uk.js +1 -1
- package/locale-data/ur.js +1 -1
- package/locale-data/uz.js +1 -1
- package/locale-data/vai.js +1 -1
- package/locale-data/ve.js +1 -1
- package/locale-data/vi.js +1 -1
- package/locale-data/vo.js +1 -1
- package/locale-data/vun.js +1 -1
- package/locale-data/wa.js +1 -1
- package/locale-data/wae.js +1 -1
- package/locale-data/wo.js +1 -1
- package/locale-data/xh.js +1 -1
- package/locale-data/xog.js +1 -1
- package/locale-data/yav.js +1 -1
- package/locale-data/yi.js +1 -1
- package/locale-data/yo.js +1 -1
- package/locale-data/yue.js +1 -1
- package/locale-data/zgh.js +1 -1
- package/locale-data/zh.js +1 -1
- package/locale-data/zu.js +1 -1
- package/package.json +2 -2
- package/src/components/provider.js +16 -8
- package/src/en.js +1 -1
- package/src/format.js +55 -57
- package/src/inject.js +2 -2
- package/src/types.js +2 -0
- package/src/utils.js +11 -0
- package/yarn.lock +19 -15
package/lib/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2019, Yahoo Inc.
|
|
3
3
|
* Copyrights licensed under the New BSD License.
|
|
4
4
|
* See the accompanying LICENSE file for terms.
|
|
5
5
|
*/
|
|
@@ -20,7 +20,7 @@ var defaultLocaleData = { "locale": "en", "pluralRuleFunction": function pluralR
|
|
|
20
20
|
t0 = Number(s[0]) == n,
|
|
21
21
|
n10 = t0 && s[0].slice(-1),
|
|
22
22
|
n100 = t0 && s[0].slice(-2);if (ord) return n10 == 1 && n100 != 11 ? "one" : n10 == 2 && n100 != 12 ? "two" : n10 == 3 && n100 != 13 ? "few" : "other";return n == 1 && v0 ? "one" : "other";
|
|
23
|
-
}, "fields": { "year": { "displayName": "year", "relative": { "0": "this year", "1": "next year", "-1": "last year" }, "relativeTime": { "future": { "one": "in {0} year", "other": "in {0} years" }, "past": { "one": "{0} year ago", "other": "{0} years ago" } } }, "month": { "displayName": "month", "relative": { "0": "this month", "1": "next month", "-1": "last month" }, "relativeTime": { "future": { "one": "in {0} month", "other": "in {0} months" }, "past": { "one": "{0} month ago", "other": "{0} months ago" } } }, "day": { "displayName": "day", "relative": { "0": "today", "1": "tomorrow", "-1": "yesterday" }, "relativeTime": { "future": { "one": "in {0} day", "other": "in {0} days" }, "past": { "one": "{0} day ago", "other": "{0} days ago" } } }, "hour": { "displayName": "hour", "relative": { "0": "this hour" }, "relativeTime": { "future": { "one": "in {0} hour", "other": "in {0} hours" }, "past": { "one": "{0} hour ago", "other": "{0} hours ago" } } }, "minute": { "displayName": "minute", "relative": { "0": "this minute" }, "relativeTime": { "future": { "one": "in {0} minute", "other": "in {0} minutes" }, "past": { "one": "{0} minute ago", "other": "{0} minutes ago" } } }, "second": { "displayName": "second", "relative": { "0": "now" }, "relativeTime": { "future": { "one": "in {0} second", "other": "in {0} seconds" }, "past": { "one": "{0} second ago", "other": "{0} seconds ago" } } } } };
|
|
23
|
+
}, "fields": { "year": { "displayName": "year", "relative": { "0": "this year", "1": "next year", "-1": "last year" }, "relativeTime": { "future": { "one": "in {0} year", "other": "in {0} years" }, "past": { "one": "{0} year ago", "other": "{0} years ago" } } }, "year-short": { "displayName": "yr.", "relative": { "0": "this yr.", "1": "next yr.", "-1": "last yr." }, "relativeTime": { "future": { "one": "in {0} yr.", "other": "in {0} yr." }, "past": { "one": "{0} yr. ago", "other": "{0} yr. ago" } } }, "month": { "displayName": "month", "relative": { "0": "this month", "1": "next month", "-1": "last month" }, "relativeTime": { "future": { "one": "in {0} month", "other": "in {0} months" }, "past": { "one": "{0} month ago", "other": "{0} months ago" } } }, "month-short": { "displayName": "mo.", "relative": { "0": "this mo.", "1": "next mo.", "-1": "last mo." }, "relativeTime": { "future": { "one": "in {0} mo.", "other": "in {0} mo." }, "past": { "one": "{0} mo. ago", "other": "{0} mo. ago" } } }, "day": { "displayName": "day", "relative": { "0": "today", "1": "tomorrow", "-1": "yesterday" }, "relativeTime": { "future": { "one": "in {0} day", "other": "in {0} days" }, "past": { "one": "{0} day ago", "other": "{0} days ago" } } }, "day-short": { "displayName": "day", "relative": { "0": "today", "1": "tomorrow", "-1": "yesterday" }, "relativeTime": { "future": { "one": "in {0} day", "other": "in {0} days" }, "past": { "one": "{0} day ago", "other": "{0} days ago" } } }, "hour": { "displayName": "hour", "relative": { "0": "this hour" }, "relativeTime": { "future": { "one": "in {0} hour", "other": "in {0} hours" }, "past": { "one": "{0} hour ago", "other": "{0} hours ago" } } }, "hour-short": { "displayName": "hr.", "relative": { "0": "this hour" }, "relativeTime": { "future": { "one": "in {0} hr.", "other": "in {0} hr." }, "past": { "one": "{0} hr. ago", "other": "{0} hr. ago" } } }, "minute": { "displayName": "minute", "relative": { "0": "this minute" }, "relativeTime": { "future": { "one": "in {0} minute", "other": "in {0} minutes" }, "past": { "one": "{0} minute ago", "other": "{0} minutes ago" } } }, "minute-short": { "displayName": "min.", "relative": { "0": "this minute" }, "relativeTime": { "future": { "one": "in {0} min.", "other": "in {0} min." }, "past": { "one": "{0} min. ago", "other": "{0} min. ago" } } }, "second": { "displayName": "second", "relative": { "0": "now" }, "relativeTime": { "future": { "one": "in {0} second", "other": "in {0} seconds" }, "past": { "one": "{0} second ago", "other": "{0} seconds ago" } } }, "second-short": { "displayName": "sec.", "relative": { "0": "now" }, "relativeTime": { "future": { "one": "in {0} sec.", "other": "in {0} sec." }, "past": { "one": "{0} sec. ago", "other": "{0} sec. ago" } } } } };
|
|
24
24
|
|
|
25
25
|
/*
|
|
26
26
|
* Copyright 2015, Yahoo Inc.
|
|
@@ -348,7 +348,9 @@ var intlConfigPropTypes = {
|
|
|
348
348
|
textComponent: any,
|
|
349
349
|
|
|
350
350
|
defaultLocale: string,
|
|
351
|
-
defaultFormats: object
|
|
351
|
+
defaultFormats: object,
|
|
352
|
+
|
|
353
|
+
onError: func
|
|
352
354
|
};
|
|
353
355
|
|
|
354
356
|
var intlFormatPropTypes = {
|
|
@@ -506,6 +508,17 @@ function shouldIntlComponentUpdate(_ref2, nextProps, nextState) {
|
|
|
506
508
|
return !shallowEquals(nextProps, props) || !shallowEquals(nextState, state) || !(nextIntl === intl || shallowEquals(filterProps(nextIntl, intlConfigPropNames), filterProps(intl, intlConfigPropNames)));
|
|
507
509
|
}
|
|
508
510
|
|
|
511
|
+
function createError(message, exception) {
|
|
512
|
+
var eMsg = exception ? '\n' + exception : '';
|
|
513
|
+
return '[React Intl] ' + message + eMsg;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
function defaultErrorHandler(error) {
|
|
517
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
518
|
+
console.error(error);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
|
|
509
522
|
/*
|
|
510
523
|
* Copyright 2015, Yahoo Inc.
|
|
511
524
|
* Copyrights licensed under the New BSD License.
|
|
@@ -543,13 +556,17 @@ function injectIntl(WrappedComponent) {
|
|
|
543
556
|
value: function getWrappedInstance() {
|
|
544
557
|
invariant(withRef, '[React Intl] To access the wrapped instance, ' + 'the `{withRef: true}` option must be set when calling: ' + '`injectIntl()`');
|
|
545
558
|
|
|
546
|
-
return this.
|
|
559
|
+
return this._wrappedInstance;
|
|
547
560
|
}
|
|
548
561
|
}, {
|
|
549
562
|
key: 'render',
|
|
550
563
|
value: function render() {
|
|
564
|
+
var _this2 = this;
|
|
565
|
+
|
|
551
566
|
return React.createElement(WrappedComponent, _extends({}, this.props, defineProperty({}, intlPropName, this.context.intl), {
|
|
552
|
-
ref: withRef ?
|
|
567
|
+
ref: withRef ? /* istanbul ignore next */function (ref) {
|
|
568
|
+
return _this2._wrappedInstance = ref;
|
|
569
|
+
} : null
|
|
553
570
|
}));
|
|
554
571
|
}
|
|
555
572
|
}]);
|
|
@@ -624,8 +641,7 @@ var RELATIVE_FORMAT_THRESHOLDS = {
|
|
|
624
641
|
minute: 60, // minutes to hour
|
|
625
642
|
hour: 24, // hours to day
|
|
626
643
|
day: 30, // days to month
|
|
627
|
-
month: 12
|
|
628
|
-
};
|
|
644
|
+
month: 12 };
|
|
629
645
|
|
|
630
646
|
function updateRelativeFormatThresholds(newThresholds) {
|
|
631
647
|
var thresholds = IntlRelativeFormat.thresholds;
|
|
@@ -641,15 +657,13 @@ function updateRelativeFormatThresholds(newThresholds) {
|
|
|
641
657
|
thresholds['month-short'] = newThresholds['month-short'];
|
|
642
658
|
}
|
|
643
659
|
|
|
644
|
-
function getNamedFormat(formats, type, name) {
|
|
660
|
+
function getNamedFormat(formats, type, name, onError) {
|
|
645
661
|
var format = formats && formats[type] && formats[type][name];
|
|
646
662
|
if (format) {
|
|
647
663
|
return format;
|
|
648
664
|
}
|
|
649
665
|
|
|
650
|
-
|
|
651
|
-
console.error('[React Intl] No ' + type + ' format named: ' + name);
|
|
652
|
-
}
|
|
666
|
+
onError(createError('No ' + type + ' format named: ' + name));
|
|
653
667
|
}
|
|
654
668
|
|
|
655
669
|
function formatDate(config, state, value) {
|
|
@@ -660,16 +674,15 @@ function formatDate(config, state, value) {
|
|
|
660
674
|
var format = options.format;
|
|
661
675
|
|
|
662
676
|
|
|
677
|
+
var onError = config.onError || defaultErrorHandler;
|
|
663
678
|
var date = new Date(value);
|
|
664
|
-
var defaults$$1 = _extends({}, timeZone && { timeZone: timeZone }, format && getNamedFormat(formats, 'date', format));
|
|
679
|
+
var defaults$$1 = _extends({}, timeZone && { timeZone: timeZone }, format && getNamedFormat(formats, 'date', format, onError));
|
|
665
680
|
var filteredOptions = filterProps(options, DATE_TIME_FORMAT_OPTIONS, defaults$$1);
|
|
666
681
|
|
|
667
682
|
try {
|
|
668
683
|
return state.getDateTimeFormat(locale, filteredOptions).format(date);
|
|
669
684
|
} catch (e) {
|
|
670
|
-
|
|
671
|
-
console.error('[React Intl] Error formatting date.\n' + e);
|
|
672
|
-
}
|
|
685
|
+
onError(createError('Error formatting date.', e));
|
|
673
686
|
}
|
|
674
687
|
|
|
675
688
|
return String(date);
|
|
@@ -683,8 +696,9 @@ function formatTime(config, state, value) {
|
|
|
683
696
|
var format = options.format;
|
|
684
697
|
|
|
685
698
|
|
|
699
|
+
var onError = config.onError || defaultErrorHandler;
|
|
686
700
|
var date = new Date(value);
|
|
687
|
-
var defaults$$1 = _extends({}, timeZone && { timeZone: timeZone }, format && getNamedFormat(formats, 'time', format));
|
|
701
|
+
var defaults$$1 = _extends({}, timeZone && { timeZone: timeZone }, format && getNamedFormat(formats, 'time', format, onError));
|
|
688
702
|
var filteredOptions = filterProps(options, DATE_TIME_FORMAT_OPTIONS, defaults$$1);
|
|
689
703
|
|
|
690
704
|
if (!filteredOptions.hour && !filteredOptions.minute && !filteredOptions.second) {
|
|
@@ -695,9 +709,7 @@ function formatTime(config, state, value) {
|
|
|
695
709
|
try {
|
|
696
710
|
return state.getDateTimeFormat(locale, filteredOptions).format(date);
|
|
697
711
|
} catch (e) {
|
|
698
|
-
|
|
699
|
-
console.error('[React Intl] Error formatting time.\n' + e);
|
|
700
|
-
}
|
|
712
|
+
onError(createError('Error formatting time.', e));
|
|
701
713
|
}
|
|
702
714
|
|
|
703
715
|
return String(date);
|
|
@@ -710,9 +722,10 @@ function formatRelative(config, state, value) {
|
|
|
710
722
|
var format = options.format;
|
|
711
723
|
|
|
712
724
|
|
|
725
|
+
var onError = config.onError || defaultErrorHandler;
|
|
713
726
|
var date = new Date(value);
|
|
714
727
|
var now = new Date(options.now);
|
|
715
|
-
var defaults$$1 = format && getNamedFormat(formats, 'relative', format);
|
|
728
|
+
var defaults$$1 = format && getNamedFormat(formats, 'relative', format, onError);
|
|
716
729
|
var filteredOptions = filterProps(options, RELATIVE_FORMAT_OPTIONS, defaults$$1);
|
|
717
730
|
|
|
718
731
|
// Capture the current threshold values, then temporarily override them with
|
|
@@ -725,9 +738,7 @@ function formatRelative(config, state, value) {
|
|
|
725
738
|
now: isFinite(now) ? now : state.now()
|
|
726
739
|
});
|
|
727
740
|
} catch (e) {
|
|
728
|
-
|
|
729
|
-
console.error('[React Intl] Error formatting relative time.\n' + e);
|
|
730
|
-
}
|
|
741
|
+
onError(createError('Error formatting relative time.', e));
|
|
731
742
|
} finally {
|
|
732
743
|
updateRelativeFormatThresholds(oldThresholds);
|
|
733
744
|
}
|
|
@@ -742,15 +753,14 @@ function formatNumber(config, state, value) {
|
|
|
742
753
|
var format = options.format;
|
|
743
754
|
|
|
744
755
|
|
|
745
|
-
var
|
|
756
|
+
var onError = config.onError || defaultErrorHandler;
|
|
757
|
+
var defaults$$1 = format && getNamedFormat(formats, 'number', format, onError);
|
|
746
758
|
var filteredOptions = filterProps(options, NUMBER_FORMAT_OPTIONS, defaults$$1);
|
|
747
759
|
|
|
748
760
|
try {
|
|
749
761
|
return state.getNumberFormat(locale, filteredOptions).format(value);
|
|
750
762
|
} catch (e) {
|
|
751
|
-
|
|
752
|
-
console.error('[React Intl] Error formatting number.\n' + e);
|
|
753
|
-
}
|
|
763
|
+
onError(createError('Error formatting number.', e));
|
|
754
764
|
}
|
|
755
765
|
|
|
756
766
|
return String(value);
|
|
@@ -762,13 +772,12 @@ function formatPlural(config, state, value) {
|
|
|
762
772
|
|
|
763
773
|
|
|
764
774
|
var filteredOptions = filterProps(options, PLURAL_FORMAT_OPTIONS);
|
|
775
|
+
var onError = config.onError || defaultErrorHandler;
|
|
765
776
|
|
|
766
777
|
try {
|
|
767
778
|
return state.getPluralFormat(locale, filteredOptions).format(value);
|
|
768
779
|
} catch (e) {
|
|
769
|
-
|
|
770
|
-
console.error('[React Intl] Error formatting plural.\n' + e);
|
|
771
|
-
}
|
|
780
|
+
onError(createError('Error formatting plural.', e));
|
|
772
781
|
}
|
|
773
782
|
|
|
774
783
|
return 'other';
|
|
@@ -785,8 +794,13 @@ function formatMessage(config, state) {
|
|
|
785
794
|
var id = messageDescriptor.id,
|
|
786
795
|
defaultMessage = messageDescriptor.defaultMessage;
|
|
787
796
|
|
|
788
|
-
//
|
|
797
|
+
// Produce a better error if the user calls `intl.formatMessage(element)`
|
|
789
798
|
|
|
799
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
800
|
+
invariant(!isValidElement(config), '[React Intl] Don\'t pass React elements to ' + 'formatMessage(), pass `.props`.');
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
// `id` is a required field of a Message Descriptor.
|
|
790
804
|
invariant(id, '[React Intl] An `id` must be provided to format a message.');
|
|
791
805
|
|
|
792
806
|
var message = messages && messages[id];
|
|
@@ -799,6 +813,7 @@ function formatMessage(config, state) {
|
|
|
799
813
|
}
|
|
800
814
|
|
|
801
815
|
var formattedMessage = void 0;
|
|
816
|
+
var onError = config.onError || defaultErrorHandler;
|
|
802
817
|
|
|
803
818
|
if (message) {
|
|
804
819
|
try {
|
|
@@ -806,18 +821,14 @@ function formatMessage(config, state) {
|
|
|
806
821
|
|
|
807
822
|
formattedMessage = formatter.format(values);
|
|
808
823
|
} catch (e) {
|
|
809
|
-
|
|
810
|
-
console.error('[React Intl] Error formatting message: "' + id + '" for locale: "' + locale + '"' + (defaultMessage ? ', using default message as fallback.' : '') + ('\n' + e));
|
|
811
|
-
}
|
|
824
|
+
onError(createError('Error formatting message: "' + id + '" for locale: "' + locale + '"' + (defaultMessage ? ', using default message as fallback.' : ''), e));
|
|
812
825
|
}
|
|
813
826
|
} else {
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
console.error('[React Intl] Missing message: "' + id + '" for locale: "' + locale + '"' + (defaultMessage ? ', using default message as fallback.' : ''));
|
|
820
|
-
}
|
|
827
|
+
// This prevents warnings from littering the console in development
|
|
828
|
+
// when no `messages` are passed into the <IntlProvider> for the
|
|
829
|
+
// default locale, and a default message is in the source.
|
|
830
|
+
if (!defaultMessage || locale && locale.toLowerCase() !== defaultLocale.toLowerCase()) {
|
|
831
|
+
onError(createError('Missing message: "' + id + '" for locale: "' + locale + '"' + (defaultMessage ? ', using default message as fallback.' : '')));
|
|
821
832
|
}
|
|
822
833
|
}
|
|
823
834
|
|
|
@@ -827,16 +838,12 @@ function formatMessage(config, state) {
|
|
|
827
838
|
|
|
828
839
|
formattedMessage = _formatter.format(values);
|
|
829
840
|
} catch (e) {
|
|
830
|
-
|
|
831
|
-
console.error('[React Intl] Error formatting the default message for: "' + id + '"' + ('\n' + e));
|
|
832
|
-
}
|
|
841
|
+
onError(createError('Error formatting the default message for: "' + id + '"', e));
|
|
833
842
|
}
|
|
834
843
|
}
|
|
835
844
|
|
|
836
845
|
if (!formattedMessage) {
|
|
837
|
-
|
|
838
|
-
console.error('[React Intl] Cannot format message: "' + id + '", ' + ('using message ' + (message || defaultMessage ? 'source' : 'id') + ' as fallback.'));
|
|
839
|
-
}
|
|
846
|
+
onError(createError('Cannot format message: "' + id + '", ' + ('using message ' + (message || defaultMessage ? 'source' : 'id') + ' as fallback.')));
|
|
840
847
|
}
|
|
841
848
|
|
|
842
849
|
return formattedMessage || message || defaultMessage || id;
|
|
@@ -887,7 +894,9 @@ var defaultProps = {
|
|
|
887
894
|
textComponent: 'span',
|
|
888
895
|
|
|
889
896
|
defaultLocale: 'en',
|
|
890
|
-
defaultFormats: {}
|
|
897
|
+
defaultFormats: {},
|
|
898
|
+
|
|
899
|
+
onError: defaultErrorHandler
|
|
891
900
|
};
|
|
892
901
|
|
|
893
902
|
var IntlProvider = function (_Component) {
|
|
@@ -964,12 +973,11 @@ var IntlProvider = function (_Component) {
|
|
|
964
973
|
var _config = config,
|
|
965
974
|
locale = _config.locale,
|
|
966
975
|
defaultLocale = _config.defaultLocale,
|
|
967
|
-
defaultFormats = _config.defaultFormats
|
|
976
|
+
defaultFormats = _config.defaultFormats,
|
|
977
|
+
onError = _config.onError;
|
|
968
978
|
|
|
969
979
|
|
|
970
|
-
|
|
971
|
-
console.error('[React Intl] Missing locale data for locale: "' + locale + '". ' + ('Using default locale: "' + defaultLocale + '" as fallback.'));
|
|
972
|
-
}
|
|
980
|
+
onError(createError('Missing locale data for locale: "' + locale + '". ' + ('Using default locale: "' + defaultLocale + '" as fallback.')));
|
|
973
981
|
|
|
974
982
|
// Since there's no registered locale data for `locale`, this will
|
|
975
983
|
// fallback to the `defaultLocale` to make sure things can render.
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2019, Yahoo Inc.
|
|
3
3
|
* Copyrights licensed under the New BSD License.
|
|
4
4
|
* See the accompanying LICENSE file for terms.
|
|
5
5
|
*/
|
|
@@ -27,7 +27,7 @@ var defaultLocaleData = { "locale": "en", "pluralRuleFunction": function pluralR
|
|
|
27
27
|
t0 = Number(s[0]) == n,
|
|
28
28
|
n10 = t0 && s[0].slice(-1),
|
|
29
29
|
n100 = t0 && s[0].slice(-2);if (ord) return n10 == 1 && n100 != 11 ? "one" : n10 == 2 && n100 != 12 ? "two" : n10 == 3 && n100 != 13 ? "few" : "other";return n == 1 && v0 ? "one" : "other";
|
|
30
|
-
}, "fields": { "year": { "displayName": "year", "relative": { "0": "this year", "1": "next year", "-1": "last year" }, "relativeTime": { "future": { "one": "in {0} year", "other": "in {0} years" }, "past": { "one": "{0} year ago", "other": "{0} years ago" } } }, "month": { "displayName": "month", "relative": { "0": "this month", "1": "next month", "-1": "last month" }, "relativeTime": { "future": { "one": "in {0} month", "other": "in {0} months" }, "past": { "one": "{0} month ago", "other": "{0} months ago" } } }, "day": { "displayName": "day", "relative": { "0": "today", "1": "tomorrow", "-1": "yesterday" }, "relativeTime": { "future": { "one": "in {0} day", "other": "in {0} days" }, "past": { "one": "{0} day ago", "other": "{0} days ago" } } }, "hour": { "displayName": "hour", "relative": { "0": "this hour" }, "relativeTime": { "future": { "one": "in {0} hour", "other": "in {0} hours" }, "past": { "one": "{0} hour ago", "other": "{0} hours ago" } } }, "minute": { "displayName": "minute", "relative": { "0": "this minute" }, "relativeTime": { "future": { "one": "in {0} minute", "other": "in {0} minutes" }, "past": { "one": "{0} minute ago", "other": "{0} minutes ago" } } }, "second": { "displayName": "second", "relative": { "0": "now" }, "relativeTime": { "future": { "one": "in {0} second", "other": "in {0} seconds" }, "past": { "one": "{0} second ago", "other": "{0} seconds ago" } } } } };
|
|
30
|
+
}, "fields": { "year": { "displayName": "year", "relative": { "0": "this year", "1": "next year", "-1": "last year" }, "relativeTime": { "future": { "one": "in {0} year", "other": "in {0} years" }, "past": { "one": "{0} year ago", "other": "{0} years ago" } } }, "year-short": { "displayName": "yr.", "relative": { "0": "this yr.", "1": "next yr.", "-1": "last yr." }, "relativeTime": { "future": { "one": "in {0} yr.", "other": "in {0} yr." }, "past": { "one": "{0} yr. ago", "other": "{0} yr. ago" } } }, "month": { "displayName": "month", "relative": { "0": "this month", "1": "next month", "-1": "last month" }, "relativeTime": { "future": { "one": "in {0} month", "other": "in {0} months" }, "past": { "one": "{0} month ago", "other": "{0} months ago" } } }, "month-short": { "displayName": "mo.", "relative": { "0": "this mo.", "1": "next mo.", "-1": "last mo." }, "relativeTime": { "future": { "one": "in {0} mo.", "other": "in {0} mo." }, "past": { "one": "{0} mo. ago", "other": "{0} mo. ago" } } }, "day": { "displayName": "day", "relative": { "0": "today", "1": "tomorrow", "-1": "yesterday" }, "relativeTime": { "future": { "one": "in {0} day", "other": "in {0} days" }, "past": { "one": "{0} day ago", "other": "{0} days ago" } } }, "day-short": { "displayName": "day", "relative": { "0": "today", "1": "tomorrow", "-1": "yesterday" }, "relativeTime": { "future": { "one": "in {0} day", "other": "in {0} days" }, "past": { "one": "{0} day ago", "other": "{0} days ago" } } }, "hour": { "displayName": "hour", "relative": { "0": "this hour" }, "relativeTime": { "future": { "one": "in {0} hour", "other": "in {0} hours" }, "past": { "one": "{0} hour ago", "other": "{0} hours ago" } } }, "hour-short": { "displayName": "hr.", "relative": { "0": "this hour" }, "relativeTime": { "future": { "one": "in {0} hr.", "other": "in {0} hr." }, "past": { "one": "{0} hr. ago", "other": "{0} hr. ago" } } }, "minute": { "displayName": "minute", "relative": { "0": "this minute" }, "relativeTime": { "future": { "one": "in {0} minute", "other": "in {0} minutes" }, "past": { "one": "{0} minute ago", "other": "{0} minutes ago" } } }, "minute-short": { "displayName": "min.", "relative": { "0": "this minute" }, "relativeTime": { "future": { "one": "in {0} min.", "other": "in {0} min." }, "past": { "one": "{0} min. ago", "other": "{0} min. ago" } } }, "second": { "displayName": "second", "relative": { "0": "now" }, "relativeTime": { "future": { "one": "in {0} second", "other": "in {0} seconds" }, "past": { "one": "{0} second ago", "other": "{0} seconds ago" } } }, "second-short": { "displayName": "sec.", "relative": { "0": "now" }, "relativeTime": { "future": { "one": "in {0} sec.", "other": "in {0} sec." }, "past": { "one": "{0} sec. ago", "other": "{0} sec. ago" } } } } };
|
|
31
31
|
|
|
32
32
|
/*
|
|
33
33
|
* Copyright 2015, Yahoo Inc.
|
|
@@ -355,7 +355,9 @@ var intlConfigPropTypes = {
|
|
|
355
355
|
textComponent: any,
|
|
356
356
|
|
|
357
357
|
defaultLocale: string,
|
|
358
|
-
defaultFormats: object
|
|
358
|
+
defaultFormats: object,
|
|
359
|
+
|
|
360
|
+
onError: func
|
|
359
361
|
};
|
|
360
362
|
|
|
361
363
|
var intlFormatPropTypes = {
|
|
@@ -513,6 +515,17 @@ function shouldIntlComponentUpdate(_ref2, nextProps, nextState) {
|
|
|
513
515
|
return !shallowEquals(nextProps, props) || !shallowEquals(nextState, state) || !(nextIntl === intl || shallowEquals(filterProps(nextIntl, intlConfigPropNames), filterProps(intl, intlConfigPropNames)));
|
|
514
516
|
}
|
|
515
517
|
|
|
518
|
+
function createError(message, exception) {
|
|
519
|
+
var eMsg = exception ? '\n' + exception : '';
|
|
520
|
+
return '[React Intl] ' + message + eMsg;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
function defaultErrorHandler(error) {
|
|
524
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
525
|
+
console.error(error);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
516
529
|
/*
|
|
517
530
|
* Copyright 2015, Yahoo Inc.
|
|
518
531
|
* Copyrights licensed under the New BSD License.
|
|
@@ -550,13 +563,17 @@ function injectIntl(WrappedComponent) {
|
|
|
550
563
|
value: function getWrappedInstance() {
|
|
551
564
|
invariant(withRef, '[React Intl] To access the wrapped instance, ' + 'the `{withRef: true}` option must be set when calling: ' + '`injectIntl()`');
|
|
552
565
|
|
|
553
|
-
return this.
|
|
566
|
+
return this._wrappedInstance;
|
|
554
567
|
}
|
|
555
568
|
}, {
|
|
556
569
|
key: 'render',
|
|
557
570
|
value: function render() {
|
|
571
|
+
var _this2 = this;
|
|
572
|
+
|
|
558
573
|
return React__default.createElement(WrappedComponent, _extends({}, this.props, defineProperty({}, intlPropName, this.context.intl), {
|
|
559
|
-
ref: withRef ?
|
|
574
|
+
ref: withRef ? /* istanbul ignore next */function (ref) {
|
|
575
|
+
return _this2._wrappedInstance = ref;
|
|
576
|
+
} : null
|
|
560
577
|
}));
|
|
561
578
|
}
|
|
562
579
|
}]);
|
|
@@ -631,8 +648,7 @@ var RELATIVE_FORMAT_THRESHOLDS = {
|
|
|
631
648
|
minute: 60, // minutes to hour
|
|
632
649
|
hour: 24, // hours to day
|
|
633
650
|
day: 30, // days to month
|
|
634
|
-
month: 12
|
|
635
|
-
};
|
|
651
|
+
month: 12 };
|
|
636
652
|
|
|
637
653
|
function updateRelativeFormatThresholds(newThresholds) {
|
|
638
654
|
var thresholds = IntlRelativeFormat.thresholds;
|
|
@@ -648,15 +664,13 @@ function updateRelativeFormatThresholds(newThresholds) {
|
|
|
648
664
|
thresholds['month-short'] = newThresholds['month-short'];
|
|
649
665
|
}
|
|
650
666
|
|
|
651
|
-
function getNamedFormat(formats, type, name) {
|
|
667
|
+
function getNamedFormat(formats, type, name, onError) {
|
|
652
668
|
var format = formats && formats[type] && formats[type][name];
|
|
653
669
|
if (format) {
|
|
654
670
|
return format;
|
|
655
671
|
}
|
|
656
672
|
|
|
657
|
-
|
|
658
|
-
console.error('[React Intl] No ' + type + ' format named: ' + name);
|
|
659
|
-
}
|
|
673
|
+
onError(createError('No ' + type + ' format named: ' + name));
|
|
660
674
|
}
|
|
661
675
|
|
|
662
676
|
function formatDate(config, state, value) {
|
|
@@ -667,16 +681,15 @@ function formatDate(config, state, value) {
|
|
|
667
681
|
var format = options.format;
|
|
668
682
|
|
|
669
683
|
|
|
684
|
+
var onError = config.onError || defaultErrorHandler;
|
|
670
685
|
var date = new Date(value);
|
|
671
|
-
var defaults$$1 = _extends({}, timeZone && { timeZone: timeZone }, format && getNamedFormat(formats, 'date', format));
|
|
686
|
+
var defaults$$1 = _extends({}, timeZone && { timeZone: timeZone }, format && getNamedFormat(formats, 'date', format, onError));
|
|
672
687
|
var filteredOptions = filterProps(options, DATE_TIME_FORMAT_OPTIONS, defaults$$1);
|
|
673
688
|
|
|
674
689
|
try {
|
|
675
690
|
return state.getDateTimeFormat(locale, filteredOptions).format(date);
|
|
676
691
|
} catch (e) {
|
|
677
|
-
|
|
678
|
-
console.error('[React Intl] Error formatting date.\n' + e);
|
|
679
|
-
}
|
|
692
|
+
onError(createError('Error formatting date.', e));
|
|
680
693
|
}
|
|
681
694
|
|
|
682
695
|
return String(date);
|
|
@@ -690,8 +703,9 @@ function formatTime(config, state, value) {
|
|
|
690
703
|
var format = options.format;
|
|
691
704
|
|
|
692
705
|
|
|
706
|
+
var onError = config.onError || defaultErrorHandler;
|
|
693
707
|
var date = new Date(value);
|
|
694
|
-
var defaults$$1 = _extends({}, timeZone && { timeZone: timeZone }, format && getNamedFormat(formats, 'time', format));
|
|
708
|
+
var defaults$$1 = _extends({}, timeZone && { timeZone: timeZone }, format && getNamedFormat(formats, 'time', format, onError));
|
|
695
709
|
var filteredOptions = filterProps(options, DATE_TIME_FORMAT_OPTIONS, defaults$$1);
|
|
696
710
|
|
|
697
711
|
if (!filteredOptions.hour && !filteredOptions.minute && !filteredOptions.second) {
|
|
@@ -702,9 +716,7 @@ function formatTime(config, state, value) {
|
|
|
702
716
|
try {
|
|
703
717
|
return state.getDateTimeFormat(locale, filteredOptions).format(date);
|
|
704
718
|
} catch (e) {
|
|
705
|
-
|
|
706
|
-
console.error('[React Intl] Error formatting time.\n' + e);
|
|
707
|
-
}
|
|
719
|
+
onError(createError('Error formatting time.', e));
|
|
708
720
|
}
|
|
709
721
|
|
|
710
722
|
return String(date);
|
|
@@ -717,9 +729,10 @@ function formatRelative(config, state, value) {
|
|
|
717
729
|
var format = options.format;
|
|
718
730
|
|
|
719
731
|
|
|
732
|
+
var onError = config.onError || defaultErrorHandler;
|
|
720
733
|
var date = new Date(value);
|
|
721
734
|
var now = new Date(options.now);
|
|
722
|
-
var defaults$$1 = format && getNamedFormat(formats, 'relative', format);
|
|
735
|
+
var defaults$$1 = format && getNamedFormat(formats, 'relative', format, onError);
|
|
723
736
|
var filteredOptions = filterProps(options, RELATIVE_FORMAT_OPTIONS, defaults$$1);
|
|
724
737
|
|
|
725
738
|
// Capture the current threshold values, then temporarily override them with
|
|
@@ -732,9 +745,7 @@ function formatRelative(config, state, value) {
|
|
|
732
745
|
now: isFinite(now) ? now : state.now()
|
|
733
746
|
});
|
|
734
747
|
} catch (e) {
|
|
735
|
-
|
|
736
|
-
console.error('[React Intl] Error formatting relative time.\n' + e);
|
|
737
|
-
}
|
|
748
|
+
onError(createError('Error formatting relative time.', e));
|
|
738
749
|
} finally {
|
|
739
750
|
updateRelativeFormatThresholds(oldThresholds);
|
|
740
751
|
}
|
|
@@ -749,15 +760,14 @@ function formatNumber(config, state, value) {
|
|
|
749
760
|
var format = options.format;
|
|
750
761
|
|
|
751
762
|
|
|
752
|
-
var
|
|
763
|
+
var onError = config.onError || defaultErrorHandler;
|
|
764
|
+
var defaults$$1 = format && getNamedFormat(formats, 'number', format, onError);
|
|
753
765
|
var filteredOptions = filterProps(options, NUMBER_FORMAT_OPTIONS, defaults$$1);
|
|
754
766
|
|
|
755
767
|
try {
|
|
756
768
|
return state.getNumberFormat(locale, filteredOptions).format(value);
|
|
757
769
|
} catch (e) {
|
|
758
|
-
|
|
759
|
-
console.error('[React Intl] Error formatting number.\n' + e);
|
|
760
|
-
}
|
|
770
|
+
onError(createError('Error formatting number.', e));
|
|
761
771
|
}
|
|
762
772
|
|
|
763
773
|
return String(value);
|
|
@@ -769,13 +779,12 @@ function formatPlural(config, state, value) {
|
|
|
769
779
|
|
|
770
780
|
|
|
771
781
|
var filteredOptions = filterProps(options, PLURAL_FORMAT_OPTIONS);
|
|
782
|
+
var onError = config.onError || defaultErrorHandler;
|
|
772
783
|
|
|
773
784
|
try {
|
|
774
785
|
return state.getPluralFormat(locale, filteredOptions).format(value);
|
|
775
786
|
} catch (e) {
|
|
776
|
-
|
|
777
|
-
console.error('[React Intl] Error formatting plural.\n' + e);
|
|
778
|
-
}
|
|
787
|
+
onError(createError('Error formatting plural.', e));
|
|
779
788
|
}
|
|
780
789
|
|
|
781
790
|
return 'other';
|
|
@@ -792,8 +801,13 @@ function formatMessage(config, state) {
|
|
|
792
801
|
var id = messageDescriptor.id,
|
|
793
802
|
defaultMessage = messageDescriptor.defaultMessage;
|
|
794
803
|
|
|
795
|
-
//
|
|
804
|
+
// Produce a better error if the user calls `intl.formatMessage(element)`
|
|
796
805
|
|
|
806
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
807
|
+
invariant(!React.isValidElement(config), '[React Intl] Don\'t pass React elements to ' + 'formatMessage(), pass `.props`.');
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
// `id` is a required field of a Message Descriptor.
|
|
797
811
|
invariant(id, '[React Intl] An `id` must be provided to format a message.');
|
|
798
812
|
|
|
799
813
|
var message = messages && messages[id];
|
|
@@ -806,6 +820,7 @@ function formatMessage(config, state) {
|
|
|
806
820
|
}
|
|
807
821
|
|
|
808
822
|
var formattedMessage = void 0;
|
|
823
|
+
var onError = config.onError || defaultErrorHandler;
|
|
809
824
|
|
|
810
825
|
if (message) {
|
|
811
826
|
try {
|
|
@@ -813,18 +828,14 @@ function formatMessage(config, state) {
|
|
|
813
828
|
|
|
814
829
|
formattedMessage = formatter.format(values);
|
|
815
830
|
} catch (e) {
|
|
816
|
-
|
|
817
|
-
console.error('[React Intl] Error formatting message: "' + id + '" for locale: "' + locale + '"' + (defaultMessage ? ', using default message as fallback.' : '') + ('\n' + e));
|
|
818
|
-
}
|
|
831
|
+
onError(createError('Error formatting message: "' + id + '" for locale: "' + locale + '"' + (defaultMessage ? ', using default message as fallback.' : ''), e));
|
|
819
832
|
}
|
|
820
833
|
} else {
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
console.error('[React Intl] Missing message: "' + id + '" for locale: "' + locale + '"' + (defaultMessage ? ', using default message as fallback.' : ''));
|
|
827
|
-
}
|
|
834
|
+
// This prevents warnings from littering the console in development
|
|
835
|
+
// when no `messages` are passed into the <IntlProvider> for the
|
|
836
|
+
// default locale, and a default message is in the source.
|
|
837
|
+
if (!defaultMessage || locale && locale.toLowerCase() !== defaultLocale.toLowerCase()) {
|
|
838
|
+
onError(createError('Missing message: "' + id + '" for locale: "' + locale + '"' + (defaultMessage ? ', using default message as fallback.' : '')));
|
|
828
839
|
}
|
|
829
840
|
}
|
|
830
841
|
|
|
@@ -834,16 +845,12 @@ function formatMessage(config, state) {
|
|
|
834
845
|
|
|
835
846
|
formattedMessage = _formatter.format(values);
|
|
836
847
|
} catch (e) {
|
|
837
|
-
|
|
838
|
-
console.error('[React Intl] Error formatting the default message for: "' + id + '"' + ('\n' + e));
|
|
839
|
-
}
|
|
848
|
+
onError(createError('Error formatting the default message for: "' + id + '"', e));
|
|
840
849
|
}
|
|
841
850
|
}
|
|
842
851
|
|
|
843
852
|
if (!formattedMessage) {
|
|
844
|
-
|
|
845
|
-
console.error('[React Intl] Cannot format message: "' + id + '", ' + ('using message ' + (message || defaultMessage ? 'source' : 'id') + ' as fallback.'));
|
|
846
|
-
}
|
|
853
|
+
onError(createError('Cannot format message: "' + id + '", ' + ('using message ' + (message || defaultMessage ? 'source' : 'id') + ' as fallback.')));
|
|
847
854
|
}
|
|
848
855
|
|
|
849
856
|
return formattedMessage || message || defaultMessage || id;
|
|
@@ -894,7 +901,9 @@ var defaultProps = {
|
|
|
894
901
|
textComponent: 'span',
|
|
895
902
|
|
|
896
903
|
defaultLocale: 'en',
|
|
897
|
-
defaultFormats: {}
|
|
904
|
+
defaultFormats: {},
|
|
905
|
+
|
|
906
|
+
onError: defaultErrorHandler
|
|
898
907
|
};
|
|
899
908
|
|
|
900
909
|
var IntlProvider = function (_Component) {
|
|
@@ -971,12 +980,11 @@ var IntlProvider = function (_Component) {
|
|
|
971
980
|
var _config = config,
|
|
972
981
|
locale = _config.locale,
|
|
973
982
|
defaultLocale = _config.defaultLocale,
|
|
974
|
-
defaultFormats = _config.defaultFormats
|
|
983
|
+
defaultFormats = _config.defaultFormats,
|
|
984
|
+
onError = _config.onError;
|
|
975
985
|
|
|
976
986
|
|
|
977
|
-
|
|
978
|
-
console.error('[React Intl] Missing locale data for locale: "' + locale + '". ' + ('Using default locale: "' + defaultLocale + '" as fallback.'));
|
|
979
|
-
}
|
|
987
|
+
onError(createError('Missing locale data for locale: "' + locale + '". ' + ('Using default locale: "' + defaultLocale + '" as fallback.')));
|
|
980
988
|
|
|
981
989
|
// Since there's no registered locale data for `locale`, this will
|
|
982
990
|
// fallback to the `defaultLocale` to make sure things can render.
|
package/locale-data/af.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,a){"object"==typeof exports&&"undefined"!=typeof module?module.exports=a():"function"==typeof define&&define.amd?define(a):(e.ReactIntlLocaleData=e.ReactIntlLocaleData||{},e.ReactIntlLocaleData.af=a())}(this,function(){"use strict";return[{locale:"af",pluralRuleFunction:function(e,a){return a?"other":1==e?"one":"other"},fields:{year:{displayName:"jaar",relative:{0:"hierdie jaar",1:"volgende jaar","-1":"verlede jaar"},relativeTime:{future:{one:"oor {0} jaar",other:"oor {0} jaar"},past:{one:"{0} jaar gelede",other:"{0} jaar gelede"}}},month:{displayName:"maand",relative:{0:"vandeesmaand",1:"volgende maand","-1":"verlede maand"},relativeTime:{future:{one:"oor {0}
|
|
1
|
+
!function(e,a){"object"==typeof exports&&"undefined"!=typeof module?module.exports=a():"function"==typeof define&&define.amd?define(a):(e.ReactIntlLocaleData=e.ReactIntlLocaleData||{},e.ReactIntlLocaleData.af=a())}(this,function(){"use strict";return[{locale:"af",pluralRuleFunction:function(e,a){return a?"other":1==e?"one":"other"},fields:{year:{displayName:"jaar",relative:{0:"hierdie jaar",1:"volgende jaar","-1":"verlede jaar"},relativeTime:{future:{one:"oor {0} jaar",other:"oor {0} jaar"},past:{one:"{0} jaar gelede",other:"{0} jaar gelede"}}},"year-short":{displayName:"j.",relative:{0:"hierdie jaar",1:"volgende jaar","-1":"verlede jaar"},relativeTime:{future:{one:"oor {0} j.",other:"oor {0} j."},past:{one:"{0} j. gelede",other:"{0} j. gelede"}}},month:{displayName:"maand",relative:{0:"vandeesmaand",1:"volgende maand","-1":"verlede maand"},relativeTime:{future:{one:"oor {0} maand",other:"oor {0} maande"},past:{one:"{0} maand gelede",other:"{0} maande gelede"}}},"month-short":{displayName:"md.",relative:{0:"vandeesmaand",1:"volgende maand","-1":"verlede maand"},relativeTime:{future:{one:"oor {0} md.",other:"oor {0} md."},past:{one:"{0} md. gelede",other:"{0} md. gelede"}}},day:{displayName:"dag",relative:{0:"vandag",1:"môre",2:"oormôre","-2":"eergister","-1":"gister"},relativeTime:{future:{one:"oor {0} dag",other:"oor {0} dae"},past:{one:"{0} dag gelede",other:"{0} dae gelede"}}},"day-short":{displayName:"d.",relative:{0:"vandag",1:"môre",2:"oormôre","-2":"eergister","-1":"gister"},relativeTime:{future:{one:"oor {0} dag",other:"oor {0} dae"},past:{one:"{0} dag gelede",other:"{0} dae gelede"}}},hour:{displayName:"uur",relative:{0:"hierdie uur"},relativeTime:{future:{one:"oor {0} uur",other:"oor {0} uur"},past:{one:"{0} uur gelede",other:"{0} uur gelede"}}},"hour-short":{displayName:"u.",relative:{0:"hierdie uur"},relativeTime:{future:{one:"oor {0} u.",other:"oor {0} u."},past:{one:"{0} u. gelede",other:"{0} u. gelede"}}},minute:{displayName:"minuut",relative:{0:"hierdie minuut"},relativeTime:{future:{one:"oor {0} minuut",other:"oor {0} minute"},past:{one:"{0} minuut gelede",other:"{0} minute gelede"}}},"minute-short":{displayName:"min.",relative:{0:"hierdie minuut"},relativeTime:{future:{one:"oor {0} min.",other:"oor {0} min."},past:{one:"{0} min. gelede",other:"{0} min. gelede"}}},second:{displayName:"sekonde",relative:{0:"nou"},relativeTime:{future:{one:"oor {0} sekonde",other:"oor {0} sekondes"},past:{one:"{0} sekonde gelede",other:"{0} sekondes gelede"}}},"second-short":{displayName:"s.",relative:{0:"nou"},relativeTime:{future:{one:"oor {0} s.",other:"oor {0} s."},past:{one:"{0} s. gelede",other:"{0} s. gelede"}}}}},{locale:"af-NA",parentLocale:"af"}]});
|
package/locale-data/agq.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e.ReactIntlLocaleData=e.ReactIntlLocaleData||{},e.ReactIntlLocaleData.agq=t())}(this,function(){"use strict";return[{locale:"agq",pluralRuleFunction:function(e,t){return"other"},fields:{year:{displayName:"kɨnûm",relative:{0:"this year",1:"next year","-1":"last year"},relativeTime:{future:{other:"+{0} y"},past:{other:"-{0} y"}}},month:{displayName:"ndzɔŋ",relative:{0:"this month",1:"next month","-1":"last month"},relativeTime:{future:{other:"+{0} m"},past:{other:"-{0} m"}}},day:{displayName:"utsuʔ",relative:{0:"nɛ",1:"tsʉtsʉ","-1":"ā zūɛɛ"},relativeTime:{future:{other:"+{0} d"},past:{other:"-{0} d"}}},hour:{displayName:"tàm",relative:{0:"this hour"},relativeTime:{future:{other:"+{0} h"},past:{other:"-{0} h"}}},minute:{displayName:"menè",relative:{0:"this minute"},relativeTime:{future:{other:"+{0} min"},past:{other:"-{0} min"}}},second:{displayName:"sɛkɔ̀n",relative:{0:"now"},relativeTime:{future:{other:"+{0} s"},past:{other:"-{0} s"}}}}}]});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e.ReactIntlLocaleData=e.ReactIntlLocaleData||{},e.ReactIntlLocaleData.agq=t())}(this,function(){"use strict";return[{locale:"agq",pluralRuleFunction:function(e,t){return"other"},fields:{year:{displayName:"kɨnûm",relative:{0:"this year",1:"next year","-1":"last year"},relativeTime:{future:{other:"+{0} y"},past:{other:"-{0} y"}}},"year-short":{displayName:"kɨnûm",relative:{0:"this year",1:"next year","-1":"last year"},relativeTime:{future:{other:"+{0} y"},past:{other:"-{0} y"}}},month:{displayName:"ndzɔŋ",relative:{0:"this month",1:"next month","-1":"last month"},relativeTime:{future:{other:"+{0} m"},past:{other:"-{0} m"}}},"month-short":{displayName:"ndzɔŋ",relative:{0:"this month",1:"next month","-1":"last month"},relativeTime:{future:{other:"+{0} m"},past:{other:"-{0} m"}}},day:{displayName:"utsuʔ",relative:{0:"nɛ",1:"tsʉtsʉ","-1":"ā zūɛɛ"},relativeTime:{future:{other:"+{0} d"},past:{other:"-{0} d"}}},"day-short":{displayName:"utsuʔ",relative:{0:"nɛ",1:"tsʉtsʉ","-1":"ā zūɛɛ"},relativeTime:{future:{other:"+{0} d"},past:{other:"-{0} d"}}},hour:{displayName:"tàm",relative:{0:"this hour"},relativeTime:{future:{other:"+{0} h"},past:{other:"-{0} h"}}},"hour-short":{displayName:"tàm",relative:{0:"this hour"},relativeTime:{future:{other:"+{0} h"},past:{other:"-{0} h"}}},minute:{displayName:"menè",relative:{0:"this minute"},relativeTime:{future:{other:"+{0} min"},past:{other:"-{0} min"}}},"minute-short":{displayName:"menè",relative:{0:"this minute"},relativeTime:{future:{other:"+{0} min"},past:{other:"-{0} min"}}},second:{displayName:"sɛkɔ̀n",relative:{0:"now"},relativeTime:{future:{other:"+{0} s"},past:{other:"-{0} s"}}},"second-short":{displayName:"sɛkɔ̀n",relative:{0:"now"},relativeTime:{future:{other:"+{0} s"},past:{other:"-{0} s"}}}}}]});
|
package/locale-data/ak.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e.ReactIntlLocaleData=e.ReactIntlLocaleData||{},e.ReactIntlLocaleData.ak=t())}(this,function(){"use strict";return[{locale:"ak",pluralRuleFunction:function(e,t){return t?"other":0==e||1==e?"one":"other"},fields:{year:{displayName:"Afe",relative:{0:"this year",1:"next year","-1":"last year"},relativeTime:{future:{other:"+{0} y"},past:{other:"-{0} y"}}},month:{displayName:"Bosome",relative:{0:"this month",1:"next month","-1":"last month"},relativeTime:{future:{other:"+{0} m"},past:{other:"-{0} m"}}},day:{displayName:"Da",relative:{0:"Ndɛ",1:"Ɔkyena","-1":"Ndeda"},relativeTime:{future:{other:"+{0} d"},past:{other:"-{0} d"}}},hour:{displayName:"Dɔnhwer",relative:{0:"this hour"},relativeTime:{future:{other:"+{0} h"},past:{other:"-{0} h"}}},minute:{displayName:"Sema",relative:{0:"this minute"},relativeTime:{future:{other:"+{0} min"},past:{other:"-{0} min"}}},second:{displayName:"Sɛkɛnd",relative:{0:"now"},relativeTime:{future:{other:"+{0} s"},past:{other:"-{0} s"}}}}}]});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e.ReactIntlLocaleData=e.ReactIntlLocaleData||{},e.ReactIntlLocaleData.ak=t())}(this,function(){"use strict";return[{locale:"ak",pluralRuleFunction:function(e,t){return t?"other":0==e||1==e?"one":"other"},fields:{year:{displayName:"Afe",relative:{0:"this year",1:"next year","-1":"last year"},relativeTime:{future:{other:"+{0} y"},past:{other:"-{0} y"}}},"year-short":{displayName:"Afe",relative:{0:"this year",1:"next year","-1":"last year"},relativeTime:{future:{other:"+{0} y"},past:{other:"-{0} y"}}},month:{displayName:"Bosome",relative:{0:"this month",1:"next month","-1":"last month"},relativeTime:{future:{other:"+{0} m"},past:{other:"-{0} m"}}},"month-short":{displayName:"Bosome",relative:{0:"this month",1:"next month","-1":"last month"},relativeTime:{future:{other:"+{0} m"},past:{other:"-{0} m"}}},day:{displayName:"Da",relative:{0:"Ndɛ",1:"Ɔkyena","-1":"Ndeda"},relativeTime:{future:{other:"+{0} d"},past:{other:"-{0} d"}}},"day-short":{displayName:"Da",relative:{0:"Ndɛ",1:"Ɔkyena","-1":"Ndeda"},relativeTime:{future:{other:"+{0} d"},past:{other:"-{0} d"}}},hour:{displayName:"Dɔnhwer",relative:{0:"this hour"},relativeTime:{future:{other:"+{0} h"},past:{other:"-{0} h"}}},"hour-short":{displayName:"Dɔnhwer",relative:{0:"this hour"},relativeTime:{future:{other:"+{0} h"},past:{other:"-{0} h"}}},minute:{displayName:"Sema",relative:{0:"this minute"},relativeTime:{future:{other:"+{0} min"},past:{other:"-{0} min"}}},"minute-short":{displayName:"Sema",relative:{0:"this minute"},relativeTime:{future:{other:"+{0} min"},past:{other:"-{0} min"}}},second:{displayName:"Sɛkɛnd",relative:{0:"now"},relativeTime:{future:{other:"+{0} s"},past:{other:"-{0} s"}}},"second-short":{displayName:"Sɛkɛnd",relative:{0:"now"},relativeTime:{future:{other:"+{0} s"},past:{other:"-{0} s"}}}}}]});
|