@bigbinary/neeto-commons-frontend 4.13.92-beta.2 → 4.13.92-beta.4
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/cjs/initializers/i18n.js +92 -64
- package/dist/cjs/initializers/i18n.js.map +1 -1
- package/dist/cjs/initializers/index.js +9 -4
- package/dist/cjs/initializers/index.js.map +1 -1
- package/dist/initializers/i18n.js +92 -64
- package/dist/initializers/i18n.js.map +1 -1
- package/dist/initializers/index.js +9 -4
- package/dist/initializers/index.js.map +1 -1
- package/initializers.d.ts +1 -1
- package/package.json +6 -4
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var index = require('../index-bFmfHzbL.js');
|
|
5
6
|
var i18next = require('i18next');
|
|
6
7
|
var ramda = require('ramda');
|
|
7
8
|
var reactI18next = require('react-i18next');
|
|
@@ -10,6 +11,7 @@ var initializers_constants = require('./constants.js');
|
|
|
10
11
|
var initializers_utils_customFormatters = require('./utils/customFormatters.js');
|
|
11
12
|
var initializers_utils_customPostProcessors = require('./utils/customPostProcessors.js');
|
|
12
13
|
var initializers_utils_utils = require('./utils/utils.js');
|
|
14
|
+
require('../_commonjsHelpers-BJu3ubxk.js');
|
|
13
15
|
require('dompurify');
|
|
14
16
|
require('../typeof-D4ZZ_FlZ.js');
|
|
15
17
|
require('../slicedToArray-BcL7fKuL.js');
|
|
@@ -459,72 +461,98 @@ var resourcesToBackend = function resourcesToBackend(res) {
|
|
|
459
461
|
|
|
460
462
|
// eslint-disable-next-line import/no-mutable-exports
|
|
461
463
|
exports.taxonomies = {};
|
|
462
|
-
var initializeI18n = function
|
|
463
|
-
var
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
464
|
+
var initializeI18n = /*#__PURE__*/function () {
|
|
465
|
+
var _ref = index._asyncToGenerator(/*#__PURE__*/index._regeneratorRuntime.mark(function _callee() {
|
|
466
|
+
var _window$globalProps, _window$globalProps2;
|
|
467
|
+
var hostTranslations,
|
|
468
|
+
enableDirAttribute,
|
|
469
|
+
userLanguage,
|
|
470
|
+
translationImports,
|
|
471
|
+
englishTranslations,
|
|
472
|
+
englishResource,
|
|
473
|
+
resources,
|
|
474
|
+
defaultTaxonomyKeys,
|
|
475
|
+
defaultTaxonomies,
|
|
476
|
+
hostTaxonomies,
|
|
477
|
+
_args = arguments;
|
|
478
|
+
return index._regeneratorRuntime.wrap(function _callee$(_context) {
|
|
479
|
+
while (1) switch (_context.prev = _context.next) {
|
|
480
|
+
case 0:
|
|
481
|
+
hostTranslations = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
|
|
482
|
+
enableDirAttribute = _args.length > 1 && _args[1] !== undefined ? _args[1] : true;
|
|
483
|
+
document.documentElement.removeAttribute("lang");
|
|
484
|
+
userLanguage = (_window$globalProps = window.globalProps) === null || _window$globalProps === void 0 || (_window$globalProps = _window$globalProps.user) === null || _window$globalProps === void 0 ? void 0 : _window$globalProps.language;
|
|
485
|
+
if (userLanguage) document.documentElement.setAttribute("lang", userLanguage);
|
|
486
|
+
translationImports = preval.require("../../../configs/scripts/buildTranslationImports.js");
|
|
487
|
+
englishTranslations = preval.require("../../../configs/scripts/getEnglishTranslation.js");
|
|
488
|
+
englishResource = {
|
|
489
|
+
en: {
|
|
490
|
+
translation: englishTranslations || {}
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
resources = ramda.mergeDeepLeft(hostTranslations, englishResource);
|
|
494
|
+
defaultTaxonomyKeys = Object.keys(resources.en.translation.taxonomyDefaultLabels || {});
|
|
495
|
+
defaultTaxonomies = Object.fromEntries(defaultTaxonomyKeys.map(function (key) {
|
|
496
|
+
return [key, {
|
|
497
|
+
singular: null,
|
|
498
|
+
plural: null
|
|
499
|
+
}];
|
|
500
|
+
}));
|
|
501
|
+
hostTaxonomies = ((_window$globalProps2 = window.globalProps) === null || _window$globalProps2 === void 0 ? void 0 : _window$globalProps2.taxonomies) || {};
|
|
502
|
+
exports.taxonomies = initializers_utils_utils.replaceNullValuesWithGetter(ramda.mergeDeepLeft(hostTaxonomies, defaultTaxonomies));
|
|
503
|
+
_context.next = 15;
|
|
504
|
+
return i18next.use(Browser).use(reactI18next.initReactI18next).use(initializers_utils_customPostProcessors.sentenceCaseProcessor).use(resourcesToBackend(function (language) {
|
|
505
|
+
return utils_retryImport(translationImports === null || translationImports === void 0 ? void 0 : translationImports[language]);
|
|
506
|
+
})).init({
|
|
507
|
+
resources: resources,
|
|
508
|
+
partialBundledLanguages: true,
|
|
509
|
+
fallbackLng: "en",
|
|
510
|
+
interpolation: {
|
|
511
|
+
defaultVariables: {
|
|
512
|
+
taxonomies: exports.taxonomies
|
|
513
|
+
},
|
|
514
|
+
escapeValue: false,
|
|
515
|
+
skipOnVariables: false,
|
|
516
|
+
alwaysFormat: true,
|
|
517
|
+
format: function format(value, _format, lng, options) {
|
|
518
|
+
var newValue = value;
|
|
519
|
+
if (initializers_constants.LIST_FORMATS.includes(_format)) {
|
|
520
|
+
newValue = initializers_utils_customFormatters.listFormatter({
|
|
521
|
+
value: newValue,
|
|
522
|
+
format: _format,
|
|
523
|
+
lng: lng,
|
|
524
|
+
options: options
|
|
525
|
+
});
|
|
526
|
+
return newValue;
|
|
527
|
+
}
|
|
528
|
+
return initializers_utils_customFormatters.lowerCaseDynamicTextFormatter(newValue, _format);
|
|
529
|
+
}
|
|
530
|
+
},
|
|
531
|
+
postProcess: [initializers_utils_customPostProcessors.sentenceCaseProcessor.name],
|
|
532
|
+
detection: {
|
|
533
|
+
order: ["querystring", "htmlTag", "navigator", "cookie"],
|
|
534
|
+
caches: ["cookie"],
|
|
535
|
+
lookupQuerystring: "lang",
|
|
536
|
+
lookupCookie: "lang"
|
|
537
|
+
}
|
|
507
538
|
});
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
539
|
+
case 15:
|
|
540
|
+
if (enableDirAttribute) {
|
|
541
|
+
document.documentElement.setAttribute("dir", i18next.dir() || "ltr");
|
|
542
|
+
}
|
|
543
|
+
if (!userLanguage) {
|
|
544
|
+
document.documentElement.setAttribute("lang", i18next.resolvedLanguage || "en");
|
|
545
|
+
}
|
|
546
|
+
case 17:
|
|
547
|
+
case "end":
|
|
548
|
+
return _context.stop();
|
|
511
549
|
}
|
|
512
|
-
},
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
lookupCookie: "lang"
|
|
519
|
-
}
|
|
520
|
-
});
|
|
521
|
-
if (enableDirAttribute) {
|
|
522
|
-
document.documentElement.setAttribute("dir", i18next.dir() || "ltr");
|
|
523
|
-
}
|
|
524
|
-
if (!userLanguage) {
|
|
525
|
-
document.documentElement.setAttribute("lang", i18next.resolvedLanguage || "en");
|
|
526
|
-
}
|
|
527
|
-
};
|
|
550
|
+
}, _callee);
|
|
551
|
+
}));
|
|
552
|
+
return function initializeI18n() {
|
|
553
|
+
return _ref.apply(this, arguments);
|
|
554
|
+
};
|
|
555
|
+
}();
|
|
528
556
|
|
|
529
557
|
exports.default = initializeI18n;
|
|
530
558
|
//# sourceMappingURL=i18n.js.map
|