@lingui/format-po 4.11.2 → 4.11.4

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 CHANGED
@@ -12,6 +12,11 @@ const splitOrigin = (origin) => {
12
12
  const [file, line] = origin.split(":");
13
13
  return [file, line ? Number(line) : null];
14
14
  };
15
+ const splitMultiLineComments = (comments) => {
16
+ return comments.flatMap(
17
+ (comment) => comment.includes("\n") ? comment.split("\n").map((slice) => slice.trim()).filter(Boolean) : comment
18
+ );
19
+ };
15
20
  const joinOrigin = (origin) => origin.join(":");
16
21
  function isGeneratedId(id, message) {
17
22
  return id === generateMessageId.generateMessageId(message.message, message.context);
@@ -33,7 +38,9 @@ const serialize = (catalog, options) => {
33
38
  return Object.keys(catalog).map((id) => {
34
39
  const message = catalog[id];
35
40
  const item = new PO__default.Item();
36
- item.extractedComments = [...message.comments || []];
41
+ item.extractedComments = [
42
+ ...message.comments?.length ? splitMultiLineComments(message.comments) : []
43
+ ];
37
44
  item.flags = (message.extra?.flags || []).reduce((acc, flag) => {
38
45
  acc[flag] = true;
39
46
  return acc;
package/dist/po.mjs CHANGED
@@ -6,6 +6,11 @@ const splitOrigin = (origin) => {
6
6
  const [file, line] = origin.split(":");
7
7
  return [file, line ? Number(line) : null];
8
8
  };
9
+ const splitMultiLineComments = (comments) => {
10
+ return comments.flatMap(
11
+ (comment) => comment.includes("\n") ? comment.split("\n").map((slice) => slice.trim()).filter(Boolean) : comment
12
+ );
13
+ };
9
14
  const joinOrigin = (origin) => origin.join(":");
10
15
  function isGeneratedId(id, message) {
11
16
  return id === generateMessageId(message.message, message.context);
@@ -27,7 +32,9 @@ const serialize = (catalog, options) => {
27
32
  return Object.keys(catalog).map((id) => {
28
33
  const message = catalog[id];
29
34
  const item = new PO.Item();
30
- item.extractedComments = [...message.comments || []];
35
+ item.extractedComments = [
36
+ ...message.comments?.length ? splitMultiLineComments(message.comments) : []
37
+ ];
31
38
  item.flags = (message.extra?.flags || []).reduce((acc, flag) => {
32
39
  acc[flag] = true;
33
40
  return acc;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingui/format-po",
3
- "version": "4.11.2",
3
+ "version": "4.11.4",
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.11.2",
45
- "@lingui/message-utils": "4.11.2",
44
+ "@lingui/conf": "4.11.4",
45
+ "@lingui/message-utils": "4.11.4",
46
46
  "date-fns": "^3.6.0",
47
47
  "pofile": "^1.1.4"
48
48
  },
@@ -52,5 +52,5 @@
52
52
  "tsd": "^0.28.0",
53
53
  "unbuild": "2.0.0"
54
54
  },
55
- "gitHead": "17e0af54b0b9d9577db2cef1be680a6d871611e7"
55
+ "gitHead": "43d4e671360e8e5f1b820e4e061c1926d95c120b"
56
56
  }