@lingui/format-po 4.4.1 → 4.5.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/po.cjs +8 -4
- package/dist/po.d.cts +39 -0
- package/dist/po.d.mts +39 -0
- package/dist/po.d.ts +1 -1
- package/package.json +5 -5
package/dist/po.cjs
CHANGED
|
@@ -4,6 +4,10 @@ const dateFns = require('date-fns');
|
|
|
4
4
|
const PO = require('pofile');
|
|
5
5
|
const generateMessageId = require('@lingui/message-utils/generateMessageId');
|
|
6
6
|
|
|
7
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
8
|
+
|
|
9
|
+
const PO__default = /*#__PURE__*/_interopDefaultCompat(PO);
|
|
10
|
+
|
|
7
11
|
const splitOrigin = (origin) => {
|
|
8
12
|
const [file, line] = origin.split(":");
|
|
9
13
|
return [file, line ? Number(line) : null];
|
|
@@ -27,7 +31,7 @@ const GENERATED_ID_FLAG = "js-lingui-generated-id";
|
|
|
27
31
|
const serialize = (catalog, options) => {
|
|
28
32
|
return Object.keys(catalog).map((id) => {
|
|
29
33
|
const message = catalog[id];
|
|
30
|
-
const item = new
|
|
34
|
+
const item = new PO__default.Item();
|
|
31
35
|
item.extractedComments = [...message.comments || []];
|
|
32
36
|
item.flags = (message.extra?.flags || []).reduce((acc, flag) => {
|
|
33
37
|
acc[flag] = true;
|
|
@@ -102,15 +106,15 @@ function formatter(options = {}) {
|
|
|
102
106
|
catalogExtension: ".po",
|
|
103
107
|
templateExtension: ".pot",
|
|
104
108
|
parse(content) {
|
|
105
|
-
const po =
|
|
109
|
+
const po = PO__default.parse(content);
|
|
106
110
|
return deserialize(po.items, options);
|
|
107
111
|
},
|
|
108
112
|
serialize(catalog, ctx) {
|
|
109
113
|
let po;
|
|
110
114
|
if (ctx.existing) {
|
|
111
|
-
po =
|
|
115
|
+
po = PO__default.parse(ctx.existing);
|
|
112
116
|
} else {
|
|
113
|
-
po = new
|
|
117
|
+
po = new PO__default();
|
|
114
118
|
po.headers = getCreateHeaders(ctx.locale);
|
|
115
119
|
po.headerOrder = Object.keys(po.headers);
|
|
116
120
|
}
|
package/dist/po.d.cts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { CatalogFormatter } from '@lingui/conf';
|
|
2
|
+
|
|
3
|
+
type PoFormatterOptions = {
|
|
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
|
+
* Print `js-lingui-id: Xs4as` statement in extracted comments section
|
|
18
|
+
*
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
printLinguiId?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* By default, the po-formatter treats the pair `msgid` + `msgctx` as the source
|
|
24
|
+
* for generating an ID by hashing its value.
|
|
25
|
+
*
|
|
26
|
+
* For messages with explicit IDs, the formatter adds a special comment `js-lingui-explicit-id` as a flag.
|
|
27
|
+
* When this flag is present, the formatter will use the `msgid` as-is without any additional processing.
|
|
28
|
+
*
|
|
29
|
+
* Set this option to true if you exclusively use explicit-ids in your project.
|
|
30
|
+
*
|
|
31
|
+
* https://lingui.dev/tutorials/react-patterns#using-custom-id
|
|
32
|
+
*
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
explicitIdAsDefault?: boolean;
|
|
36
|
+
};
|
|
37
|
+
declare function formatter(options?: PoFormatterOptions): CatalogFormatter;
|
|
38
|
+
|
|
39
|
+
export { type PoFormatterOptions, formatter };
|
package/dist/po.d.mts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { CatalogFormatter } from '@lingui/conf';
|
|
2
|
+
|
|
3
|
+
type PoFormatterOptions = {
|
|
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
|
+
* Print `js-lingui-id: Xs4as` statement in extracted comments section
|
|
18
|
+
*
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
printLinguiId?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* By default, the po-formatter treats the pair `msgid` + `msgctx` as the source
|
|
24
|
+
* for generating an ID by hashing its value.
|
|
25
|
+
*
|
|
26
|
+
* For messages with explicit IDs, the formatter adds a special comment `js-lingui-explicit-id` as a flag.
|
|
27
|
+
* When this flag is present, the formatter will use the `msgid` as-is without any additional processing.
|
|
28
|
+
*
|
|
29
|
+
* Set this option to true if you exclusively use explicit-ids in your project.
|
|
30
|
+
*
|
|
31
|
+
* https://lingui.dev/tutorials/react-patterns#using-custom-id
|
|
32
|
+
*
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
explicitIdAsDefault?: boolean;
|
|
36
|
+
};
|
|
37
|
+
declare function formatter(options?: PoFormatterOptions): CatalogFormatter;
|
|
38
|
+
|
|
39
|
+
export { type PoFormatterOptions, formatter };
|
package/dist/po.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingui/format-po",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"description": "Gettext PO format for Lingui Catalogs",
|
|
5
5
|
"main": "./dist/po.cjs",
|
|
6
6
|
"module": "./dist/po.mjs",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"dist/"
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@lingui/conf": "4.
|
|
45
|
-
"@lingui/message-utils": "4.
|
|
44
|
+
"@lingui/conf": "4.5.0",
|
|
45
|
+
"@lingui/message-utils": "4.5.0",
|
|
46
46
|
"date-fns": "^2.29.3",
|
|
47
47
|
"pofile": "^1.1.4"
|
|
48
48
|
},
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@lingui/jest-mocks": "^3.0.3",
|
|
51
51
|
"mockdate": "^3.0.5",
|
|
52
52
|
"tsd": "^0.28.0",
|
|
53
|
-
"unbuild": "
|
|
53
|
+
"unbuild": "2.0.0"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "62c92d1f8c60b3890bdda870f307fa780d423080"
|
|
56
56
|
}
|