-
-
Notifications
You must be signed in to change notification settings - Fork 423
fix: Gettext formatter merges duplicate plural entries #2347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@garikkh is attempting to deploy a commit to the Crowdin Team on Vercel. A member of the Team first needs to authorize it. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2347 +/- ##
==========================================
- Coverage 77.05% 76.72% -0.33%
==========================================
Files 84 99 +15
Lines 2157 2733 +576
Branches 555 707 +152
==========================================
+ Hits 1662 2097 +435
- Misses 382 509 +127
- Partials 113 127 +14 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Ah, didn't work properly, need to continue working on it |
|
I think implementation is suboptimal, instead of introducing another type of comment, simply print the same comments many times #. js-lingui:icu=%7BanotherCount%2C+plural%2C+one+%7Bone+book%7D+other+%7Bmany+books%7D%7D&pluralize_on=anotherCount
#. js-lingui:icu=%7Bcount%2C+plural%2C+one+%7Bone+book%7D+other+%7Bmany+books%7D%7D&pluralize_on=count
#: src/App.tsx:61
msgid "one book"
msgid_plural "many books"
msgstr[0] "one book"
msgstr[1] "many books"When deserializing just take to consideration that there could be multiple comments, flat map 1 message + 1 comment and use existing methods to process that. |
|
I considered that approach, but it seemed messier to me when you have many duplicates. In our codebase, we've only been using lingui a few months, but already have cases with ~7 duplicates. So now you'd have a PO entry with 7 ICU comments instead of 1 really long comment. |
Also wanted to note, this isn't introducing another comment - it's just using the const contextComment = item.extractedComments
.find((comment) => comment.startsWith(ctxPrefix))
?.substring(ctxPrefix.length)
const ctx = new URLSearchParams(contextComment)This solution is a little more complex, but IMO is more elegant/consistent |
|
bump @timofei-iatsenko |
Description
Fixes #2346
When using po-gettext formatter, plural calls with identical strings but different variables:
generated duplicate msgid entries in PO files, which violates PO format rules.
Added pre-processing step that merges duplicate plural catalog entries before serialization.
msgid/msgid_pluralentries in generated PO filesWith this change the PO now looks like:
Types of changes
Fixes #2346
Checklist