@lingui/format-json 5.9.2 → 6.0.0-next.0
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/json.d.mts +2 -1
- package/package.json +15 -10
- package/dist/json.cjs +0 -73
- package/dist/json.d.cts +0 -31
- package/dist/json.d.ts +0 -31
package/dist/json.d.mts
CHANGED
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingui/format-json",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0-next.0",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"description": "JSON format for Lingui Catalogs",
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./dist/json.mjs"
|
|
8
|
+
},
|
|
8
9
|
"sideEffects": false,
|
|
9
10
|
"license": "MIT",
|
|
10
11
|
"keywords": [
|
|
@@ -20,8 +21,8 @@
|
|
|
20
21
|
"multilingual"
|
|
21
22
|
],
|
|
22
23
|
"scripts": {
|
|
23
|
-
"build": "
|
|
24
|
-
"
|
|
24
|
+
"build": "unbuild",
|
|
25
|
+
"check-types": "tsc --noEmit"
|
|
25
26
|
},
|
|
26
27
|
"homepage": "https://lingui.dev",
|
|
27
28
|
"repository": {
|
|
@@ -33,7 +34,7 @@
|
|
|
33
34
|
"url": "https://github.com/lingui/js-lingui/issues"
|
|
34
35
|
},
|
|
35
36
|
"engines": {
|
|
36
|
-
"node": ">=
|
|
37
|
+
"node": ">=22.19.0"
|
|
37
38
|
},
|
|
38
39
|
"files": [
|
|
39
40
|
"LICENSE",
|
|
@@ -41,10 +42,14 @@
|
|
|
41
42
|
"dist/"
|
|
42
43
|
],
|
|
43
44
|
"dependencies": {
|
|
44
|
-
"@lingui/conf": "
|
|
45
|
+
"@lingui/conf": "6.0.0-next.0"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
|
-
"unbuild": "
|
|
48
|
+
"unbuild": "3.6.1",
|
|
49
|
+
"vitest": "4.0.18"
|
|
50
|
+
},
|
|
51
|
+
"unbuild": {
|
|
52
|
+
"declaration": "node16"
|
|
48
53
|
},
|
|
49
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "a9576050487a4f7dfbc88db20814d5a1bb861c8c"
|
|
50
55
|
}
|
package/dist/json.cjs
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const serializeMinimal = (catalog) => {
|
|
4
|
-
const result = {};
|
|
5
|
-
for (const key in catalog) {
|
|
6
|
-
result[key] = catalog[key].translation || "";
|
|
7
|
-
}
|
|
8
|
-
return result;
|
|
9
|
-
};
|
|
10
|
-
const deserializeMinimal = (minimalCatalog) => {
|
|
11
|
-
const result = {};
|
|
12
|
-
for (const key in minimalCatalog) {
|
|
13
|
-
result[key] = {
|
|
14
|
-
translation: minimalCatalog[key],
|
|
15
|
-
obsolete: false,
|
|
16
|
-
message: null,
|
|
17
|
-
origin: []
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
return result;
|
|
21
|
-
};
|
|
22
|
-
const removeOrigins = (catalog) => {
|
|
23
|
-
const result = {};
|
|
24
|
-
for (const key in catalog) {
|
|
25
|
-
const { origin, ...message } = catalog[key];
|
|
26
|
-
result[key] = message;
|
|
27
|
-
}
|
|
28
|
-
return result;
|
|
29
|
-
};
|
|
30
|
-
const removeLineNumbers = (catalog) => {
|
|
31
|
-
const result = {};
|
|
32
|
-
for (const key in catalog) {
|
|
33
|
-
result[key] = {
|
|
34
|
-
...catalog[key],
|
|
35
|
-
origin: catalog[key].origin?.map(([file]) => [file])
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
return result;
|
|
39
|
-
};
|
|
40
|
-
function formatter(options = {}) {
|
|
41
|
-
options = {
|
|
42
|
-
origins: true,
|
|
43
|
-
lineNumbers: true,
|
|
44
|
-
...options
|
|
45
|
-
};
|
|
46
|
-
return {
|
|
47
|
-
catalogExtension: ".json",
|
|
48
|
-
serialize(catalog, { existing }) {
|
|
49
|
-
let outputCatalog = catalog;
|
|
50
|
-
if (options.origins === false) {
|
|
51
|
-
outputCatalog = removeOrigins(outputCatalog);
|
|
52
|
-
}
|
|
53
|
-
if (options.origins !== false && options.lineNumbers === false) {
|
|
54
|
-
outputCatalog = removeLineNumbers(outputCatalog);
|
|
55
|
-
}
|
|
56
|
-
const shouldUseTrailingNewline = existing === null || existing?.endsWith("\n");
|
|
57
|
-
const trailingNewLine = shouldUseTrailingNewline ? "\n" : "";
|
|
58
|
-
if (options.style === "minimal") {
|
|
59
|
-
outputCatalog = serializeMinimal(outputCatalog);
|
|
60
|
-
}
|
|
61
|
-
return JSON.stringify(outputCatalog, null, options.indentation ?? 2) + trailingNewLine;
|
|
62
|
-
},
|
|
63
|
-
parse(content) {
|
|
64
|
-
const catalog = JSON.parse(content);
|
|
65
|
-
if (options.style === "minimal") {
|
|
66
|
-
return deserializeMinimal(catalog);
|
|
67
|
-
}
|
|
68
|
-
return catalog;
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
exports.formatter = formatter;
|
package/dist/json.d.cts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { CatalogFormatter } from '@lingui/conf';
|
|
2
|
-
|
|
3
|
-
type JsonFormatterOptions = {
|
|
4
|
-
/**
|
|
5
|
-
* Print places where message is used
|
|
6
|
-
*
|
|
7
|
-
* @default true
|
|
8
|
-
*/
|
|
9
|
-
origins?: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Print line numbers in origins
|
|
12
|
-
*
|
|
13
|
-
* @default true
|
|
14
|
-
*/
|
|
15
|
-
lineNumbers?: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* Different styles of how information could be printed
|
|
18
|
-
*
|
|
19
|
-
* @default "lingui"
|
|
20
|
-
*/
|
|
21
|
-
style?: "lingui" | "minimal";
|
|
22
|
-
/**
|
|
23
|
-
* Indentation of output JSON
|
|
24
|
-
*
|
|
25
|
-
* @default 2
|
|
26
|
-
*/
|
|
27
|
-
indentation?: number;
|
|
28
|
-
};
|
|
29
|
-
declare function formatter(options?: JsonFormatterOptions): CatalogFormatter;
|
|
30
|
-
|
|
31
|
-
export { type JsonFormatterOptions, formatter };
|
package/dist/json.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { CatalogFormatter } from '@lingui/conf';
|
|
2
|
-
|
|
3
|
-
type JsonFormatterOptions = {
|
|
4
|
-
/**
|
|
5
|
-
* Print places where message is used
|
|
6
|
-
*
|
|
7
|
-
* @default true
|
|
8
|
-
*/
|
|
9
|
-
origins?: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Print line numbers in origins
|
|
12
|
-
*
|
|
13
|
-
* @default true
|
|
14
|
-
*/
|
|
15
|
-
lineNumbers?: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* Different styles of how information could be printed
|
|
18
|
-
*
|
|
19
|
-
* @default "lingui"
|
|
20
|
-
*/
|
|
21
|
-
style?: "lingui" | "minimal";
|
|
22
|
-
/**
|
|
23
|
-
* Indentation of output JSON
|
|
24
|
-
*
|
|
25
|
-
* @default 2
|
|
26
|
-
*/
|
|
27
|
-
indentation?: number;
|
|
28
|
-
};
|
|
29
|
-
declare function formatter(options?: JsonFormatterOptions): CatalogFormatter;
|
|
30
|
-
|
|
31
|
-
export { type JsonFormatterOptions, formatter };
|