|
10 | 10 | }
|
11 | 11 | }
|
12 | 12 |
|
| 13 | + function _typeof(obj) { |
| 14 | + "@babel/helpers - typeof"; |
| 15 | + |
| 16 | + return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { |
| 17 | + return typeof obj; |
| 18 | + } : function (obj) { |
| 19 | + return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; |
| 20 | + }, _typeof(obj); |
| 21 | + } |
| 22 | + |
| 23 | + function _toPrimitive(input, hint) { |
| 24 | + if (_typeof(input) !== "object" || input === null) return input; |
| 25 | + var prim = input[Symbol.toPrimitive]; |
| 26 | + if (prim !== undefined) { |
| 27 | + var res = prim.call(input, hint || "default"); |
| 28 | + if (_typeof(res) !== "object") return res; |
| 29 | + throw new TypeError("@@toPrimitive must return a primitive value."); |
| 30 | + } |
| 31 | + return (hint === "string" ? String : Number)(input); |
| 32 | + } |
| 33 | + |
| 34 | + function _toPropertyKey(arg) { |
| 35 | + var key = _toPrimitive(arg, "string"); |
| 36 | + return _typeof(key) === "symbol" ? key : String(key); |
| 37 | + } |
| 38 | + |
13 | 39 | function _defineProperties(target, props) {
|
14 | 40 | for (var i = 0; i < props.length; i++) {
|
15 | 41 | var descriptor = props[i];
|
16 | 42 | descriptor.enumerable = descriptor.enumerable || false;
|
17 | 43 | descriptor.configurable = true;
|
18 | 44 | if ("value" in descriptor) descriptor.writable = true;
|
19 |
| - Object.defineProperty(target, descriptor.key, descriptor); |
| 45 | + Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); |
20 | 46 | }
|
21 | 47 | }
|
22 | 48 | function _createClass(Constructor, protoProps, staticProps) {
|
|
307 | 333 | lookupSessionStorage: 'i18nextLng',
|
308 | 334 | // cache user language
|
309 | 335 | caches: ['localStorage'],
|
310 |
| - excludeCacheFor: ['cimode'] |
| 336 | + excludeCacheFor: ['cimode'], |
311 | 337 | // cookieMinutes: 10,
|
312 | 338 | // cookieDomain: 'myDomain'
|
| 339 | + |
| 340 | + convertDetectedLanguage: function convertDetectedLanguage(l) { |
| 341 | + return l; |
| 342 | + } |
313 | 343 | };
|
314 | 344 | }
|
315 | 345 | var Browser = /*#__PURE__*/function () {
|
|
329 | 359 | languageUtils: {}
|
330 | 360 | }; // this way the language detector can be used without i18next
|
331 | 361 | this.options = defaults(options, this.options || {}, getDefaults());
|
| 362 | + if (typeof this.options.convertDetectedLanguage === 'string' && this.options.convertDetectedLanguage.indexOf('15897') > -1) { |
| 363 | + this.options.convertDetectedLanguage = function (l) { |
| 364 | + return l.replace('-', '_'); |
| 365 | + }; |
| 366 | + } |
332 | 367 |
|
333 | 368 | // backwards compatibility
|
334 | 369 | if (this.options.lookupFromUrlIndex) this.options.lookupFromPathIndex = this.options.lookupFromUrlIndex;
|
|
360 | 395 | if (lookup) detected = detected.concat(lookup);
|
361 | 396 | }
|
362 | 397 | });
|
| 398 | + detected = detected.map(function (d) { |
| 399 | + return _this.options.convertDetectedLanguage(d); |
| 400 | + }); |
363 | 401 | if (this.services.languageUtils.getBestMatchFromCodes) return detected; // new i18next v19.5.0
|
364 | 402 | return detected.length > 0 ? detected[0] : null; // a little backward compatibility
|
365 | 403 | }
|
|
0 commit comments