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

关于LocaleProvider汉化的问题 #8881

Closed
guoxiangwen opened this Issue Jan 9, 2018 · 10 comments

Comments

Projects
None yet
4 participants
@guoxiangwen

guoxiangwen commented Jan 9, 2018

Version

3.1.0

Environment

Chrome win10

Reproduction link

https://ant.design/components/locale-provider-cn/

Steps to reproduce

我根据官网的说明 配置相关
index.html

<script src="//cdn.bootcss.com/moment.js/2.20.1/moment.min.js"></script>
<script src="//cdn.bootcss.com/moment.js/2.20.1/moment-with-locales.min.js"></script>
<script src="https://cdn.bootcss.com/moment.js/2.20.1/locale/zh-cn.js"></script>
<script src="//cdn.bootcss.com/antd/3.1.0/antd.min.js"></script>
<script src="//cdn.bootcss.com/antd/3.1.0/antd-with-locales.min.js"></script>

entry.jsx

      const { LocaleProvider, locales } = antd;
      moment.locale('zh-cn');
        <Provider store={store}>
         <LocaleProvider locale={locales.zh_CN}>
           <HashRouter>
        <Switch>
          <Route path="/user" render={props => <UserLayout {...props} />} />
          <Route path="/" render={props => <DashboardLayout {...props} />} />
        </Switch>
      </HashRouter>
    </LocaleProvider>
  </Provider>,

What is expected?

DatePicker组件英文变成中文

What is actually happening?

在某一个页面中用 DatePicker组件,初始化的时候是显示的中文,但是today还是英文。当选择日期的时候再次打开 全部变成英文


因为这个设计到环境的问题,我的antd组件都是挂载window下的。所以无法用codeopen重现

@ant-design-bot

This comment has been minimized.

ant-design-bot commented Jan 9, 2018

It will be better to write your issue/comment in English, so more people can understand you.
And this means that more people can help you or benefit from your issue/comment.
See: #4897

@ant-design-bot

This comment has been minimized.

ant-design-bot commented Jan 9, 2018

Hello @guoxiangwen. Please provide a online reproduction by forking this link https://u.ant.design/codesandbox-repro. Issues labeled by Need Reproduce will be closed if no activities in 7 days.

@afc163

This comment has been minimized.

Member

afc163 commented Jan 9, 2018

<script src="//cdn.bootcss.com/antd/3.1.0/antd.min.js"></script>
<script src="//cdn.bootcss.com/antd/3.1.0/antd-with-locales.min.js"></script>

这两个是重复的。

@guoxiangwen

This comment has been minimized.

guoxiangwen commented Jan 9, 2018

@afc163 已经改过来了,还是一样的效果

@afc163

This comment has been minimized.

Member

afc163 commented Jan 9, 2018

<script src="//cdn.bootcss.com/moment.js/2.20.1/moment-with-locales.min.js"></script>

保留这个一个就够了,moment.min.jszh-cn.js 也是重复的。

@afc163

This comment has been minimized.

Member

afc163 commented Jan 9, 2018

https://codepen.io/afc163/pen/LeQVxg?editors=0010

发现需要这么写才行:locales.zh_CN.default

@afc163

This comment has been minimized.

Member

afc163 commented Jan 9, 2018

@yesmeck 这块是不是可以修正?

@guoxiangwen

This comment has been minimized.

guoxiangwen commented Jan 9, 2018

厉害。谢谢了

@guoxiangwen

This comment has been minimized.

guoxiangwen commented Jan 9, 2018

@afc163 大神,还有个问题,就是我的所有antd的组件以及css都是通过link和script标签挂载在window下的。然后在webpack extral.如果要修改字体大小或者其他的属性。按照官网的方法是行不通的。有没有什么办法呢?

@yesmeck

This comment has been minimized.

Member

yesmeck commented Jan 9, 2018

奇怪,我本地 build 出来没有这个 default。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment