pro-components
pro-components copied to clipboard
🐛[BUG]日历国际化问题
提问前先看看:
https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md
🐛 bug 描述
日历国际化的问题真的需要你们统一处理一下。现在官网也出现这个问题了。我先前调版本调了好久都没啥用。provider也不能解决问题。
📷 复现步骤

🏞 期望结果
日历国际化,语言统一
The same question
+1,还没有解决吗
pro component 文档确实没说明相关的解决,下面是我的曲线救国方式,

- 安装
momentjs,
antd 的日期选择依赖于
moment,但不排除有部分使用者,讲momentjs改成了dayjs。如果改成了dayjs我并不知道能不能成功。
- 导入
moment的语言
import 'moment/locale/zh-cn';
<ProFormDatePicker
name="expirationDate"
rules={[{ required: true, message: '请选择到期时间!' }]}
fieldProps={{
locale: { locale },
}}
label="到期时间"
/>
提问前先看看:
https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md
🐛 bug 描述
日历国际化的问题真的需要你们统一处理一下。现在官网也出现这个问题了。我先前调版本调了好久都没啥用。provider也不能解决问题。
📷 复现步骤
🏞 期望结果
日历国际化,语言统一
解决方式: https://github.com/ant-design/pro-components/issues/5833#issuecomment-1288661470
pro component 文档确实没说明相关的解决,下面是我的曲线救国方式,
- 安装
momentjs,antd 的日期选择依赖于
moment,但不排除有部分使用者,讲momentjs改成了dayjs。如果改成了dayjs我并不知道能不能成功。
- 导入
moment的语言import 'moment/locale/zh-cn'; <ProFormDatePicker name="expirationDate" rules={[{ required: true, message: '请选择到期时间!' }]} fieldProps={{ locale: { locale }, }} label="到期时间" />
我知道这个方法,我这边项目是双语的,后面可能还会扩展语言。而且,项目里用到特别多这个组件,一个个改,太麻烦了。我就想有没有方法可以直接配置。一劳永逸。
pro component 文档确实没说明相关的解决,下面是我的曲线救国方式,
- 安装
momentjs,antd 的日期选择依赖于
moment,但不排除有部分使用者,讲momentjs改成了dayjs。如果改成了dayjs我并不知道能不能成功。
- 导入
moment的语言import 'moment/locale/zh-cn'; <ProFormDatePicker name="expirationDate" rules={[{ required: true, message: '请选择到期时间!' }]} fieldProps={{ locale: { locale }, }} label="到期时间" />我知道这个方法,我这边项目是双语的,后面可能还会扩展语言。而且,项目里用到特别多这个组件,一个个改,太麻烦了。我就想有没有方法可以直接配置。一劳永逸。
+1
这个应该是脚手架要处理的事情,umi 打开 antd 插件会自动处理,如果是其他脚手架按照 antd 官网的文档设置一下就能解决
https://ant.design/docs/react/i18n-cn
迷之操作,就这样关了吗,你们有自己看pro官网 https://procomponents.ant.design/components/table#%E9%80%9A%E8%BF%87-formref-%E6%9D%A5%E6%93%8D%E4%BD%9C%E6%9F%A5%E8%AF%A2%E8%A1%A8%E5%8D%95 查询表单的日期也变成英文了吗,之前都还是正常的
pro component 文档确实没说明相关的解决,下面是我的曲线救国方式,
- 安装
momentjs,antd 的日期选择依赖于
moment,但不排除有部分使用者,讲momentjs改成了dayjs。如果改成了dayjs我并不知道能不能成功。
- 导入
moment的语言import 'moment/locale/zh-cn'; <ProFormDatePicker name="expirationDate" rules={[{ required: true, message: '请选择到期时间!' }]} fieldProps={{ locale: { locale }, }} label="到期时间" />
fieldProps中的locale: { locale }不太明白,locale这个变量那里来的啊
这个问题是不会修复了嘛
import locale from 'antd/es/date-picker/locale/zh_CN';
来自于 antd
------------------ 原始邮件 ------------------ 发件人: "ant-design/pro-components" @.>; 发送时间: 2022年11月24日(星期四) 上午10:33 @.>; @.@.>; 主题: Re: [ant-design/pro-components] 🐛[BUG]日历国际化问题 (Issue #5833)
pro component 文档确实没说明相关的解决,下面是我的曲线救国方式,
安装 momentjs ,
antd 的日期选择依赖于 moment,但不排除有部分使用者,讲 momentjs 改成了 dayjs。如果改成了 dayjs 我并不知道能不能成功。
导入 moment 的语言 import 'moment/locale/zh-cn'; <ProFormDatePicker name="expirationDate" rules={[{ required: true, message: '请选择到期时间!' }]} fieldProps={{ locale: { locale }, }} label="到期时间" />
fieldProps中的locale: { locale }不太明白,locale这个变量那里来的啊
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>
import locale from 'antd/es/date-picker/locale/zh_CN'; 来自于 antd … ------------------ 原始邮件 ------------------ 发件人: "ant-design/pro-components" @.>; 发送时间: 2022年11月24日(星期四) 上午10:33 @.>; @.@.>; 主题: Re: [ant-design/pro-components] 🐛[BUG]日历国际化问题 (Issue #5833) pro component 文档确实没说明相关的解决,下面是我的曲线救国方式, 安装 momentjs , antd 的日期选择依赖于 moment,但不排除有部分使用者,讲 momentjs 改成了 dayjs。如果改成了 dayjs 我并不知道能不能成功。 导入 moment 的语言 import 'moment/locale/zh-cn'; <ProFormDatePicker name="expirationDate" rules={[{ required: true, message: '请选择到期时间!' }]} fieldProps={{ locale: { locale }, }} label="到期时间" /> fieldProps中的locale: { locale }不太明白,locale这个变量那里来的啊 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>
非常感谢
最新版的 "@ant-design/pro-components": "^2.3.47",
只需要在页面中引入:
import 'dayjs/locale/zh-cn';
就可以恢复成中文,其他没有配置
最新版的 "@ant-design/pro-components": "^2.3.47",
只需要在页面中引入:
import 'dayjs/locale/zh-cn';
就可以恢复成中文,其他没有配置
现在这个又不行了
注意下多版本 dayjs 的问题