-
Notifications
You must be signed in to change notification settings - Fork 386
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
feat: add ph() and explicit labels for placeholders #2092
feat: add ph() and explicit labels for placeholders #2092
Conversation
@timofei-iatsenko is attempting to deploy a commit to the Crowdin Team on Vercel. A member of the Team first needs to authorize it. |
size-limit report 📦
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2092 +/- ##
==========================================
- Coverage 77.05% 75.81% -1.24%
==========================================
Files 84 87 +3
Lines 2157 2390 +233
Branches 555 627 +72
==========================================
+ Hits 1662 1812 +150
- Misses 382 459 +77
- Partials 113 119 +6 ☔ View full report in Codecov by Sentry. |
68b0809
to
aaa680f
Compare
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
aaa680f
to
593e1e7
Compare
593e1e7
to
e3ea7d4
Compare
@andrii-bodnar rebased to main branch |
@andrii-bodnar anything here stopping from merging? |
I would love to play with this feature, but I am pretty busy at the moment :(. Will try to find some time probably next week. What about the SWC version of this? We have a lot of users who use SWC and it would probably be better to ship such features fully functional. |
e3ea7d4
to
9a744bb
Compare
Description
Adds a way to give an explicit name for placeholders in the messages. There are two syntaxes supported:
And with explicit
ph
helper:Shortcut syntax is also supported:
plural / select / selectOrdinal:
In the JSX
Note, that Children type for the Trans component was amended to allow passing an object. However, inner elements in the Trans will not allow that, and the only one way to use is a
ph()
helper macro, which basically a type helper to mitigate this issue.PS
Actually everything could be covered with
ph()
helper, but i've found syntax without it much easier to write in day to day routine. So i decided to left both of them. For most of cases just{name: getName()}
and for cases where it doesn't work theph
.The implementation is almost the same, to support both of the methods it's additional 10 lines of code.
Let me know what you think about it.
Types of changes
Fixes # (issue)
Checklist