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
DatePicker日期国际化错误 中英文都存在 #23891
Comments
还需要引用 moment 的语言包:https://codesandbox.io/s/antd-reproduction-template-64gfh?file=/index.js:273-303 我补充一下文档。 |
这个demo里面的选择框也不全是中文呀,,,按照这个设置了并不好使。。 |
Same issue when version >= 4.2.1, week is english. |
奇怪,全配对了moment也不生效,仍然是一半英文,moment": "2.27.0","antd": "4.5.2", |
我也感觉很奇怪,之前没有这个问题,升级后就出现了,却解决不了,很明显是moment的配置没有生效。试了查依赖发现rc picker用的moment与antd的不一样,不知道有没有影响
![image](https://user-images.githubusercontent.com/39182231/89267957-78d00e80-d66a-11ea-9f67-7af7f3553fff.png)
|
@JarVZhao 移除 yarn.lock 或者 package-lock.json 后重新安装。 |
works,thanks @afc163 |
把antd版本降为4.2.0, 在哪里看到了>=4.2.1周为英文,本人已试, 可用 |
Bundlers might create multiple copies of moment when using moment@2.27.0, hence |
同样的问题, antd4.6.5 moment 2.29.0 moment恢复老版本2.24.0可展示中文,但是ts报错。。 moment升级最新的,ts是不报错了,但是中英文就都有了。一个时间组件而已这么依赖moment干嘛。。。 |
我的办法是删除yarn.lock,重新安装一下,应该是之前安装的moment版本和antd不匹配,如果只重新安装moment和antd并不能解决其他的依赖问题,让他全量更新一下就好了。 |
�我也遇到同样问题,降级到2.24.0解决的,老项目没有ts |
首先按照antd官网配置
版本:
|
moment的package.json里有个jsnext:main属性指向的是./dist/moment.js。也就是说如果外部打包工具设置了能够识别jsnext:main这个属性的话,import moment from 'moment' 对应的应该是 import 'moment/dist/locale/zh-cn'。 |
+1 升级的时候容易出现这种情况,建议官方尽早移除对moment的依赖 |
@wumiangithub 我也遇到了这个问题(rc-picker 依赖moment:v2.24.0)和我本地的版本v:2.27.0不一致,请问你是如何解决的呢? |
我知道了,rc-picker 的package中引用的是^2.24.0,^实际取得是最近的大版本,所以实际版本应该看node_modules->moment>momentjs的version实际为2.29.1,那么本地版本修改为^2.24.0就可以了 |
还是没看懂要怎么解决,antd版本4.11.2,moment版本2.29.1,依然是中英文混合 moment.locales()输出结果: 在zh-cn.js打断点,明明执行进去了
但是一点用没有 |
将 修改为:
版本: "antd": "^4.15.1",
"moment": "^2.29.1" 测试可行。 |
感谢, 确实, dist下面的文件是ejs格式的 |
"antd": "^4.16.13"可行 |
moment版本不一致导致的,rc-calender指定moment为2.x,把自己项目的package.json里moment版本号对齐就可以解决了,先yarn remove moment,再手动添加"moment": "2.x"到package.json,然后yarn一下重新安装依赖 |
本地运行是正常的,可是发布到测试环境就变中英混合,这是啥原因呢 |
我用的pro; |
antd@4.23.2
https://codesandbox.io/s/suspicious-banzai-iwpso4?file=/src/App.js |
|
@zombieJ 请教下,现在 4.24.8 版本国际化中文的需求,是不是不需要在项目内 moment.locale('zh_cn') 了? |
此方法管用,谢谢 |
yarn add moment@2.29.4 装了这个版本可以了 |
如果使用的是yarn 可以加上resolutions 字段固定moment版本 其他工具同理 |
有用 |
Reproduction link
Steps to reproduce
添加全局本地化
What is expected?
显示应该是全部中文
What is actually happening?
日期有中文有英文
The text was updated successfully, but these errors were encountered: