rspress
rspress copied to clipboard
feat: improve some translation options
Summary
This pull request addresses issue #1971 by adding configurable translation options to the theme-default package in Rspress. The changes enable dynamic translation for the following components:
SidebarMenu/index.tsx: Replaced hardcoded"Menu"witht('menuText').CopyCodeButton.tsx: Replaced hardcoded"Copy code"witht('copyCode').code/index.tsx: Replaced hardcoded"Toggle code wrap"witht('toggleCodeWrap').
To support these translations, I added new entries (menuText, copyCode, toggleCodeWrap) to i18n.json with default English and Chinese values. The useI18n hook is utilized to dynamically fetch translations
Note:I personally believe the search box width adjustment (to 960px with full-screen below 640px) is not necessary, as the current design appears sufficient
Related Issue
Checklist
- [x] Tests updated (or not required).
- [x] Documentation updated (or not required).
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.
Deploy Preview for aquamarine-blini-95325f ready!
| Name | Link |
|---|---|
| Latest commit | 0c714c4273a7cd947b761ce05f8d1b7f2eabb95b |
| Latest deploy log | https://app.netlify.com/sites/aquamarine-blini-95325f/deploys/67e41453d4d34b0008e48d22 |
| Deploy Preview | https://deploy-preview-1995--aquamarine-blini-95325f.netlify.app |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
Lighthouse |
1 paths audited Performance: 94 (🟢 up 8 from production) Accessibility: 97 (no change from production) Best Practices: 92 (no change from production) SEO: 100 (no change from production) PWA: - View the detailed breakdown and full score reports |
To edit notification comments on pull requests, go to your Netlify site configuration.
Deploy Preview for rspress-v2 ready!
| Name | Link |
|---|---|
| Latest commit | 0c714c4273a7cd947b761ce05f8d1b7f2eabb95b |
| Latest deploy log | https://app.netlify.com/sites/rspress-v2/deploys/67e4145352c4850008b4019c |
| Deploy Preview | https://deploy-preview-1995--rspress-v2.netlify.app |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
@isolcat Are you still working on this?
@isolcat Are you still working on this?
Our current internationalized text is maintained in multiple places. This caused the contributor to incorrectly understand how to add translation text in the theme-default component.
in Rspress V2, I want to migrate all the translation text options to i18n.json
the components in @rspress/theme-default should use the translation text in i18n.json via usei18n(); and t('foo')
and we provide a default i18n.json for merging with the user's i18n.json...
and we provide a default i18n.json for merging with the user's i18n.json...
This is not quite cool for https://github.com/alauda/Doom which is a kind of document framework and doesn't require users provide any i18n.json. How to provide a high-level i18n.json? Maybe an i18n property in config should be provided instead? So that our doom can merge in its own logic.
And this PR could target 1.x instead.
translation text
Yes, I'm still following up on this issue, but I'm not entirely clear about your subsequent thoughts on multilingual processing. I'm in favor of the centralized management approach for multilingual solutions.
And this PR could target
1.xinstead.
I can accept adding text fields into themeConfig in V1 to handle these translation issues just like searchNoResultsText
we need to refactor i18n.json usage
so closed
