@bigbinary/neeto-commons-frontend 4.13.95 → 4.13.96
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/configs/esbuild/index.js +4 -0
- package/configs/esbuild/plugins/packageTranslations.js +16 -0
- package/configs/esbuild/plugins/preval.js +16 -6
- package/configs/esbuild/plugins/reactGiphy.js +1 -0
- package/configs/scripts/buildTranslationImports.js +21 -0
- package/configs/scripts/getEnglishTranslation.js +11 -0
- package/configs/utils/packageTranslations.js +90 -0
- package/configs/vite/index.js +5 -0
- package/configs/vite/plugins/packageTranslations.js +14 -0
- package/configs/vite/plugins/preval.js +17 -11
- package/dist/cjs/initializers/i18n.js +120 -183
- package/dist/cjs/initializers/i18n.js.map +1 -1
- package/dist/cjs/initializers/index.js +43 -19
- package/dist/cjs/initializers/index.js.map +1 -1
- package/dist/cjs/react-utils/mount/mount.js +68 -69
- package/dist/cjs/react-utils/mount/mount.js.map +1 -1
- package/dist/initializers/i18n.js +120 -183
- package/dist/initializers/i18n.js.map +1 -1
- package/dist/initializers/index.js +43 -19
- package/dist/initializers/index.js.map +1 -1
- package/dist/react-utils/mount/mount.js +68 -69
- package/dist/react-utils/mount/mount.js.map +1 -1
- package/initializers.d.ts +1 -1
- package/package.json +4 -2
- package/react-utils.d.ts +3 -3
- package/src/translations/ar.json +111 -0
- package/src/translations/bg.json +111 -0
- package/src/translations/ca.json +111 -0
- package/src/translations/cs.json +111 -0
- package/src/translations/da.json +111 -0
- package/src/translations/de.json +111 -0
- package/src/translations/en.json +111 -0
- package/src/translations/es-MX.json +111 -0
- package/src/translations/es.json +111 -0
- package/src/translations/et.json +111 -0
- package/src/translations/fi.json +111 -0
- package/src/translations/fil.json +111 -0
- package/src/translations/fr.json +111 -0
- package/src/translations/he.json +111 -0
- package/src/translations/hi.json +111 -0
- package/src/translations/hr.json +111 -0
- package/src/translations/id.json +111 -0
- package/src/translations/it.json +111 -0
- package/src/translations/ja.json +111 -0
- package/src/translations/ko.json +111 -0
- package/src/translations/nl.json +111 -0
- package/src/translations/pl.json +111 -0
- package/src/translations/pt-BR.json +111 -0
- package/src/translations/pt.json +111 -0
- package/src/translations/ro.json +111 -0
- package/src/translations/ru.json +111 -0
- package/src/translations/sk.json +111 -0
- package/src/translations/sl.json +111 -0
- package/src/translations/sv.json +111 -0
- package/src/translations/th.json +111 -0
- package/src/translations/tr.json +111 -0
- package/src/translations/uk.json +111 -0
- package/src/translations/vi.json +111 -0
- package/src/translations/zh-CN.json +111 -0
- package/src/translations/zh-TW.json +111 -0
- package/configs/scripts/getPkgTranslations.js +0 -45
package/configs/esbuild/index.js
CHANGED
|
@@ -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
|
|
3
|
+
const getTranslationImports = require("../../scripts/buildTranslationImports.js");
|
|
4
|
+
const getEnglishTranslations = require("../../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
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
24
|
+
const transformedContent = contents
|
|
25
|
+
.replace(PREVAL_IMPORT_TRANSLATION_IMPORTS, getTranslationImports())
|
|
26
|
+
.replace(
|
|
27
|
+
PREVAL_IMPORT_ENGLISH_TRANSLATIONS,
|
|
28
|
+
JSON.stringify(getEnglishTranslations())
|
|
29
|
+
);
|
|
20
30
|
|
|
21
|
-
return { contents:
|
|
31
|
+
return { contents: transformedContent, loader: "js" };
|
|
22
32
|
}
|
|
23
33
|
);
|
|
24
34
|
},
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
|
|
4
|
+
const getTranslationImports = () => {
|
|
5
|
+
const translationsDir = path.resolve("dist/translations");
|
|
6
|
+
|
|
7
|
+
const files = fs
|
|
8
|
+
.readdirSync(translationsDir)
|
|
9
|
+
.filter(file => file.endsWith(".json"));
|
|
10
|
+
|
|
11
|
+
// Create a map like { "en": () => import("dist/translations/en.json") }
|
|
12
|
+
const entries = files.map(file => {
|
|
13
|
+
const lang = path.basename(file, ".json");
|
|
14
|
+
|
|
15
|
+
return `"${lang}": () => import("${process.cwd()}/dist/translations/${file}")`;
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return `{ ${entries.join(",\n")} }`;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
module.exports = getTranslationImports;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
|
|
4
|
+
const getEnglishTranslations = () => {
|
|
5
|
+
const filePath = path.resolve(process.cwd(), "dist/translations/en.json");
|
|
6
|
+
const content = fs.readFileSync(filePath, "utf8");
|
|
7
|
+
|
|
8
|
+
return JSON.parse(content);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
module.exports = getEnglishTranslations;
|
|
@@ -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
|
+
};
|
package/configs/vite/index.js
CHANGED
|
@@ -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,29 @@
|
|
|
1
1
|
/* eslint-disable import/extensions */
|
|
2
2
|
/* eslint-disable @bigbinary/neeto/no-dangling-constants */
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
|
|
4
|
+
const getTranslationImports = require("../../scripts/buildTranslationImports.js");
|
|
5
|
+
const getEnglishTranslations = require("../../scripts/getEnglishTranslation.js");
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const PREVAL_IMPORT_TRANSLATION_IMPORTS =
|
|
8
|
+
'preval.require("../../configs/scripts/buildTranslationImports.js")';
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
'preval.require("../../configs/scripts/
|
|
10
|
+
const PREVAL_IMPORT_ENGLISH_TRANSLATIONS =
|
|
11
|
+
'preval.require("../../configs/scripts/getEnglishTranslation.js")';
|
|
12
12
|
|
|
13
13
|
const prevalPlugin = () => ({
|
|
14
14
|
name: "preval-plugin",
|
|
15
15
|
transform(code, id) {
|
|
16
|
-
if (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
if (
|
|
17
|
+
id.includes("node_modules") &&
|
|
18
|
+
(code.includes(PREVAL_IMPORT_TRANSLATION_IMPORTS) ||
|
|
19
|
+
code.includes(PREVAL_IMPORT_ENGLISH_TRANSLATIONS))
|
|
20
|
+
) {
|
|
21
|
+
const replacedCode = code
|
|
22
|
+
.replace(PREVAL_IMPORT_TRANSLATION_IMPORTS, getTranslationImports())
|
|
23
|
+
.replace(
|
|
24
|
+
PREVAL_IMPORT_ENGLISH_TRANSLATIONS,
|
|
25
|
+
JSON.stringify(getEnglishTranslations())
|
|
26
|
+
);
|
|
21
27
|
|
|
22
28
|
return { code: replacedCode, map: null };
|
|
23
29
|
}
|
|
@@ -2,13 +2,16 @@
|
|
|
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');
|
|
9
|
+
var utils_retryImport = require('../utils/retryImport.js');
|
|
8
10
|
var initializers_constants = require('./constants.js');
|
|
9
11
|
var initializers_utils_customFormatters = require('./utils/customFormatters.js');
|
|
10
12
|
var initializers_utils_customPostProcessors = require('./utils/customPostProcessors.js');
|
|
11
13
|
var initializers_utils_utils = require('./utils/utils.js');
|
|
14
|
+
require('../_commonjsHelpers-BJu3ubxk.js');
|
|
12
15
|
require('dompurify');
|
|
13
16
|
require('../typeof-D4ZZ_FlZ.js');
|
|
14
17
|
require('../slicedToArray-BcL7fKuL.js');
|
|
@@ -427,195 +430,129 @@ var Browser = /*#__PURE__*/function () {
|
|
|
427
430
|
}();
|
|
428
431
|
Browser.type = 'languageDetector';
|
|
429
432
|
|
|
430
|
-
var
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
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
|
|
433
|
+
var resourcesToBackend = function resourcesToBackend(res) {
|
|
434
|
+
return {
|
|
435
|
+
type: 'backend',
|
|
436
|
+
init: function init(services, backendOptions, i18nextOptions) {},
|
|
437
|
+
read: function read(language, namespace, callback) {
|
|
438
|
+
if (typeof res === 'function') {
|
|
439
|
+
if (res.length < 3) {
|
|
440
|
+
try {
|
|
441
|
+
var r = res(language, namespace);
|
|
442
|
+
if (r && typeof r.then === 'function') {
|
|
443
|
+
r.then(function (data) {
|
|
444
|
+
return callback(null, data && data.default || data);
|
|
445
|
+
}).catch(callback);
|
|
446
|
+
} else {
|
|
447
|
+
callback(null, r);
|
|
448
|
+
}
|
|
449
|
+
} catch (err) {
|
|
450
|
+
callback(err);
|
|
451
|
+
}
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
res(language, namespace, callback);
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
callback(null, res && res[language] && res[language][namespace]);
|
|
458
|
+
}
|
|
459
|
+
};
|
|
554
460
|
};
|
|
555
461
|
|
|
556
462
|
// eslint-disable-next-line import/no-mutable-exports
|
|
557
463
|
exports.taxonomies = {};
|
|
558
|
-
var initializeI18n = function
|
|
559
|
-
var
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
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
|
+
}
|
|
598
538
|
});
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
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();
|
|
602
549
|
}
|
|
603
|
-
},
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
lookupCookie: "lang"
|
|
610
|
-
}
|
|
611
|
-
});
|
|
612
|
-
if (enableDirAttribute) {
|
|
613
|
-
document.documentElement.setAttribute("dir", i18next.dir() || "ltr");
|
|
614
|
-
}
|
|
615
|
-
if (!userLanguage) {
|
|
616
|
-
document.documentElement.setAttribute("lang", i18next.resolvedLanguage || "en");
|
|
617
|
-
}
|
|
618
|
-
};
|
|
550
|
+
}, _callee);
|
|
551
|
+
}));
|
|
552
|
+
return function initializeI18n() {
|
|
553
|
+
return _ref.apply(this, arguments);
|
|
554
|
+
};
|
|
555
|
+
}();
|
|
619
556
|
|
|
620
557
|
exports.default = initializeI18n;
|
|
621
558
|
//# sourceMappingURL=i18n.js.map
|