@bigbinary/neeto-commons-frontend 4.13.91 → 4.13.92-beta.2

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.
Files changed (102) hide show
  1. package/README.md +1 -0
  2. package/configs/esbuild/index.js +4 -0
  3. package/configs/esbuild/plugins/packageTranslations.js +16 -0
  4. package/configs/esbuild/plugins/preval.js +16 -6
  5. package/configs/scripts/buildTranslationImports.js +22 -0
  6. package/configs/scripts/getEnglishTranslation.js +17 -0
  7. package/configs/utils/packageTranslations.js +90 -0
  8. package/configs/vite/index.js +5 -0
  9. package/configs/vite/plugins/packageTranslations.js +14 -0
  10. package/configs/vite/plugins/preval.js +32 -10
  11. package/dist/cjs/initializers/i18n.js +39 -130
  12. package/dist/cjs/initializers/i18n.js.map +1 -1
  13. package/dist/cjs/initializers/index.js +38 -19
  14. package/dist/cjs/initializers/index.js.map +1 -1
  15. package/dist/cjs/react-utils/AppContainer/AppContainer.js +2 -2
  16. package/dist/cjs/react-utils/HoneybadgerErrorBoundary/FallbackComponent.js +2 -2
  17. package/dist/cjs/react-utils/index.js +6 -0
  18. package/dist/cjs/react-utils/index.js.map +1 -1
  19. package/dist/cjs/react-utils/lazyWithRetry/index.js +10 -0
  20. package/dist/cjs/react-utils/lazyWithRetry/index.js.map +1 -0
  21. package/dist/cjs/react-utils/lazyWithRetry/lazyWithRetry.js +15 -0
  22. package/dist/cjs/react-utils/lazyWithRetry/lazyWithRetry.js.map +1 -0
  23. package/dist/cjs/react-utils/mount/index.js +15 -0
  24. package/dist/cjs/react-utils/mount/index.js.map +1 -0
  25. package/dist/cjs/react-utils/mount/mount.js +86 -0
  26. package/dist/cjs/react-utils/mount/mount.js.map +1 -0
  27. package/dist/cjs/react-utils/useBreakpoints/index.js +2 -2
  28. package/dist/cjs/react-utils/useColumnConfig/useColumnConfig.js +2 -2
  29. package/dist/cjs/react-utils/useDebounce/useDebounce.js +3 -3
  30. package/dist/cjs/react-utils/useFieldSubmit/useFieldSubmit.js +4 -4
  31. package/dist/cjs/react-utils/useFuncDebounce/useFuncDebounce.js +2 -2
  32. package/dist/cjs/react-utils/useIsElementVisibleInDom/useForceUpdate.js +2 -2
  33. package/dist/cjs/react-utils/useIsElementVisibleInDom/useIsElementVisibleInDom.js +3 -3
  34. package/dist/cjs/react-utils/useLocalStorage/useLocalStorage.js +2 -2
  35. package/dist/cjs/react-utils/useOnClickOutside/useOnClickOutside.js +2 -2
  36. package/dist/cjs/react-utils/usePersistedQuery/usePersistedQuery.js +2 -2
  37. package/dist/cjs/react-utils/usePrevious/usePrevious.js +3 -3
  38. package/dist/cjs/react-utils/useRegisterNavigationCheckpoint/useRegisterNavigationCheckpoint.js +2 -2
  39. package/dist/cjs/react-utils/useRestoreScrollPosition/useRestoreScrollPosition.js +2 -2
  40. package/dist/cjs/react-utils/useStateWithDependency/useStateWithDependency.js +3 -3
  41. package/dist/cjs/react-utils/useTimer/useTimer.js +3 -3
  42. package/dist/cjs/react-utils/useUpdateEffect/useUpdateEffect.js +3 -3
  43. package/dist/cjs/utils/datetime.js +22 -13
  44. package/dist/cjs/utils/datetime.js.map +1 -1
  45. package/dist/cjs/utils/retryImport.js +37 -0
  46. package/dist/cjs/utils/retryImport.js.map +1 -0
  47. package/dist/initializers/i18n.js +39 -130
  48. package/dist/initializers/i18n.js.map +1 -1
  49. package/dist/initializers/index.js +38 -19
  50. package/dist/initializers/index.js.map +1 -1
  51. package/dist/react-utils/index.js +4 -0
  52. package/dist/react-utils/index.js.map +1 -1
  53. package/dist/react-utils/lazyWithRetry/index.js +4 -0
  54. package/dist/react-utils/lazyWithRetry/index.js.map +1 -0
  55. package/dist/react-utils/lazyWithRetry/lazyWithRetry.js +13 -0
  56. package/dist/react-utils/lazyWithRetry/lazyWithRetry.js.map +1 -0
  57. package/dist/react-utils/mount/index.js +9 -0
  58. package/dist/react-utils/mount/index.js.map +1 -0
  59. package/dist/react-utils/mount/mount.js +84 -0
  60. package/dist/react-utils/mount/mount.js.map +1 -0
  61. package/dist/utils/datetime.js +22 -13
  62. package/dist/utils/datetime.js.map +1 -1
  63. package/dist/utils/retryImport.js +35 -0
  64. package/dist/utils/retryImport.js.map +1 -0
  65. package/package.json +10 -6
  66. package/react-utils.d.ts +73 -1
  67. package/src/translations/ar.json +111 -0
  68. package/src/translations/bg.json +111 -0
  69. package/src/translations/ca.json +111 -0
  70. package/src/translations/cs.json +111 -0
  71. package/src/translations/da.json +111 -0
  72. package/src/translations/de.json +111 -0
  73. package/src/translations/en.json +111 -0
  74. package/src/translations/es-MX.json +111 -0
  75. package/src/translations/es.json +111 -0
  76. package/src/translations/et.json +111 -0
  77. package/src/translations/fi.json +111 -0
  78. package/src/translations/fil.json +111 -0
  79. package/src/translations/fr.json +111 -0
  80. package/src/translations/he.json +111 -0
  81. package/src/translations/hi.json +111 -0
  82. package/src/translations/hr.json +111 -0
  83. package/src/translations/id.json +111 -0
  84. package/src/translations/it.json +111 -0
  85. package/src/translations/ja.json +111 -0
  86. package/src/translations/ko.json +111 -0
  87. package/src/translations/nl.json +111 -0
  88. package/src/translations/pl.json +111 -0
  89. package/src/translations/pt-BR.json +111 -0
  90. package/src/translations/pt.json +111 -0
  91. package/src/translations/ro.json +111 -0
  92. package/src/translations/ru.json +111 -0
  93. package/src/translations/sk.json +111 -0
  94. package/src/translations/sl.json +111 -0
  95. package/src/translations/sv.json +111 -0
  96. package/src/translations/th.json +111 -0
  97. package/src/translations/tr.json +111 -0
  98. package/src/translations/uk.json +111 -0
  99. package/src/translations/vi.json +111 -0
  100. package/src/translations/zh-CN.json +111 -0
  101. package/src/translations/zh-TW.json +111 -0
  102. package/configs/scripts/getPkgTranslations.js +0 -45
package/README.md CHANGED
@@ -80,6 +80,7 @@ React utilities [↗](./docs/react/README.md)
80
80
  - [handleMetaClick](./docs/react/utils/handleMetaClick.md)
81
81
  - [isMetaKeyPressed](./docs/react/utils/isMetaKeyPressed.md)
82
82
  - [withT](./docs/react/utils/withT.md)
83
+ - [lazyWithRetry](./docs/react/utils/lazyWithRetry.md)
83
84
 
84
85
  </td>
85
86
  </tr>
@@ -15,6 +15,9 @@ const sass = require("sass");
15
15
  const alias = require("./alias.js");
16
16
  const { babelPlugin } = require("./plugins/babel.js");
17
17
  const { entrypointPlugin } = require("./plugins/entrypoint.js");
18
+ const {
19
+ packageTranslationsPlugin,
20
+ } = require("./plugins/packageTranslations.js");
18
21
  const { prevalPlugin } = require("./plugins/preval.js");
19
22
  const { reactGiphyPlugin } = require("./plugins/reactGiphy.js");
20
23
  const { virtualizedPlugin } = require("./plugins/virtualized.js");
@@ -49,6 +52,7 @@ const config = {
49
52
  plugins: [
50
53
  rails(),
51
54
  entrypointPlugin(isWatchMode),
55
+ packageTranslationsPlugin(),
52
56
  prevalPlugin(),
53
57
  babelPlugin(),
54
58
  virtualizedPlugin(),
@@ -0,0 +1,16 @@
1
+ const {
2
+ generateMergedTranslations,
3
+ writeTranslationsToDisk,
4
+ } = require("../../utils/packageTranslations");
5
+
6
+ const packageTranslationsPlugin = () => ({
7
+ name: "package-translations",
8
+ setup(build) {
9
+ build.onStart(() => {
10
+ const mergedTranslations = generateMergedTranslations();
11
+ writeTranslationsToDisk(mergedTranslations);
12
+ });
13
+ },
14
+ });
15
+
16
+ module.exports = { packageTranslationsPlugin };
@@ -1,5 +1,13 @@
1
+ /* eslint-disable @bigbinary/neeto/no-dangling-constants */
1
2
  /* eslint-disable import/extensions */
2
- const PkgTranslations = require("@bigbinary/neeto-commons-frontend/configs/scripts/getPkgTranslations.js");
3
+ const translationImports = require("@bigbinary/neeto-commons-frontend/configs/scripts/buildTranslationImports.js");
4
+ const englishTranslations = require("@bigbinary/neeto-commons-frontend/configs/scripts/getEnglishTranslation.js");
5
+
6
+ const PREVAL_IMPORT_TRANSLATION_IMPORTS =
7
+ 'preval.require("../../configs/scripts/buildTranslationImports.js")';
8
+
9
+ const PREVAL_IMPORT_ENGLISH_TRANSLATIONS =
10
+ 'preval.require("../../configs/scripts/getEnglishTranslation.js")';
3
11
 
4
12
  const prevalPlugin = () => ({
5
13
  name: "preval-plugin",
@@ -13,12 +21,14 @@ const prevalPlugin = () => ({
13
21
  const fs = require("fs").promises;
14
22
  const contents = await fs.readFile(args.path, "utf8");
15
23
 
16
- const transformedContents = contents.replace(
17
- `preval.require("../../configs/scripts/getPkgTranslations.js")`,
18
- JSON.stringify(PkgTranslations)
19
- );
24
+ const transformedContent = contents
25
+ .replace(PREVAL_IMPORT_TRANSLATION_IMPORTS, translationImports)
26
+ .replace(
27
+ PREVAL_IMPORT_ENGLISH_TRANSLATIONS,
28
+ JSON.stringify(englishTranslations)
29
+ );
20
30
 
21
- return { contents: transformedContents, loader: "js" };
31
+ return { contents: transformedContent, loader: "js" };
22
32
  }
23
33
  );
24
34
  },
@@ -0,0 +1,22 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+
4
+ const translationsDir = path.resolve("dist/translations");
5
+ if (!fs.existsSync(translationsDir)) {
6
+ fs.mkdirSync(translationsDir, { recursive: true });
7
+ }
8
+
9
+ const files = fs
10
+ .readdirSync(translationsDir)
11
+ .filter(file => file.endsWith(".json"));
12
+
13
+ // Create a map like { "en": () => import("dist/translations/en.json") }
14
+ const entries = files.map(file => {
15
+ const lang = path.basename(file, ".json");
16
+
17
+ return `"${lang}": () => import("${process.cwd()}/dist/translations/${file}")`;
18
+ });
19
+
20
+ const content = `{ ${entries.join(",\n")} }`;
21
+
22
+ module.exports = content;
@@ -0,0 +1,17 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+
4
+ const filePath = path.resolve(process.cwd(), "dist/translations/en.json");
5
+
6
+ let englishTranslations = {};
7
+
8
+ try {
9
+ if (fs.existsSync(filePath)) {
10
+ const content = fs.readFileSync(filePath, "utf8");
11
+ englishTranslations = JSON.parse(content);
12
+ }
13
+ } catch {
14
+ englishTranslations = {};
15
+ }
16
+
17
+ module.exports = englishTranslations;
@@ -0,0 +1,90 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+
4
+ const { mergeDeepLeft } = require("ramda");
5
+
6
+ const getPkgTransPath = pkg => {
7
+ const packageDir = path.join(__dirname, "../../..");
8
+
9
+ const basePath = path.join(packageDir, pkg);
10
+ const transPath1 = path.join(basePath, "app/javascript/src/translations");
11
+ const transPath2 = path.join(basePath, "src/translations");
12
+
13
+ return fs.existsSync(transPath1) ? transPath1 : transPath2;
14
+ };
15
+
16
+ const loadTranslations = translationsDir => {
17
+ try {
18
+ const jsonFiles = fs
19
+ .readdirSync(translationsDir)
20
+ .filter(file => file.endsWith(".json"))
21
+ .map(file => path.join(translationsDir, file));
22
+
23
+ const translations = {};
24
+
25
+ jsonFiles.forEach(jsonFile => {
26
+ const content = fs.readFileSync(jsonFile, "utf8");
27
+ const basename = path.basename(jsonFile, ".json");
28
+ translations[basename] = { translation: JSON.parse(content) };
29
+ });
30
+
31
+ return translations;
32
+ } catch {
33
+ return {};
34
+ }
35
+ };
36
+
37
+ const generatePackageTranslations = () => {
38
+ const packageDir = "./node_modules/@bigbinary";
39
+ const packages = fs.readdirSync(packageDir);
40
+
41
+ return packages
42
+ .map(pkg => {
43
+ const transPath = getPkgTransPath(pkg);
44
+
45
+ return fs.existsSync(transPath) ? loadTranslations(transPath) : {};
46
+ })
47
+ .reduce(mergeDeepLeft, {});
48
+ };
49
+
50
+ const getHostTranslations = () => {
51
+ const hostTranslationsDir = "./app/javascript/src/translations";
52
+
53
+ return fs.existsSync(hostTranslationsDir)
54
+ ? loadTranslations(hostTranslationsDir)
55
+ : {};
56
+ };
57
+
58
+ const generateMergedTranslations = () => {
59
+ const packageTranslations = generatePackageTranslations();
60
+ const hostTranslations = getHostTranslations();
61
+
62
+ return mergeDeepLeft(hostTranslations, packageTranslations);
63
+ };
64
+
65
+ const writeTranslationsToDisk = mergedTranslations => {
66
+ const publicTranslationsDir = path.join(
67
+ process.cwd(),
68
+ "dist",
69
+ "translations"
70
+ );
71
+
72
+ if (!fs.existsSync(publicTranslationsDir)) {
73
+ fs.mkdirSync(publicTranslationsDir, { recursive: true });
74
+ }
75
+
76
+ Object.keys(mergedTranslations).forEach(lang => {
77
+ const translationData = mergedTranslations[lang];
78
+ const outputPath = path.join(publicTranslationsDir, `${lang}.json`);
79
+
80
+ fs.writeFileSync(
81
+ outputPath,
82
+ JSON.stringify(translationData.translation, null, 2)
83
+ );
84
+ });
85
+ };
86
+
87
+ module.exports = {
88
+ generateMergedTranslations,
89
+ writeTranslationsToDisk,
90
+ };
@@ -1,9 +1,13 @@
1
1
  /* eslint-disable import/extensions */
2
+
2
3
  const { default: viteYaml } = require("@modyfi/vite-plugin-yaml");
3
4
  const { default: react } = require("@vitejs/plugin-react");
4
5
  const dotenv = require("dotenv");
5
6
 
6
7
  const { nanoDevelopmentPlugin } = require("./plugins/nanoDevelopment.js");
8
+ const {
9
+ packageTranslationsPlugin,
10
+ } = require("./plugins/packageTranslations.js");
7
11
  const { prevalPlugin } = require("./plugins/preval.js");
8
12
  const { reactGiphyPlugin } = require("./plugins/reactGiphy.js");
9
13
  const svgr = require("./plugins/svgr.js");
@@ -25,6 +29,7 @@ const config = {
25
29
  react({ babel: VITE_BABEL_CONFIG }),
26
30
  virtualizedPlugin(),
27
31
  reactGiphyPlugin(),
32
+ packageTranslationsPlugin(),
28
33
  prevalPlugin(),
29
34
  viteYaml(),
30
35
  nanoDevelopmentPlugin(),
@@ -0,0 +1,14 @@
1
+ const {
2
+ generateMergedTranslations,
3
+ writeTranslationsToDisk,
4
+ } = require("../../utils/packageTranslations");
5
+
6
+ const packageTranslationsPlugin = () => ({
7
+ name: "package-translations",
8
+ buildStart() {
9
+ const mergedTranslations = generateMergedTranslations();
10
+ writeTranslationsToDisk(mergedTranslations);
11
+ },
12
+ });
13
+
14
+ module.exports = { packageTranslationsPlugin };
@@ -1,23 +1,45 @@
1
1
  /* eslint-disable import/extensions */
2
2
  /* eslint-disable @bigbinary/neeto/no-dangling-constants */
3
3
 
4
- const getUncachedTranslations = () => {
5
- delete require.cache[require.resolve("../../scripts/getPkgTranslations.js")];
4
+ const getUncachedTranslationImports = () => {
5
+ delete require.cache[
6
+ require.resolve("../../scripts/buildTranslationImports.js")
7
+ ];
6
8
 
7
- return require("../../scripts/getPkgTranslations.js");
9
+ return require("../../scripts/buildTranslationImports.js");
8
10
  };
9
11
 
10
- const PREVAL_IMPORT =
11
- 'preval.require("../../configs/scripts/getPkgTranslations.js")';
12
+ const getUncachedEnglishTranslations = () => {
13
+ delete require.cache[
14
+ require.resolve("../../scripts/getEnglishTranslation.js")
15
+ ];
16
+
17
+ return require("../../scripts/getEnglishTranslation.js");
18
+ };
19
+
20
+ const PREVAL_IMPORT_TRANSLATION_IMPORTS =
21
+ 'preval.require("../../configs/scripts/buildTranslationImports.js")';
22
+
23
+ const PREVAL_IMPORT_ENGLISH_TRANSLATIONS =
24
+ 'preval.require("../../configs/scripts/getEnglishTranslation.js")';
12
25
 
13
26
  const prevalPlugin = () => ({
14
27
  name: "preval-plugin",
15
28
  transform(code, id) {
16
- if (id.includes("node_modules") && code.includes(PREVAL_IMPORT)) {
17
- const replacedCode = code.replace(
18
- PREVAL_IMPORT,
19
- JSON.stringify(getUncachedTranslations())
20
- );
29
+ if (
30
+ id.includes("node_modules") &&
31
+ (code.includes(PREVAL_IMPORT_TRANSLATION_IMPORTS) ||
32
+ code.includes(PREVAL_IMPORT_ENGLISH_TRANSLATIONS))
33
+ ) {
34
+ const replacedCode = code
35
+ .replace(
36
+ PREVAL_IMPORT_TRANSLATION_IMPORTS,
37
+ getUncachedTranslationImports()
38
+ )
39
+ .replace(
40
+ PREVAL_IMPORT_ENGLISH_TRANSLATIONS,
41
+ JSON.stringify(getUncachedEnglishTranslations())
42
+ );
21
43
 
22
44
  return { code: replacedCode, map: null };
23
45
  }
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var i18next = require('i18next');
6
6
  var ramda = require('ramda');
7
7
  var reactI18next = require('react-i18next');
8
+ var utils_retryImport = require('../utils/retryImport.js');
8
9
  var initializers_constants = require('./constants.js');
9
10
  var initializers_utils_customFormatters = require('./utils/customFormatters.js');
10
11
  var initializers_utils_customPostProcessors = require('./utils/customPostProcessors.js');
@@ -427,147 +428,52 @@ var Browser = /*#__PURE__*/function () {
427
428
  }();
428
429
  Browser.type = 'languageDetector';
429
430
 
430
- var generic = {
431
- error: "Something went wrong. Please try again later."
432
- };
433
- var authentication = {
434
- notLoggedIn: "Could not authenticate, please login to continue!",
435
- couldNotAuth: "Could not authenticate with the provided {{parameter}}.",
436
- incorrectPassword: "Current password is incorrect. Please try again.",
437
- incorrectEmailPassword: "Incorrect email or password. Please try again."
438
- };
439
- var authorization = {
440
- unauthorized: "You are not authorized to perform this action."
441
- };
442
- var resource = {
443
- add_one: "{{entity}} has been added successfully.",
444
- add_other: "{{entity}} have been added successfully.",
445
- save: "{{entity}} has been saved successfully.",
446
- save_one: "{{entity}} has been saved successfully.",
447
- save_other: "{{entity}} have been saved successfully.",
448
- update: "{{entity}} has been updated successfully.",
449
- update_one: "{{entity}} has been updated successfully.",
450
- update_other: "{{entity}} have been updated successfully.",
451
- delete_one: "{{entity}} has been deleted successfully.",
452
- delete_other: "{{entity}} have been deleted successfully.",
453
- clone: "{{entity}} has been cloned successfully.",
454
- notFound: "{{entity}} does not exist.",
455
- remove_one: "{{entity}} has been removed successfully.",
456
- remove_other: "{{entity}} have been removed successfully.",
457
- sent: "{{entity}} sent successfully.",
458
- merged: "{{entity}} have been successfully merged.",
459
- disconnected: "{{entity}} has been successfully disconnected."
460
- };
461
- var otp = {
462
- sent: "OTP has been sent successfully.",
463
- invalid: "Invalid OTP",
464
- verified: "OTP has been verified successfully."
465
- };
466
- var upload = {
467
- error: "An error occurred while uploading the file"
468
- };
469
- var image = {
470
- profile: {
471
- removalFailed: "Failed to remove profile picture",
472
- removalSuccess: "Profile picture successfully removed"
473
- },
474
- contentTypeInvalid: "Other than jpg, png, svg are not supported",
475
- sizeOutOfRange: "Should not be more than {{maxSize, number}} MB"
476
- };
477
- var userRole = {
478
- deactivateActiveAdmin: "You cannot deactivate active admin from the workspace!"
479
- };
480
- var activeRecord = {
481
- error: {
482
- blankName: "Name can't be blank",
483
- blankDescription: "Description can't be blank",
484
- blankValue: "Value can't be blank",
485
- prefixType: "Prefix type {{value}} is not valid",
486
- minimumEntryLimit: "Minimum entry limit must be less than or equal to {{maximumEntryLimit, number}}",
487
- maximumEntryLimit: "Maximum entry limit must be greater than or equal to {{minimumEntryLimit, number}}"
488
- }
489
- };
490
- var sessions = {
491
- expiry: "Your session has expired. Please login again."
492
- };
493
- var payment = {
494
- error: {
495
- incomplete: "Your payment could not be completed"
496
- }
497
- };
498
- var invitations = {
499
- deleted_one: "Invitation has been deleted successfully",
500
- deleted_other: "{{count, number}} Invitations have been deleted successfully",
501
- sent_one: "Invitation has been sent successfully",
502
- sent_other: "{{count, number}} Invitations have been sent successfully",
503
- notFound: "{{email}} was not invited to test this website."
504
- };
505
- var github = {
506
- error: {
507
- webhookPermissionDenied: "Permission denied. Ensure you have permission to create webhooks for the repository.",
508
- primaryNonDeletable: "Primary Github account cannot be deleted."
509
- }
510
- };
511
- var neetoCommons = {
512
- fallbackComponent: {
513
- somethingWentWrong: "Sorry, something went wrong.",
514
- description: "Please try <reloading>reloading</reloading> the page.<br> If the problem persists, <contactus>contact us</contactus>."
515
- },
516
- toastr: {
517
- success: {
518
- copiedToClipboard: "Copied to clipboard!"
519
- },
520
- error: {
521
- noInternetConnection: "No Internet Connection.",
522
- networkError: "Network error. Please check your connection and try again."
523
- }
524
- },
525
- notice: {
526
- errorOccurred: "Some error occurred."
527
- },
528
- validators: {
529
- isRequired: "{{what}} is required.",
530
- mustNotContainCapitalLetters: "{{what}} must not contain capital letters.",
531
- mustNotContainSpaces: "{{what}} must not contain spaces.",
532
- mustNotContainSpecialCharactersExceptHyphen: "{{what}} must not contain any special characters, except '-'",
533
- mustNotStartOrEndWithSpecialCharacters: "{{what}} must not start or end with special characters."
534
- },
535
- copyToClipboard: {
536
- failed: "Failed to copy to clipboard"
537
- }
538
- };
539
- var commonsEn = {
540
- generic: generic,
541
- authentication: authentication,
542
- authorization: authorization,
543
- resource: resource,
544
- otp: otp,
545
- upload: upload,
546
- image: image,
547
- userRole: userRole,
548
- activeRecord: activeRecord,
549
- sessions: sessions,
550
- payment: payment,
551
- invitations: invitations,
552
- github: github,
553
- neetoCommons: neetoCommons
431
+ var resourcesToBackend = function resourcesToBackend(res) {
432
+ return {
433
+ type: 'backend',
434
+ init: function init(services, backendOptions, i18nextOptions) {},
435
+ read: function read(language, namespace, callback) {
436
+ if (typeof res === 'function') {
437
+ if (res.length < 3) {
438
+ try {
439
+ var r = res(language, namespace);
440
+ if (r && typeof r.then === 'function') {
441
+ r.then(function (data) {
442
+ return callback(null, data && data.default || data);
443
+ }).catch(callback);
444
+ } else {
445
+ callback(null, r);
446
+ }
447
+ } catch (err) {
448
+ callback(err);
449
+ }
450
+ return;
451
+ }
452
+ res(language, namespace, callback);
453
+ return;
454
+ }
455
+ callback(null, res && res[language] && res[language][namespace]);
456
+ }
457
+ };
554
458
  };
555
459
 
556
460
  // eslint-disable-next-line import/no-mutable-exports
557
461
  exports.taxonomies = {};
558
- var initializeI18n = function initializeI18n(hostTranslations) {
462
+ var initializeI18n = function initializeI18n() {
559
463
  var _window$globalProps, _window$globalProps2;
464
+ var hostTranslations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
560
465
  var enableDirAttribute = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
561
466
  document.documentElement.removeAttribute("lang");
562
467
  var 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;
563
468
  if (userLanguage) document.documentElement.setAttribute("lang", userLanguage);
564
- var packageTranslations = preval.require("../../../configs/scripts/getPkgTranslations.js");
565
- var commonsTranslations = {
469
+ var translationImports = preval.require("../../../configs/scripts/buildTranslationImports.js");
470
+ var englishTranslations = preval.require("../../../configs/scripts/getEnglishTranslation.js");
471
+ var englishResource = {
566
472
  en: {
567
- translation: commonsEn
473
+ translation: englishTranslations || {}
568
474
  }
569
475
  };
570
- var resources = [hostTranslations, commonsTranslations, packageTranslations].reduce(ramda.mergeDeepLeft);
476
+ var resources = ramda.mergeDeepLeft(hostTranslations, englishResource);
571
477
  var defaultTaxonomyKeys = Object.keys(resources.en.translation.taxonomyDefaultLabels || {});
572
478
  var defaultTaxonomies = Object.fromEntries(defaultTaxonomyKeys.map(function (key) {
573
479
  return [key, {
@@ -577,8 +483,11 @@ var initializeI18n = function initializeI18n(hostTranslations) {
577
483
  }));
578
484
  var hostTaxonomies = ((_window$globalProps2 = window.globalProps) === null || _window$globalProps2 === void 0 ? void 0 : _window$globalProps2.taxonomies) || {};
579
485
  exports.taxonomies = initializers_utils_utils.replaceNullValuesWithGetter(ramda.mergeDeepLeft(hostTaxonomies, defaultTaxonomies));
580
- i18next.use(Browser).use(reactI18next.initReactI18next).use(initializers_utils_customPostProcessors.sentenceCaseProcessor).init({
486
+ i18next.use(Browser).use(reactI18next.initReactI18next).use(initializers_utils_customPostProcessors.sentenceCaseProcessor).use(resourcesToBackend(function (language) {
487
+ return utils_retryImport(translationImports === null || translationImports === void 0 ? void 0 : translationImports[language]);
488
+ })).init({
581
489
  resources: resources,
490
+ partialBundledLanguages: true,
582
491
  fallbackLng: "en",
583
492
  interpolation: {
584
493
  defaultVariables: {