feat(i18n): adds type-checking for translations (DRAFT)#61820
Closed
ahrjarrett wants to merge 7 commits into
Closed
feat(i18n): adds type-checking for translations (DRAFT)#61820ahrjarrett wants to merge 7 commits into
ahrjarrett wants to merge 7 commits into
Conversation
Contributor
Author
|
Link to the Discord thread |
ahrjarrett
commented
Aug 15, 2025
ahrjarrett
commented
Aug 15, 2025
27 tasks
4 tasks
Contributor
Author
|
Closed in favor of #61970 |
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.
Checklist:
mainbranch of freeCodeCamp.Closes #61818
Intro
First I want to say thank you to the freeCodeCamp maintainers for helping make education more accessible 🙇.
The i18next team is planning to release a new API that is designed for TypeScript codebases with large translation sets (like freeCodeCamp).
Here's the issue, if you're curious: i18next/i18next#2322
Note
If you'd like to see this issue get merged, please consider giving it a 👍 !
That will help signal to the i18next maintainers that the ecosystem would find this change useful.
To make the transition smoother for larger teams (like freeCodeCamp!), we've implemented a codemod, which was used to generate this PR.
Demo
To make the change easier to understand, I created a quick demo showing a before and after.
Before
Impact
This makes the system more difficult to change without accidentally introducing bugs.
For example, if the path
icons.avatarchanges, the user needs to remember to grepicons.avatarto find all the places where its referenced, or risk breaking the translationAfter
Impact
This makes the system easier to change, because if the location of a translation changes, the user will get a type error when running
pnpm lint:ts.It also reduces the ramp-up time for new users who want to contribute. They don't (necessarily) need to know where translations are located to use a translation. This makes the process of translating freeCodeCamp into different languages more accessible overall.
Description
Note
This PR is not meant to be merged in its current state.
It is meant as a way to help the freeCodeCamp team gauge the amount of work required to migrate, and to demonstrate the improved DX / type safety available in the next version.
Feel free to take over this PR, close it, or whatever is most useful for your workflow.
Here are the outstanding issues after applying the codemod:
Closing thoughts
The migration is mostly a mechanical change. All that's left are a few places where props need to have a slightly narrower type.
Alternatively, you could also change the type of the resources in your i18next config to be a little wider, if making the types narrower proves to be more trouble than it's worth.
The migration also found a few probable bugs:
client/src/client-only-routes/show-project-links.tsxclient/src/components/Donation/donation-modal-body.tsxLet me know if I can answer any questions about the change, and of course please don't hesitate to share any feedback about the change you might have.