1 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | export default function chooseLocale(locales, isLocaleDataAvailable) {
|
18 |
|
19 |
|
20 |
|
21 | for (var _iterator = locales, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
|
22 | var _ref;
|
23 |
|
24 | if (_isArray) {
|
25 | if (_i >= _iterator.length) break;
|
26 | _ref = _iterator[_i++];
|
27 | } else {
|
28 | _i = _iterator.next();
|
29 | if (_i.done) break;
|
30 | _ref = _i.value;
|
31 | }
|
32 |
|
33 | var locale = _ref;
|
34 |
|
35 | if (isLocaleDataAvailable(locale)) {
|
36 | return locale;
|
37 | }
|
38 |
|
39 | var parts = locale.split('-');
|
40 |
|
41 | while (parts.length > 1) {
|
42 | parts.pop();
|
43 | locale = parts.join('-');
|
44 |
|
45 | if (isLocaleDataAvailable(locale)) {
|
46 | return locale;
|
47 | }
|
48 | }
|
49 | }
|
50 |
|
51 | throw new Error("No locale data has been registered for any of the locales: ".concat(locales.join(', ')));
|
52 | }
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 | export function intlDateTimeFormatSupportedLocale(locales) {
|
61 |
|
62 | if (intlDateTimeFormatSupported()) {
|
63 | return Intl.DateTimeFormat.supportedLocalesOf(locales)[0];
|
64 | }
|
65 | }
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 | export function intlDateTimeFormatSupported() {
|
72 |
|
73 |
|
74 |
|
75 |
|
76 | var isIntlAvailable = (typeof Intl === "undefined" ? "undefined" : _typeof(Intl)) === 'object';
|
77 | return isIntlAvailable && typeof Intl.DateTimeFormat === 'function';
|
78 | }
|
79 |
|
\ | No newline at end of file |