Skip to content
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

Cannot localize the titles of Theme switcher in v1.X version (not supporting?) #1753

Closed
SEWeiTung opened this issue Jun 23, 2023 · 1 comment
Labels
bug Something isn't working no plan This will not be worked on

Comments

@SEWeiTung
Copy link

SEWeiTung commented Jun 23, 2023

Versions

  • dumi: 1.1.47
  • node: 18.16.0
  • npm: 9.5.1
  • OS: N/A
  • Browser: N/A

Steps to reproduce

Install the dumi as what was given by the torturials and enable the theme switcher (A good example is to see what's inside the “Egg”'s repository at "site" folder).

What is Expected?

As I have a Chinese and English version, the switch button's title should be with Chinese in the Chinese mode.

What is actually happening?

All are English version, not translated.

A typical example is that you can see the official site of dumi at v1.x: https://v1.d.umijs.org/zh-CN/
When in the Chinese version, move your mouse onto the button, "Default to System" should be "跟随系统设置" but actually NOT, this also happens for all the related switch buttons such as "Dark mode", "Light mode"……ect:

image

Reasons:

The "title" is hard-coded instead of supporting a flexible, localizable string at:

case 'dark':
return (
<button key="dumi-dark-btn-moon" title="Dark theme" onClick={ev => changeColor(ev, baseColor)} className={`__dumi-default-dark-moon ${baseColor === prefersColor ? '__dumi-default-dark-switch-active' : ''}`}>
{moonSvg}
</button>
);
case 'light':
return (
<button key="dumi-dark-btn-sun" title="Light theme" onClick={ev => changeColor(ev, baseColor)} className={`__dumi-default-dark-sun ${baseColor === prefersColor ? '__dumi-default-dark-switch-active' : ''}`}>
{sunSvg}
</button>
);
case 'auto':
return (
<button key="dumi-dark-btn-auto" title="Default to system" onClick={ev => changeColor(ev, baseColor)} className={`__dumi-default-dark-auto ${baseColor === prefersColor ? '__dumi-default-dark-switch-active' : ''}`}>

@SEWeiTung SEWeiTung added the bug Something isn't working label Jun 23, 2023
@SEWeiTung SEWeiTung changed the title Cannot localize the title of Theme switcher in v1.X version Cannot localize the titles of Theme switcher in v1.X version (not supporting?) Jun 23, 2023
@PeachScript
Copy link
Member

Yes it is not supporting in 1.x, and it is recommended to upgrade to 2.x, to use the full-localized color switcher:

"header.color.mode.light": "亮色模式",
"header.color.mode.dark": "暗色模式",
"header.color.mode.auto": "跟随系统",

Upgrading Guide (Chinese only): https://d.umijs.org/guide/upgrading

@PeachScript PeachScript closed this as not planned Won't fix, can't repro, duplicate, stale Jul 18, 2023
@PeachScript PeachScript added the no plan This will not be worked on label Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working no plan This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants