Skip to content

Conversation

@sjgeyer
Copy link

@sjgeyer sjgeyer commented Oct 9, 2025

Rule to disallow nesting Plural components inside Trans components for improved localization.

Good:

<Plural value={count} one="You have # unread message" other="You have # unread messages" />

Bad:

<Trans>You have <Plural value={count} one="# unread message" other="# unread messages" /></Trans>

@codecov
Copy link

codecov bot commented Oct 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.89%. Comparing base (073664e) to head (21ce4a1).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #110      +/-   ##
==========================================
+ Coverage   97.86%   97.89%   +0.02%     
==========================================
  Files          11       12       +1     
  Lines         563      571       +8     
  Branches      187      187              
==========================================
+ Hits          551      559       +8     
  Misses         12       12              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@andrii-bodnar andrii-bodnar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sjgeyer looks good to me, thank you for the contribution!

@timofei-iatsenko
Copy link
Collaborator

Why you consider this bad? In my opinion the opposite is bad, nesting Plural inside Trans creates a perfectly fine ICU message without duplication:

You have {plural, count, one {# unread message} other {# unread messages}}

@sjgeyer
Copy link
Author

sjgeyer commented Oct 15, 2025

it's less about the creation of the message than the quality of the translation. i've found that we get better and more reliable translations when the Plural includes the full sentence (or as much of the sentence as possible) vs. concatenating sentences inside a Trans

@timofei-iatsenko
Copy link
Collaborator

@sjgeyer could you add more details to the doc for that rule, like where to use tis rule and where not.

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.

3 participants