umijs / dumi

📖 Static Site Generator for component library development
https://d.umijs.org
MIT License
3.6k stars 1.18k forks source link

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

Closed SEWeiTung closed 1 year ago

SEWeiTung commented 1 year ago

Versions

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: https://github.com/umijs/dumi/blob/dbf20d9ae7a078d0b1b0544bb433524edd1bfa38/packages/theme-default/src/components/Dark.tsx#L33-L47

PeachScript commented 1 year ago

Yes it is not supporting in 1.x, and it is recommended to upgrade to 2.x, to use the full-localized color switcher: https://github.com/umijs/dumi/blob/de3ad27916129d0bffffad43ccceaf657c228384/src/client/theme-default/locales/zh-CN.json#L3-L5

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