feat(po-format): print source message as translation for explicit id#2390
Merged
andrii-bodnar merged 2 commits intomainfrom Jan 8, 2026
Merged
feat(po-format): print source message as translation for explicit id#2390andrii-bodnar merged 2 commits intomainfrom
andrii-bodnar merged 2 commits intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
size-limit report 📦
|
andrii-bodnar
approved these changes
Jan 8, 2026
Contributor
andrii-bodnar
left a comment
There was a problem hiding this comment.
@timofei-iatsenko thank you! This is actually a pretty common approach. In Crowdin, we support a special flag that allows you to import source strings from msgstr instead of msgid. https://store.crowdin.com/gnu-gettext
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
While working on #2388 i noticed that when we have an "explicit id" and extract with po formatter, the information about original message is not stored anywhere. So if those PO files than imported into some other systems it's hard to figure out what source text associated with this key.
In general, po files is not designed to work with "key" approach. Current implementation when key printed into
msgid(by the po spec
msgidshould contain a source message) is a workaround and kept historically during rewrite between v3-v4.I have better idea how to do this, but any changes in this matter requires migration of catalogs and would be a big disruption - but i still have this on my plans.
So in this PR, source message would be printed to source locale and template catalog into the translation.
Before (after extraction):
en.po
#. js-lingui-explicit-id msgid "custom.id" msgstr ""After change in this PR:
en.po
#. js-lingui-explicit-id msgid "custom.id" msgstr "with explicit id" <!-- source message printedSo printing original message to translation is also not strictly following the spec, but also not breaking it.
Also this PR adds more sanity to the PO Formatters, it cleans up after itself the comments used as serialization flags, such as
js-lingui-explicit-idthey make sense only for formatter itself, and should not be propagated to the lingui internal data model.Types of changes
Fixes # (issue)
Checklist