@lingui/format-po-gettext 6.1.0 → 6.3.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.
@@ -1,5 +1,5 @@
1
1
  import { parse } from '@messageformat/parser';
2
- import PO from 'pofile';
2
+ import { parsePo, stringifyPo, createItem } from 'pofile-ts';
3
3
  import { generateMessageId } from '@lingui/message-utils/generateMessageId';
4
4
  import { formatter as formatter$1 } from '@lingui/format-po';
5
5
 
@@ -3447,7 +3447,7 @@ function expandMergedPluralEntries(items, options) {
3447
3447
  continue;
3448
3448
  }
3449
3449
  for (const variable of variableList) {
3450
- const newItem = new PO.Item();
3450
+ const newItem = createItem();
3451
3451
  newItem.msgid = item.msgid;
3452
3452
  newItem.msgid_plural = item.msgid_plural;
3453
3453
  newItem.msgstr = [...item.msgstr];
@@ -3473,14 +3473,22 @@ function formatter(options = {}) {
3473
3473
  options = {
3474
3474
  origins: true,
3475
3475
  lineNumbers: true,
3476
+ foldLength: 0,
3476
3477
  ...options
3477
3478
  };
3478
3479
  const formatter2 = formatter$1(options);
3480
+ const serializeOptions = {};
3481
+ if (options.foldLength !== void 0) {
3482
+ serializeOptions.foldLength = options.foldLength;
3483
+ }
3484
+ if (options.compactMultiline !== void 0) {
3485
+ serializeOptions.compactMultiline = options.compactMultiline;
3486
+ }
3479
3487
  return {
3480
3488
  catalogExtension: ".po",
3481
3489
  templateExtension: ".pot",
3482
3490
  parse(content, ctx) {
3483
- const po = PO.parse(content);
3491
+ const po = parsePo(content);
3484
3492
  if (options.mergePlurals) {
3485
3493
  po.items = expandMergedPluralEntries(po.items, options);
3486
3494
  }
@@ -3502,10 +3510,13 @@ function formatter(options = {}) {
3502
3510
  options.customICUPrefix
3503
3511
  );
3504
3512
  });
3505
- return formatter2.parse(po.toString(), ctx);
3513
+ return formatter2.parse(
3514
+ stringifyPo(po, serializeOptions),
3515
+ ctx
3516
+ );
3506
3517
  },
3507
3518
  serialize(catalog, ctx) {
3508
- const po = PO.parse(formatter2.serialize(catalog, ctx));
3519
+ const po = parsePo(formatter2.serialize(catalog, ctx));
3509
3520
  po.items = po.items.map((item) => {
3510
3521
  const isGeneratedId = !item.extractedComments.includes(
3511
3522
  "js-lingui-explicit-id"
@@ -3533,7 +3544,7 @@ function formatter(options = {}) {
3533
3544
  });
3534
3545
  po.items = newItems;
3535
3546
  }
3536
- return po.toString();
3547
+ return stringifyPo(po, serializeOptions);
3537
3548
  }
3538
3549
  };
3539
3550
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingui/format-po-gettext",
3
- "version": "6.1.0",
3
+ "version": "6.3.0",
4
4
  "description": "Gettext PO formatter for Lingui message catalogs using gettext-style plural rules",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -41,19 +41,20 @@
41
41
  "dist/"
42
42
  ],
43
43
  "dependencies": {
44
- "@lingui/conf": "6.1.0",
45
- "@lingui/format-po": "6.1.0",
46
- "@lingui/message-utils": "6.1.0",
44
+ "@lingui/conf": "6.3.0",
45
+ "@lingui/format-po": "6.3.0",
46
+ "@lingui/message-utils": "6.3.0",
47
47
  "@messageformat/parser": "^5.0.0",
48
- "pofile": "^1.1.4"
48
+ "pofile-ts": "^4.0.3"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@lingui/test-utils": "3.0.3",
52
+ "typescript": "catalog:",
52
53
  "unbuild": "catalog:",
53
54
  "vitest": "catalog:"
54
55
  },
55
56
  "unbuild": {
56
57
  "declaration": "node16"
57
58
  },
58
- "gitHead": "46a340af0dbfc8e4ac483cc607c2b24ac48ab56b"
59
+ "gitHead": "f5f432578a13f07c5e261896eed65ec4f82998d3"
59
60
  }