-
-
Notifications
You must be signed in to change notification settings - Fork 10k
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
🐛 fix: antd i18n miss error #1083
🐛 fix: antd i18n miss error #1083
Conversation
@Wxh16144 is attempting to deploy a commit to the LobeHub Team on Vercel. A member of the Team first needs to authorize it. |
Thank you for raising your pull request and contributing to our Community |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## fix/antd-i18n #1083 +/- ##
================================================
Coverage ? 88.62%
================================================
Files ? 177
Lines ? 8350
Branches ? 953
================================================
Hits ? 7400
Misses ? 950
Partials ? 0 ☔ View full report in Codecov by Sentry. |
async () => { | ||
const localeName = lang?.includes('-') ? lang?.replace('-', '_') : 'en_US'; | ||
const antdLocale = await import(`antd/locale/${localeName}.js`); | ||
return antdLocale.default ?? antdLocale; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
之前 antd i18n 不生效是因为这里没 .default
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
大吃一惊
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@Wxh16144 还是不对呀: |
我懂了,默认打开时候是英文,设置里面设置为其他语言后,需要重新刷一下,我看看 swr 是不是需要手动再更新一下🤔 |
I understand, it opens in English by default. After setting it to other languages in the settings, you need to refresh it. Let me see if swr needs to be updated manually🤔 |
Swr在 key发生变化的时候会自动做重新请求的 |
Swr will automatically re-request when the key changes. |
有一个已知问题,#1049 添加了新的语言,只提供了国家,没有提供区域,无法正确的得到 antd 支持的语言。 cc @MEClouds |
There is a known issue, #1049 Added new languages, only country provided, not region, Unable to get language supported by antd correctly. cc @MEClouds |
可以在这里做处理: https://github.com/lobehub/lobe-chat/blob/main/src/locales/resources.ts#L22-L42 |
This can be done here: https://github.com/lobehub/lobe-chat/blob/main/src/locales/resources.ts#L22-L42 |
但是为啥 antd 支持的是 ar-EG ? |
But why does antd support ar-EG? |
Update normalizeLocale Function:
Then can use it with the import statement: :
|
[FETCH_ANTD_LOCALE, lang], | ||
async ([, l]) => { | ||
const localeName = l?.includes('-') ? l?.replace('-', '_') : 'en_US'; | ||
const antdLocale = await import(`antd/locale/${localeName}.js`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think you can use normalizeLocale function just import it from '@/locales/resources';
const antdLocale = await import(`antd/locale/${normalizeLocale(lang!).replace('-', '_')}.js`);
or
const localeName =normalizeLocale(l!).replace('-', '_');
const antdLocale = await import(`antd/locale/${localeName}.js`);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Wxh16144 冲突解决下?我先合到 fix/antd-i18n 里再改改
95e17a9
to
ea24177
Compare
❤️ Great PR @Wxh16144 ❤️ The growth of project is inseparable from user feedback and contribution, thanks for your contribution! If you are interesting with the lobehub developer community, please join our discord and then dm @arvinxx or @canisminor1990. They will invite you to our private developer channel. We are talking about the lobe-chat development or sharing ai newsletter around the world. |
* 📝 docs(bot): Auto sync agents & plugin to readme * 🐛 fix: antd i18n miss error * 🐛 fix: update logic * 🍻 chore: update --------- Co-authored-by: lobehubbot <i@lobehub.com>
* 🐛 fix: antd i18n miss error (#1083) * 📝 docs(bot): Auto sync agents & plugin to readme * 🐛 fix: antd i18n miss error * 🐛 fix: update logic * 🍻 chore: update --------- Co-authored-by: lobehubbot <i@lobehub.com> * 🐛 fix: fix antd locale fetch * 🐛 fix: fix antd locale fetch * 🐛 fix: fix antd locale fetch --------- Co-authored-by: 红 <wxh1220@gmail.com> Co-authored-by: lobehubbot <i@lobehub.com>
### [Version 0.120.3](v0.120.2...v0.120.3) <sup>Released on **2024-01-19**</sup> #### ♻ Code Refactoring - **misc**: Refactor antd i18n and improve locale order. <br/> <details> <summary><kbd>Improvements and Fixes</kbd></summary> #### Code refactoring * **misc**: Refactor antd i18n and improve locale order, closes [#1103](#1103) [#1083](#1083) ([c89f527](c89f527)) </details> <div align="right"> [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top) </div>
🎉 This PR is included in version 0.120.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
### [Version 1.2.3](v1.2.2...v1.2.3) <sup>Released on **2024-01-19**</sup> #### ♻ Code Refactoring - **misc**: Refactor antd i18n and improve locale order. <br/> <details> <summary><kbd>Improvements and Fixes</kbd></summary> #### Code refactoring * **misc**: Refactor antd i18n and improve locale order, closes [lobehub#1103](https://github.com/bentwnghk/lobe-chat/issues/1103) [lobehub#1083](https://github.com/bentwnghk/lobe-chat/issues/1083) ([c89f527](c89f527)) </details> <div align="right"> [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top) </div>
### [Version 0.120.3](lobehub/lobe-chat@v0.120.2...v0.120.3) <sup>Released on **2024-01-19**</sup> #### ♻ Code Refactoring - **misc**: Refactor antd i18n and improve locale order. <br/> <details> <summary><kbd>Improvements and Fixes</kbd></summary> #### Code refactoring * **misc**: Refactor antd i18n and improve locale order, closes [#1103](lobehub/lobe-chat#1103) [#1083](lobehub/lobe-chat#1083) ([c89f527](lobehub/lobe-chat@c89f527)) </details> <div align="right"> [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top) </div>
💻 变更类型 | Change Type
🔀 变更说明 | Description of Change
📝 补充信息 | Additional Information