|
17 | 17 |
|
18 | 18 | from babel.core import Locale |
19 | 19 | from babel.messages.catalog import Catalog, Message |
20 | | -from babel.util import _cmp, wraptext |
| 20 | +from babel.util import TextWrapper, _cmp |
21 | 21 |
|
22 | 22 | if TYPE_CHECKING: |
23 | 23 | from typing import IO, AnyStr |
@@ -637,8 +637,11 @@ def generate_po( |
637 | 637 | # provide the same behaviour |
638 | 638 | comment_width = width if width and width > 0 else 76 |
639 | 639 |
|
| 640 | + comment_wrapper = TextWrapper(width=comment_width) |
| 641 | + header_wrapper = TextWrapper(width=width, subsequent_indent="# ") |
| 642 | + |
640 | 643 | def _format_comment(comment, prefix=''): |
641 | | - for line in wraptext(comment, comment_width): |
| 644 | + for line in comment_wrapper.wrap(comment): |
642 | 645 | yield f"#{prefix} {line.strip()}\n" |
643 | 646 |
|
644 | 647 | def _format_message(message, prefix=''): |
@@ -668,8 +671,7 @@ def _format_message(message, prefix=''): |
668 | 671 | if width and width > 0: |
669 | 672 | lines = [] |
670 | 673 | for line in comment_header.splitlines(): |
671 | | - lines += wraptext(line, width=width, |
672 | | - subsequent_indent='# ') |
| 674 | + lines += header_wrapper.wrap(line) |
673 | 675 | comment_header = '\n'.join(lines) |
674 | 676 | yield f"{comment_header}\n" |
675 | 677 |
|
|
0 commit comments