-
Notifications
You must be signed in to change notification settings - Fork 393
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
Extra details about i18next + better lingui examples #2013
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
size-limit report 📦
|
By the way, lazy translation is something that i18next does NOT support, and caused a lot of subtle bugs on our application until I realized what was going on. I'm not sure how to better write about this in the comparison page, though :| |
```js | ||
i18n._("Hello!", { comment: "This goes in the header" }); | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately that will not work. Most lingui features build around macros, pieces of code which executed during build step not a runtime. This helps reduce size footprint of the translation catalogs as well as library itself.
In this case to specify a context for a message you MUST use a macro like this
import {t} from "@lingui/macro";
t({message: `From: `, context: "direction"})
With plain runtime modules (i18n._) the only way is custom id.
@igorsantos07 @timofei-iatsenko is there anything we can do to help move this PR forward? |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2013 +/- ##
==========================================
+ Coverage 76.65% 80.00% +3.35%
==========================================
Files 81 85 +4
Lines 2090 2146 +56
Branches 533 547 +14
==========================================
+ Hits 1602 1717 +115
- Misses 375 413 +38
+ Partials 113 16 -97 ☔ View full report in Codecov by Sentry. |
This article should be proofread and lingui examples replaced to theirs |
Close in favor of #2064 |
Description
As a user of i18next for around 3 years, I noticed some parts of the comparison were lacking. I got specially baffled by the verbosity of interpolations, but I'm glad I checked the API docs before giving up :)
An important fact to distinguish as well is that you need a lot of extra config in i18n to use natLang keys, which honestly is quite troublesome for people coming from gettext. This happens because i18next relies solely on JSON files, so they need some... workarounds... to shove different details in the same JSON key.
I also replaced the
t()
references with_()
, as that's the main function (and not the alias).Lastly, I'm not entirely sure about the syntax to include translation context in Lingui. I stumbled upon
comment
in some other example and in the API docs, but again, that's not exactly clear. I would advise add a description for all options that can be used in_()
, as well as examples for context/comments.Types of changes
Checklist