-
Notifications
You must be signed in to change notification settings - Fork 678
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
Support i18n #345
Support i18n #345
Conversation
@djyde is attempting to deploy a commit to the RSS3 Team on Vercel. A member of the Team first needs to authorize it. |
Signed-off-by: Innei <i@innei.in>
@djyde Thanks for the contribution! But I found some problems, like |
Signed-off-by: Innei <i@innei.in>
Another problem is that this implementation only works for the web and does not cover electron. We need to set the language of the electron app, not just the renderer. The electron i18n logic maybe like this:
|
Where to save the language in main process? |
I just researched other electron apps and most of them ignore this issue, testing on Discord, Slack, AFFiNE. Only Slack synchronizes the language between renderer and main, while the others only do i18n for the renderer, and main only based on the system language. |
So for now we don't need to be concerned about this, I'll take the time to address it subsequently |
Signed-off-by: Innei <i@innei.in>
Signed-off-by: Innei <i@innei.in>
Signed-off-by: Innei <i@innei.in>
Signed-off-by: Innei <i@innei.in>
Signed-off-by: Innei <i@innei.in>
@djyde I fixed TypeScript support for i18n and added DX HMR support. Once testing is complete, it will be merged |
This PR add i18n support to Follow. (Currently I only test on Electron app), which is powered by i18next and react-i18next.
What new in UI
Added a language selector on the general setting page:
How it works
All locales files are on
locales/
path. I addeden.json
andzh_CN.json
.The i18next core function is on
shared/src/i18n.ts
. This file import all the locales from locale json file.Then on the top level of the entire app (aka
renderer/src/main.tsx
) just simply import thei18n.ts
to load the locales.How to use in component
just use
useTranslation
, e.g. :How to progressivly add translation:
I recommend using Cursor. Open the React component file, open chat, just tell it "Extract all text to en.json". It will do all the things for you:
Otherwise manually extract them file by file.
BTW I could create a new PR to do it after this PR being merged.