mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-09 04:06:42 +00:00
fix(i18n): keep a rejection sample from breaking the catalog it annotates
record() quotes the rejected translation into a PO comment and guarded the known hazard, a trailing backslash, with rstrip. The guard sits too early: babel wraps the finished comment across several # lines afterwards, so a backslash inside the string can land at a break it never saw. In docs/tr the wrap fell inside an escaped \\\\ of the source, gettext read the dangling backslash as a line continuation, swallowed the msgid below it, and msgfmt reported 56451:7 syntax error on an msgstr with no counterpart. docs/zh failed the same way. Removing every backslash instead of the last one makes the hazard impossible wherever the wrap falls, and a newline becomes a space rather than an escape that reintroduces one. A rejection sample quotes what the engine said; it needs no escapes. Reproduced and closed: both catalogs failed msgfmt before and pass after. A sweep over the tree finds no syntax error in any of the 180+ catalogs, though 24 still carry the same dangling backslash where the next line happens to be another comment. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
2a6a8de5f0
commit
5790359cd0
1 file changed
+1
-1
@@ -230,7 +230,7 @@ def record(message: Message, rejected: Rejected | None) -> None:
|
||||
)
|
||||
message.user_comments.append(URL_SUPPRESSION)
|
||||
message.user_comments.append(
|
||||
f"{REJECTED_PREFIX} {rejected.text}".replace("\n", "\\n").rstrip("\\")
|
||||
f"{REJECTED_PREFIX} {rejected.text}".replace("\\", "").replace("\n", " ")
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user