|
1 | 1 | import { parse as parseIcu, Select, SelectCase } from "@messageformat/parser" |
2 | 2 | import pluralsCldr from "plurals-cldr" |
3 | | -import { parsePo, stringifyPo, createItem, type PoItem } from "pofile-ts" |
| 3 | +import { parsePo, stringifyPo, createItem, type PoItem, type SerializeOptions } from "pofile-ts" |
4 | 4 | import gettextPlurals from "node-gettext/lib/plurals" |
5 | 5 |
|
6 | 6 | import type { CatalogFormatter, CatalogType, MessageType } from "@lingui/conf" |
@@ -514,6 +514,15 @@ export function formatter( |
514 | 514 |
|
515 | 515 | const formatter = poFormatter(options) |
516 | 516 |
|
| 517 | + // Build serialize options from the formatter options |
| 518 | + const serializeOptions: SerializeOptions = {} |
| 519 | + if (options.foldLength !== undefined) { |
| 520 | + serializeOptions.foldLength = options.foldLength |
| 521 | + } |
| 522 | + if (options.compactMultiline !== undefined) { |
| 523 | + serializeOptions.compactMultiline = options.compactMultiline |
| 524 | + } |
| 525 | + |
517 | 526 | return { |
518 | 527 | catalogExtension: ".po", |
519 | 528 | templateExtension: ".pot", |
@@ -543,7 +552,7 @@ export function formatter( |
543 | 552 | ) |
544 | 553 | }) |
545 | 554 |
|
546 | | - return formatter.parse(stringifyPo(po), ctx) as CatalogType |
| 555 | + return formatter.parse(stringifyPo(po, serializeOptions), ctx) as CatalogType |
547 | 556 | }, |
548 | 557 |
|
549 | 558 | serialize(catalog, ctx): string { |
@@ -587,7 +596,7 @@ export function formatter( |
587 | 596 | po.items = newItems |
588 | 597 | } |
589 | 598 |
|
590 | | - return stringifyPo(po) |
| 599 | + return stringifyPo(po, serializeOptions) |
591 | 600 | }, |
592 | 601 | } |
593 | 602 | } |
0 commit comments