rspress icon indicating copy to clipboard operation
rspress copied to clipboard

feat: improve some translation options

Open isolcat opened this issue 8 months ago • 3 comments

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" with t('menuText').
  • CopyCodeButton.tsx: Replaced hardcoded "Copy code" with t('copyCode').
  • code/index.tsx: Replaced hardcoded "Toggle code wrap" with t('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).

isolcat avatar Mar 23 '25 06:03 isolcat

CLA assistant check
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.

CLAassistant avatar Mar 23 '25 06:03 CLAassistant

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...

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.

netlify[bot] avatar Mar 23 '25 06:03 netlify[bot]

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...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] avatar Mar 23 '25 06:03 netlify[bot]

@isolcat Are you still working on this?

JounQin avatar May 08 '25 10:05 JounQin

@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

image

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...

SoonIter avatar May 08 '25 11:05 SoonIter

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.

JounQin avatar May 08 '25 11:05 JounQin

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.

isolcat avatar May 08 '25 11:05 isolcat

And this PR could target 1.x instead.

I can accept adding text fields into themeConfig in V1 to handle these translation issues just like searchNoResultsText

SoonIter avatar May 09 '25 09:05 SoonIter

we need to refactor i18n.json usage

so closed

SoonIter avatar Sep 11 '25 07:09 SoonIter