@carbon/ibmdotcom-services 1.55.1 → 1.56.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/es/internal/vendor/@carbon/ibmdotcom-utilities/utilities/settings/settings.js +3 -3
- package/es/services/Locale/Locale.js +234 -143
- package/lib/internal/vendor/@carbon/ibmdotcom-utilities/utilities/settings/settings.js +3 -3
- package/lib/services/Locale/Locale.js +233 -143
- package/package.json +2 -2
- package/umd/ibmdotcom-services.js +235 -144
- package/umd/ibmdotcom-services.min.js +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2020,
|
|
2
|
+
* Copyright IBM Corp. 2020, 2024
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
* @exports ibmdotcom.settings
|
|
12
12
|
* @type {object} Settings object
|
|
13
13
|
* @property {string} [prefix=dds]
|
|
14
|
-
* Carbon for IBM.com v1.
|
|
14
|
+
* Carbon for IBM.com v1.56.0',
|
|
15
15
|
*/
|
|
16
16
|
var settings = {
|
|
17
|
-
version: 'Carbon for IBM.com v1.
|
|
17
|
+
version: 'Carbon for IBM.com v1.56.0',
|
|
18
18
|
stablePrefix: 'dds'
|
|
19
19
|
};
|
|
20
20
|
export default settings;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
2
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
4
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
5
5
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
6
6
|
/**
|
|
7
|
-
* Copyright IBM Corp. 2020,
|
|
7
|
+
* Copyright IBM Corp. 2020, 2024
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
10
10
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -16,15 +16,21 @@ import ipcinfoCookie from '../../internal/vendor/@carbon/ibmdotcom-utilities/uti
|
|
|
16
16
|
import root from 'window-or-global';
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
* @
|
|
19
|
+
* @typedef {object} Locale
|
|
20
|
+
* @property {string} cc The country code.
|
|
21
|
+
* @property {string} lc The language code.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @constant {string | string} Host for the Locale API call.
|
|
20
26
|
* @private
|
|
21
27
|
*/
|
|
22
28
|
var _host = process && (process.env.REACT_APP_TRANSLATION_HOST || process.env.TRANSLATION_HOST) || 'https://1.www.s81c.com';
|
|
23
29
|
|
|
24
30
|
/**
|
|
25
|
-
* Sets the default location if nothing is returned
|
|
31
|
+
* Sets the default location if nothing is returned.
|
|
26
32
|
*
|
|
27
|
-
* @type {
|
|
33
|
+
* @type {Locale}
|
|
28
34
|
* @private
|
|
29
35
|
*/
|
|
30
36
|
var _localeDefault = {
|
|
@@ -33,7 +39,7 @@ var _localeDefault = {
|
|
|
33
39
|
};
|
|
34
40
|
|
|
35
41
|
/**
|
|
36
|
-
* Default display name for lang combination
|
|
42
|
+
* Default display name for lang combination.
|
|
37
43
|
*
|
|
38
44
|
* @type {string}
|
|
39
45
|
* @private
|
|
@@ -41,7 +47,7 @@ var _localeDefault = {
|
|
|
41
47
|
var _localeNameDefault = 'United States — English';
|
|
42
48
|
|
|
43
49
|
/**
|
|
44
|
-
* Locale API endpoint
|
|
50
|
+
* Locale API endpoint.
|
|
45
51
|
*
|
|
46
52
|
* @type {string}
|
|
47
53
|
* @private
|
|
@@ -49,7 +55,7 @@ var _localeNameDefault = 'United States — English';
|
|
|
49
55
|
var _endpoint = "".concat(_host, "/common/js/dynamicnav/www/countrylist/jsononly");
|
|
50
56
|
|
|
51
57
|
/**
|
|
52
|
-
* Configuration for axios
|
|
58
|
+
* Configuration for axios.
|
|
53
59
|
*
|
|
54
60
|
* @type {{headers: {'Content-Type': string}}}
|
|
55
61
|
* @private
|
|
@@ -61,7 +67,7 @@ var _axiosConfig = {
|
|
|
61
67
|
};
|
|
62
68
|
|
|
63
69
|
/**
|
|
64
|
-
* Session Storage key for country list
|
|
70
|
+
* Session Storage key for country list.
|
|
65
71
|
*
|
|
66
72
|
* @type {string}
|
|
67
73
|
* @private
|
|
@@ -77,44 +83,141 @@ var _sessionListKey = 'dds-countrylist';
|
|
|
77
83
|
var _twoHours = 60 * 60 * 2000;
|
|
78
84
|
|
|
79
85
|
/**
|
|
80
|
-
*
|
|
86
|
+
* The cache for in-flight or resolved requests for the country list, keyed by
|
|
87
|
+
* the initiating locale.
|
|
81
88
|
*
|
|
82
89
|
* @type {object}
|
|
83
90
|
* @private
|
|
84
91
|
*/
|
|
85
|
-
var
|
|
92
|
+
var _requestsList = {};
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Retrieves the default locale.
|
|
96
|
+
*
|
|
97
|
+
* @returns {Locale} The default locale.
|
|
98
|
+
*/
|
|
99
|
+
var _getLocaleDefault = function _getLocaleDefault() {
|
|
100
|
+
return _localeDefault;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Use the <html> lang attr to determine a return locale object, or "false"
|
|
105
|
+
* when it's not available so the consumer can decide what to do next.
|
|
106
|
+
*
|
|
107
|
+
* @type {(Locale | boolean)}
|
|
108
|
+
* @private
|
|
109
|
+
*/
|
|
110
|
+
function _getLocaleFromLangAttr() {
|
|
86
111
|
var _root$document;
|
|
87
112
|
if ((_root$document = root.document) !== null && _root$document !== void 0 && (_root$document = _root$document.documentElement) !== null && _root$document !== void 0 && _root$document.lang) {
|
|
88
113
|
var lang = root.document.documentElement.lang.toLowerCase();
|
|
114
|
+
var locale = {};
|
|
89
115
|
if (lang.indexOf('-') === -1) {
|
|
90
|
-
|
|
91
|
-
lc: lang
|
|
92
|
-
};
|
|
116
|
+
locale.lc = lang;
|
|
93
117
|
} else {
|
|
94
118
|
var codes = lang.split('-');
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
lc: codes[0]
|
|
98
|
-
};
|
|
119
|
+
locale.cc = codes[1];
|
|
120
|
+
locale.lc = codes[0];
|
|
99
121
|
}
|
|
100
|
-
|
|
101
|
-
return _localeDefault;
|
|
122
|
+
return locale;
|
|
102
123
|
}
|
|
103
|
-
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
104
126
|
|
|
105
127
|
/**
|
|
106
|
-
*
|
|
128
|
+
* Gets the locale from the cookie and returns it if both 'cc' and 'lc' values
|
|
129
|
+
* are present.
|
|
107
130
|
*
|
|
108
|
-
* @
|
|
109
|
-
* @
|
|
131
|
+
* @async
|
|
132
|
+
* @returns {Promise<Locale|boolean>} The cookie object if 'cc' and 'lc' values are present, otherwise false.
|
|
110
133
|
*/
|
|
111
|
-
var
|
|
134
|
+
var _getLocaleFromCookie = /*#__PURE__*/function () {
|
|
135
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
136
|
+
var cookie;
|
|
137
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
138
|
+
while (1) switch (_context.prev = _context.next) {
|
|
139
|
+
case 0:
|
|
140
|
+
cookie = ipcinfoCookie.get();
|
|
141
|
+
if (!(cookie && cookie.cc && cookie.lc)) {
|
|
142
|
+
_context.next = 5;
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
_context.next = 4;
|
|
146
|
+
return LocaleAPI.getList(cookie);
|
|
147
|
+
case 4:
|
|
148
|
+
return _context.abrupt("return", cookie);
|
|
149
|
+
case 5:
|
|
150
|
+
return _context.abrupt("return", false);
|
|
151
|
+
case 6:
|
|
152
|
+
case "end":
|
|
153
|
+
return _context.stop();
|
|
154
|
+
}
|
|
155
|
+
}, _callee);
|
|
156
|
+
}));
|
|
157
|
+
return function _getLocaleFromCookie() {
|
|
158
|
+
return _ref.apply(this, arguments);
|
|
159
|
+
};
|
|
160
|
+
}();
|
|
112
161
|
|
|
113
162
|
/**
|
|
114
|
-
*
|
|
115
|
-
* so the consumer can decide what to do next
|
|
163
|
+
* Get the locale from the user's browser.
|
|
116
164
|
*
|
|
117
|
-
* @
|
|
165
|
+
* @async
|
|
166
|
+
* @returns {Promise<Locale|boolean>} The verified locale or false if not found.
|
|
167
|
+
*/
|
|
168
|
+
var _getLocaleFromBrowser = /*#__PURE__*/function () {
|
|
169
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
170
|
+
var cc, lang, lc, list, verifiedCodes;
|
|
171
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
172
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
173
|
+
case 0:
|
|
174
|
+
_context2.prev = 0;
|
|
175
|
+
_context2.next = 3;
|
|
176
|
+
return DDOAPI.getLocation();
|
|
177
|
+
case 3:
|
|
178
|
+
cc = _context2.sent;
|
|
179
|
+
// Language preference from browser can return in either 'en-US' format or
|
|
180
|
+
// 'en' so will need to extract language only.
|
|
181
|
+
lang = root.navigator.language;
|
|
182
|
+
lc = lang.split('-')[0];
|
|
183
|
+
if (!(cc && lc)) {
|
|
184
|
+
_context2.next = 13;
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
_context2.next = 9;
|
|
188
|
+
return LocaleAPI.getList({
|
|
189
|
+
cc: cc,
|
|
190
|
+
lc: lc
|
|
191
|
+
});
|
|
192
|
+
case 9:
|
|
193
|
+
list = _context2.sent;
|
|
194
|
+
verifiedCodes = LocaleAPI.verifyLocale(cc, lc, list); // Set the ipcInfo cookie.
|
|
195
|
+
ipcinfoCookie.set(verifiedCodes);
|
|
196
|
+
return _context2.abrupt("return", verifiedCodes);
|
|
197
|
+
case 13:
|
|
198
|
+
_context2.next = 17;
|
|
199
|
+
break;
|
|
200
|
+
case 15:
|
|
201
|
+
_context2.prev = 15;
|
|
202
|
+
_context2.t0 = _context2["catch"](0);
|
|
203
|
+
case 17:
|
|
204
|
+
return _context2.abrupt("return", false);
|
|
205
|
+
case 18:
|
|
206
|
+
case "end":
|
|
207
|
+
return _context2.stop();
|
|
208
|
+
}
|
|
209
|
+
}, _callee2, null, [[0, 15]]);
|
|
210
|
+
}));
|
|
211
|
+
return function _getLocaleFromBrowser() {
|
|
212
|
+
return _ref2.apply(this, arguments);
|
|
213
|
+
};
|
|
214
|
+
}();
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Return a locale object based on the DDO API, or "false" so the consumer can
|
|
218
|
+
* decide what to do next.
|
|
219
|
+
*
|
|
220
|
+
* @returns {(Locale | boolean)} Locale from the DDO, or "false" if not present.
|
|
118
221
|
* @private
|
|
119
222
|
*/
|
|
120
223
|
function _getLocaleFromDDO() {
|
|
@@ -152,8 +255,7 @@ function _getLocaleFromDDO() {
|
|
|
152
255
|
}
|
|
153
256
|
|
|
154
257
|
/**
|
|
155
|
-
* Locale API class with method of fetching user's locale for
|
|
156
|
-
* ibm.com
|
|
258
|
+
* Locale API class with method of fetching user's locale for ibm.com.
|
|
157
259
|
*/
|
|
158
260
|
var LocaleAPI = /*#__PURE__*/function () {
|
|
159
261
|
function LocaleAPI() {
|
|
@@ -180,14 +282,18 @@ var LocaleAPI = /*#__PURE__*/function () {
|
|
|
180
282
|
}
|
|
181
283
|
|
|
182
284
|
/**
|
|
183
|
-
* Gets the user's locale
|
|
285
|
+
* Gets the user's locale.
|
|
184
286
|
*
|
|
185
|
-
* Grab the locale from the
|
|
186
|
-
*
|
|
187
|
-
* if not, retrieve the user's locale through DDO service + gets user's
|
|
188
|
-
* browser language preference then set the cookie
|
|
287
|
+
* Grab the locale from the available information on the page in the following
|
|
288
|
+
* order:
|
|
189
289
|
*
|
|
190
|
-
*
|
|
290
|
+
* 1. DDO
|
|
291
|
+
* 2. HTML lang attribute
|
|
292
|
+
* 3. ipcInfo cookie
|
|
293
|
+
* 4. Browser (navigator.language)
|
|
294
|
+
* 5. Default (us-EN)
|
|
295
|
+
*
|
|
296
|
+
* @returns {Promise<Locale>} Locale object.
|
|
191
297
|
* @example
|
|
192
298
|
* import { LocaleAPI } from '@carbon/ibmdotcom-services';
|
|
193
299
|
*
|
|
@@ -199,60 +305,39 @@ var LocaleAPI = /*#__PURE__*/function () {
|
|
|
199
305
|
}, {
|
|
200
306
|
key: "getLocale",
|
|
201
307
|
value: function () {
|
|
202
|
-
var _getLocale = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
203
|
-
var
|
|
204
|
-
return _regeneratorRuntime.wrap(function
|
|
205
|
-
while (1) switch (
|
|
308
|
+
var _getLocale = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
309
|
+
var localeGetters, _i, _localeGetters, getter, locale;
|
|
310
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
311
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
206
312
|
case 0:
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
if (!lang) {
|
|
213
|
-
_context.next = 8;
|
|
214
|
-
break;
|
|
215
|
-
}
|
|
216
|
-
return _context.abrupt("return", lang);
|
|
217
|
-
case 8:
|
|
218
|
-
if (!(cookie && cookie.cc && cookie.lc)) {
|
|
219
|
-
_context.next = 14;
|
|
313
|
+
localeGetters = [_getLocaleFromDDO, _getLocaleFromLangAttr, _getLocaleFromCookie, _getLocaleFromBrowser];
|
|
314
|
+
_i = 0, _localeGetters = localeGetters;
|
|
315
|
+
case 2:
|
|
316
|
+
if (!(_i < _localeGetters.length)) {
|
|
317
|
+
_context3.next = 12;
|
|
220
318
|
break;
|
|
221
319
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
case 16:
|
|
230
|
-
cc = _context.sent;
|
|
231
|
-
/**
|
|
232
|
-
* get language preference from browser
|
|
233
|
-
* can return in either 'en-US' format or 'en' so will need to extract language only
|
|
234
|
-
*/
|
|
235
|
-
_lang = root.navigator.language;
|
|
236
|
-
lc = _lang.split('-')[0];
|
|
237
|
-
if (!(cc && lc)) {
|
|
238
|
-
_context.next = 26;
|
|
320
|
+
getter = _localeGetters[_i];
|
|
321
|
+
_context3.next = 6;
|
|
322
|
+
return getter();
|
|
323
|
+
case 6:
|
|
324
|
+
locale = _context3.sent;
|
|
325
|
+
if (!locale) {
|
|
326
|
+
_context3.next = 9;
|
|
239
327
|
break;
|
|
240
328
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
case
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
ipcinfoCookie.set(verifiedCodes);
|
|
250
|
-
return _context.abrupt("return", verifiedCodes);
|
|
251
|
-
case 26:
|
|
329
|
+
return _context3.abrupt("return", locale);
|
|
330
|
+
case 9:
|
|
331
|
+
_i++;
|
|
332
|
+
_context3.next = 2;
|
|
333
|
+
break;
|
|
334
|
+
case 12:
|
|
335
|
+
return _context3.abrupt("return", _getLocaleDefault());
|
|
336
|
+
case 13:
|
|
252
337
|
case "end":
|
|
253
|
-
return
|
|
338
|
+
return _context3.stop();
|
|
254
339
|
}
|
|
255
|
-
},
|
|
340
|
+
}, _callee3);
|
|
256
341
|
}));
|
|
257
342
|
function getLocale() {
|
|
258
343
|
return _getLocale.apply(this, arguments);
|
|
@@ -260,62 +345,69 @@ var LocaleAPI = /*#__PURE__*/function () {
|
|
|
260
345
|
return getLocale;
|
|
261
346
|
}()
|
|
262
347
|
/**
|
|
263
|
-
*
|
|
264
|
-
* Otherwise gets those values from the <html> lang attribute
|
|
348
|
+
* Gets the user's locale.
|
|
265
349
|
*
|
|
266
|
-
* @returns {
|
|
350
|
+
* @returns {Promise<Locale>} Locale object.
|
|
267
351
|
* @example
|
|
268
352
|
* import { LocaleAPI } from '@carbon/ibmdotcom-services';
|
|
269
353
|
*
|
|
270
354
|
* function async getLocale() {
|
|
271
355
|
* const locale = await LocaleAPI.getLang();
|
|
272
356
|
* }
|
|
357
|
+
*
|
|
358
|
+
* @deprecated in favor of LocalAPI.getLocale.
|
|
273
359
|
*/
|
|
274
360
|
}, {
|
|
275
361
|
key: "getLang",
|
|
276
|
-
value: function
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
362
|
+
value: function () {
|
|
363
|
+
var _getLang = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
364
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
365
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
366
|
+
case 0:
|
|
367
|
+
return _context4.abrupt("return", this.getLocale());
|
|
368
|
+
case 1:
|
|
369
|
+
case "end":
|
|
370
|
+
return _context4.stop();
|
|
371
|
+
}
|
|
372
|
+
}, _callee4, this);
|
|
373
|
+
}));
|
|
374
|
+
function getLang() {
|
|
375
|
+
return _getLang.apply(this, arguments);
|
|
376
|
+
}
|
|
377
|
+
return getLang;
|
|
378
|
+
}()
|
|
287
379
|
/**
|
|
288
|
-
* This fetches the language display name based on
|
|
380
|
+
* This fetches the language display name based on locale.
|
|
289
381
|
*
|
|
290
|
-
* @param {
|
|
291
|
-
* @returns {Promise<string>} Display name of locale/language
|
|
382
|
+
* @param {(Locale | boolean)} locale (optional) If not given, uses LocaleAPI.getLocale logic.
|
|
383
|
+
* @returns {Promise<string>} Display name of locale/language.
|
|
292
384
|
*/
|
|
293
385
|
}, {
|
|
294
386
|
key: "getLangDisplay",
|
|
295
387
|
value: function () {
|
|
296
|
-
var _getLangDisplay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
388
|
+
var _getLangDisplay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(locale) {
|
|
297
389
|
var lang, list, countries, location;
|
|
298
|
-
return _regeneratorRuntime.wrap(function
|
|
299
|
-
while (1) switch (
|
|
390
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
391
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
300
392
|
case 0:
|
|
301
|
-
if (!
|
|
302
|
-
|
|
393
|
+
if (!locale) {
|
|
394
|
+
_context5.next = 4;
|
|
303
395
|
break;
|
|
304
396
|
}
|
|
305
|
-
|
|
306
|
-
|
|
397
|
+
_context5.t0 = locale;
|
|
398
|
+
_context5.next = 7;
|
|
307
399
|
break;
|
|
308
400
|
case 4:
|
|
309
|
-
|
|
310
|
-
return this.
|
|
401
|
+
_context5.next = 6;
|
|
402
|
+
return this.getLocale();
|
|
311
403
|
case 6:
|
|
312
|
-
|
|
404
|
+
_context5.t0 = _context5.sent;
|
|
313
405
|
case 7:
|
|
314
|
-
lang =
|
|
315
|
-
|
|
406
|
+
lang = _context5.t0;
|
|
407
|
+
_context5.next = 10;
|
|
316
408
|
return this.getList(lang);
|
|
317
409
|
case 10:
|
|
318
|
-
list =
|
|
410
|
+
list = _context5.sent;
|
|
319
411
|
// combines the countryList arrays
|
|
320
412
|
countries = [];
|
|
321
413
|
list.regionList.forEach(function (region) {
|
|
@@ -337,17 +429,17 @@ var LocaleAPI = /*#__PURE__*/function () {
|
|
|
337
429
|
}
|
|
338
430
|
});
|
|
339
431
|
if (!location.length) {
|
|
340
|
-
|
|
432
|
+
_context5.next = 18;
|
|
341
433
|
break;
|
|
342
434
|
}
|
|
343
|
-
return
|
|
435
|
+
return _context5.abrupt("return", "".concat(location[0].name, " \u2014 ").concat(location[0].locale[0][1]));
|
|
344
436
|
case 18:
|
|
345
|
-
return
|
|
437
|
+
return _context5.abrupt("return", _localeNameDefault);
|
|
346
438
|
case 19:
|
|
347
439
|
case "end":
|
|
348
|
-
return
|
|
440
|
+
return _context5.stop();
|
|
349
441
|
}
|
|
350
|
-
},
|
|
442
|
+
}, _callee5, this);
|
|
351
443
|
}));
|
|
352
444
|
function getLangDisplay(_x) {
|
|
353
445
|
return _getLangDisplay.apply(this, arguments);
|
|
@@ -356,12 +448,12 @@ var LocaleAPI = /*#__PURE__*/function () {
|
|
|
356
448
|
}()
|
|
357
449
|
/**
|
|
358
450
|
* Get the country list of all supported countries and their languages
|
|
359
|
-
* if it is not already stored in session storage
|
|
451
|
+
* if it is not already stored in session storage.
|
|
360
452
|
*
|
|
361
|
-
* @param {
|
|
362
|
-
* @param {string}
|
|
363
|
-
* @param {string}
|
|
364
|
-
* @returns {Promise<any>}
|
|
453
|
+
* @param {Locale} locale Locale object.
|
|
454
|
+
* @param {string} locale.cc Country code.
|
|
455
|
+
* @param {string} locale.lc Language code.
|
|
456
|
+
* @returns {Promise<any>} Promise object.
|
|
365
457
|
* @example
|
|
366
458
|
* import { LocaleAPI } from '@carbon/ibmdotcom-services';
|
|
367
459
|
*
|
|
@@ -373,21 +465,21 @@ var LocaleAPI = /*#__PURE__*/function () {
|
|
|
373
465
|
}, {
|
|
374
466
|
key: "getList",
|
|
375
467
|
value: function () {
|
|
376
|
-
var _getList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
468
|
+
var _getList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref3) {
|
|
377
469
|
var _this = this;
|
|
378
470
|
var cc, lc;
|
|
379
|
-
return _regeneratorRuntime.wrap(function
|
|
380
|
-
while (1) switch (
|
|
471
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
472
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
381
473
|
case 0:
|
|
382
|
-
cc =
|
|
383
|
-
return
|
|
474
|
+
cc = _ref3.cc, lc = _ref3.lc;
|
|
475
|
+
return _context6.abrupt("return", new Promise(function (resolve, reject) {
|
|
384
476
|
_this.fetchList(cc, lc, resolve, reject);
|
|
385
477
|
}));
|
|
386
478
|
case 2:
|
|
387
479
|
case "end":
|
|
388
|
-
return
|
|
480
|
+
return _context6.stop();
|
|
389
481
|
}
|
|
390
|
-
},
|
|
482
|
+
}, _callee6);
|
|
391
483
|
}));
|
|
392
484
|
function getList(_x2) {
|
|
393
485
|
return _getList.apply(this, arguments);
|
|
@@ -395,12 +487,12 @@ var LocaleAPI = /*#__PURE__*/function () {
|
|
|
395
487
|
return getList;
|
|
396
488
|
}()
|
|
397
489
|
/**
|
|
398
|
-
* Fetches the list data based on cc/lc combination
|
|
490
|
+
* Fetches the list data based on cc/lc combination.
|
|
399
491
|
*
|
|
400
|
-
* @param {string} cc
|
|
401
|
-
* @param {string} lc
|
|
402
|
-
* @param {Function} resolve
|
|
403
|
-
* @param {Function} reject
|
|
492
|
+
* @param {string} cc Country code.
|
|
493
|
+
* @param {string} lc Language code.
|
|
494
|
+
* @param {Function} resolve Resolves the Promise.
|
|
495
|
+
* @param {Function} reject Rejects the promise.
|
|
404
496
|
*/
|
|
405
497
|
}, {
|
|
406
498
|
key: "fetchList",
|
|
@@ -432,13 +524,12 @@ var LocaleAPI = /*#__PURE__*/function () {
|
|
|
432
524
|
}
|
|
433
525
|
|
|
434
526
|
/**
|
|
435
|
-
* Verify that the cc and lc combo is in the list of
|
|
436
|
-
* supported cc-lc combos
|
|
527
|
+
* Verify that the cc and lc combo is in the list of supported cc-lc combos.
|
|
437
528
|
*
|
|
438
|
-
* @param {string} cc
|
|
439
|
-
* @param {string} lc
|
|
440
|
-
* @param {object} list
|
|
441
|
-
* @returns {object}
|
|
529
|
+
* @param {string} cc Country code.
|
|
530
|
+
* @param {string} lc Language code.
|
|
531
|
+
* @param {object} list Country list.
|
|
532
|
+
* @returns {object} Object with lc and cc.
|
|
442
533
|
* @example
|
|
443
534
|
* import { LocaleAPI } from '@carbon/ibmdotcom-services';
|
|
444
535
|
*
|
|
@@ -455,8 +546,8 @@ var LocaleAPI = /*#__PURE__*/function () {
|
|
|
455
546
|
var language = list && list.regionList.forEach(function (region) {
|
|
456
547
|
return region.countryList.forEach(function (country) {
|
|
457
548
|
var code = country.locale[0][0].split('-');
|
|
458
|
-
var countryCode = code[1];
|
|
459
549
|
var languageCode = code[0];
|
|
550
|
+
var countryCode = code[1];
|
|
460
551
|
if (countryCode === cc && languageCode === lc) {
|
|
461
552
|
locale = {
|
|
462
553
|
cc: cc,
|
|
@@ -481,7 +572,7 @@ var LocaleAPI = /*#__PURE__*/function () {
|
|
|
481
572
|
/**
|
|
482
573
|
* Retrieves session cache and checks if cache needs to be refreshed
|
|
483
574
|
*
|
|
484
|
-
* @param
|
|
575
|
+
* @param {string} key Session storage key.
|
|
485
576
|
*/
|
|
486
577
|
}, {
|
|
487
578
|
key: "getSessionCache",
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
/**
|
|
8
|
-
* Copyright IBM Corp. 2020,
|
|
8
|
+
* Copyright IBM Corp. 2020, 2024
|
|
9
9
|
*
|
|
10
10
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
11
11
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -17,10 +17,10 @@ exports.default = void 0;
|
|
|
17
17
|
* @exports ibmdotcom.settings
|
|
18
18
|
* @type {object} Settings object
|
|
19
19
|
* @property {string} [prefix=dds]
|
|
20
|
-
* Carbon for IBM.com v1.
|
|
20
|
+
* Carbon for IBM.com v1.56.0',
|
|
21
21
|
*/
|
|
22
22
|
var settings = {
|
|
23
|
-
version: 'Carbon for IBM.com v1.
|
|
23
|
+
version: 'Carbon for IBM.com v1.56.0',
|
|
24
24
|
stablePrefix: 'dds'
|
|
25
25
|
};
|
|
26
26
|
var _default = exports.default = settings;
|