Skip to content

Support parsing and compiling previous translations in obsolete entries#112

Closed
kisaragi-hiu wants to merge 3 commits into
smhg:mainfrom
kisaragi-hiu:fix-obsolete-previous
Closed

Support parsing and compiling previous translations in obsolete entries#112
kisaragi-hiu wants to merge 3 commits into
smhg:mainfrom
kisaragi-hiu:fix-obsolete-previous

Conversation

@kisaragi-hiu

Copy link
Copy Markdown
Contributor

Fixes #111. After investigating that I thought I might try my hand at fixing it.

A #~| is a previous (un)translated string (like #|) in an obsolete entry, and is emitted when a string is translated, updated with msgmerge --previous (thus creating a #| previous translation), then made obsolete (removed) before a translator could act on it. msgmerge generates it as seen in this msgmerge test case.

The approach I've taken here for lexing seems to be what GNU Gettext does as well. (While the GNU Gettext comment says it "does not make sense semantically, and is implemented here for completeness only", it does actually make sense to exist as explained above, and does actually exist in the wild in at least 200k files.)

@kisaragi-hiu
kisaragi-hiu force-pushed the fix-obsolete-previous branch from 0aae23d to 14256c4 Compare June 30, 2026 21:29
smhg added a commit that referenced this pull request Jul 6, 2026
Recognize `#~|` comments, which msgmerge emits when an entry carrying a
`--previous` msgid is later marked obsolete. Previously these threw
"Invalid key name". The previous string round-trips as an opaque comment,
consistent with existing non-obsolete `#|` handling. Fixes #111.

Co-authored-by: Kisaragi Hiu <mail@kisaragi-hiu.com>
@smhg

smhg commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Squash-merged as 8ebe726, released in v9.1.0. Thanks @kisaragi-hiu!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Valid #~| lines (previous msgid/msgstr of an obsolete string) are treated as syntax errors

2 participants