devexpress-aspnetcore-spreadsheet 25.1.7 → 25.2.2-beta

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.
@@ -1,102 +1,97 @@
1
- /**
2
- * DevExpress AspNetCore Spreadsheet (dx-localization-builder.js)
3
- * Version: 25.1.7
4
- * Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED
5
- * License: https://www.devexpress.com/Support/EULAs
6
- */
7
- /**
8
- * DevExpress ASPxSpreadsheet (dx-localization-builder.js)
9
- * Version: 25.1.6-build-25280-1634
10
- * Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED
11
- * License: https://www.devexpress.com/Support/EULAs",
12
- */
13
- const jsHeader =
14
- `(function(root, factory) {
15
- if(typeof define === 'function' && define.amd) {
16
- define(function(require) {
17
- factory(require("devextreme/localization"));
18
- });
19
- } else if(typeof module === "object" && module.exports) {
20
- factory(require("devextreme/localization"));
21
- } else {
22
- factory(DevExpress.localization);
23
- }
24
- }(this, function(localization) {
25
- localization.loadMessages(`;
26
-
27
- const jsFooter =
28
- `);
29
- }));`
30
-
31
- const fs = require('fs');
32
- const path = require('path');
33
-
34
- function getLocale(fileName) {
35
- const parts = fileName.split('.');
36
- return parts[parts.length - 2];
37
- }
38
-
39
- function writeFile(filePath, content) {
40
- const dirPath = path.dirname(filePath);
41
- if (!fs.existsSync(dirPath))
42
- fs.mkdirSync(dirPath, { recursive: true });
43
- fs.writeFileSync(filePath, content, 'utf8');
44
- console.log(`${filePath} created`);
45
- }
46
-
47
- function getFullPath(p) {
48
- return path.normalize(path.isAbsolute(p) ? p : path.join(process.cwd(), p));
49
- }
50
-
51
- // Possible calls:
52
- // * generate(souceDir, targetDir)
53
- // * generate(sourceFile, targetFile)
54
- function generate(sourcePath, targetPath) {
55
- sourcePath = getFullPath(sourcePath);
56
- targetPath = getFullPath(targetPath);
57
- if (!fs.existsSync(sourcePath))
58
- throw Error('Source path is incorrect');
59
- if (fs.lstatSync(sourcePath).isFile()) {
60
- const extension = path.extname(targetPath);
61
- generateFromFile(sourcePath, targetPath.slice(0, -extension.length),
62
- getLocale(path.basename(sourcePath)), extension == '.js', extension == '.json');
63
- }
64
- else {
65
- let numFiles = 0;
66
- fs.readdirSync(sourcePath).forEach(fileName => {
67
- const locale = getLocale(fileName);
68
- if (locale) {
69
- numFiles++;
70
- generateFromFile(path.join(sourcePath, fileName),
71
- path.join(targetPath, fileName.slice(0, -path.extname(fileName).length)),
72
- locale, true, true);
73
- }
74
- });
75
- if (numFiles == 0)
76
- console.log(`No source files found`);
77
- }
78
- }
79
-
80
- // targetPath without extension
81
- function generateFromFile(sourceFilePath, targetPath, locale, generateJsContent, generateJsonContent) {
82
- if (!locale) {
83
- console.log(`Incorrect locale ${locale}`);
84
- return;
85
- }
86
- const correctJsonContent = {
87
- [locale]: JSON.parse(fs.readFileSync(sourceFilePath, 'utf8'))
88
- };
89
- const jsonContentAsString = JSON.stringify(correctJsonContent, null, ' ');
90
- if (generateJsContent)
91
- writeFile(targetPath +'.js', jsHeader + jsonContentAsString + jsFooter);
92
- if (generateJsonContent)
93
- writeFile(targetPath + '.json', jsonContentAsString);
94
- }
95
-
96
- if (require.main === module) {
97
- if (process.argv.length != 4)
98
- throw Error('Incorrect arguments count. localization-builder.js sourcePath targetPath');
99
- generate(process.argv[2], process.argv[3]);
100
- }
101
-
1
+ /**
2
+ * DevExpress AspNetCore Spreadsheet (localization-builder.js)
3
+ * Version: 25.2.2-beta
4
+ * Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED
5
+ * License: https://www.devexpress.com/Support/EULAs
6
+ */
7
+
8
+ const jsHeader =
9
+ `(function(root, factory) {
10
+ if(typeof define === 'function' && define.amd) {
11
+ define(function(require) {
12
+ factory(require("devextreme/localization"));
13
+ });
14
+ } else if(typeof module === "object" && module.exports) {
15
+ factory(require("devextreme/localization"));
16
+ } else {
17
+ factory(DevExpress.localization);
18
+ }
19
+ }(this, function(localization) {
20
+ localization.loadMessages(`;
21
+
22
+ const jsFooter =
23
+ `);
24
+ }));`
25
+
26
+ const fs = require('fs');
27
+ const path = require('path');
28
+
29
+ function getLocale(fileName) {
30
+ const parts = fileName.split('.');
31
+ return parts[parts.length - 2];
32
+ }
33
+
34
+ function writeFile(filePath, content) {
35
+ const dirPath = path.dirname(filePath);
36
+ if (!fs.existsSync(dirPath))
37
+ fs.mkdirSync(dirPath, { recursive: true });
38
+ fs.writeFileSync(filePath, content, 'utf8');
39
+ console.log(`${filePath} created`);
40
+ }
41
+
42
+ function getFullPath(p) {
43
+ return path.normalize(path.isAbsolute(p) ? p : path.join(process.cwd(), p));
44
+ }
45
+
46
+ // Possible calls:
47
+ // * generate(souceDir, targetDir)
48
+ // * generate(sourceFile, targetFile)
49
+ function generate(sourcePath, targetPath) {
50
+ sourcePath = getFullPath(sourcePath);
51
+ targetPath = getFullPath(targetPath);
52
+ if (!fs.existsSync(sourcePath))
53
+ throw Error('Source path is incorrect');
54
+ if (fs.lstatSync(sourcePath).isFile()) {
55
+ const extension = path.extname(targetPath);
56
+ generateFromFile(sourcePath, targetPath.slice(0, -extension.length),
57
+ getLocale(path.basename(sourcePath)), extension == '.js', extension == '.json');
58
+ }
59
+ else {
60
+ let numFiles = 0;
61
+ fs.readdirSync(sourcePath).forEach(fileName => {
62
+ const locale = getLocale(fileName);
63
+ if (locale) {
64
+ numFiles++;
65
+ generateFromFile(path.join(sourcePath, fileName),
66
+ path.join(targetPath, fileName.slice(0, -path.extname(fileName).length)),
67
+ locale, true, true);
68
+ }
69
+ });
70
+ if (numFiles == 0)
71
+ console.log(`No source files found`);
72
+ }
73
+ }
74
+
75
+ // targetPath without extension
76
+ function generateFromFile(sourceFilePath, targetPath, locale, generateJsContent, generateJsonContent) {
77
+ if (!locale) {
78
+ console.log(`Incorrect locale ${locale}`);
79
+ return;
80
+ }
81
+ const correctJsonContent = {
82
+ [locale]: JSON.parse(fs.readFileSync(sourceFilePath, 'utf8'))
83
+ };
84
+ const jsonContentAsString = JSON.stringify(correctJsonContent, null, ' ');
85
+ if (generateJsContent)
86
+ writeFile(targetPath +'.js', jsHeader + jsonContentAsString + jsFooter);
87
+ if (generateJsonContent)
88
+ writeFile(targetPath + '.json', jsonContentAsString);
89
+ }
90
+
91
+ if (require.main === module) {
92
+ if (process.argv.length != 4)
93
+ throw Error('Incorrect arguments count. localization-builder.js sourcePath targetPath');
94
+ generate(process.argv[2], process.argv[3]);
95
+ }
96
+
102
97
  module.exports = generate;