Skip to content
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

Lazy set moment locale #8785

Merged
merged 1 commit into from
Jan 13, 2018
Merged

Lazy set moment locale #8785

merged 1 commit into from
Jan 13, 2018

Conversation

yesmeck
Copy link
Member

@yesmeck yesmeck commented Dec 29, 2017

Fix #8662 #8816

uploadError: 'مشكلة فى الرفع',
previewFile: 'استعرض الملف',
},
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个 diff 看着慌。

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好像是原来的缩进有问题。

this.componentDidUpdate();
}

componentWillReceiveProps() {
this.setMomentLocale();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不用比较一下?

@yesmeck yesmeck force-pushed the lazy-set-moment-locale branch 6 times, most recently from 941a20d to 422d79c Compare December 29, 2017 10:54
@yesmeck
Copy link
Member Author

yesmeck commented Dec 29, 2017

b439ca7

原来的测试没测到这部分。

@yesmeck yesmeck force-pushed the lazy-set-moment-locale branch from 422d79c to 1dec931 Compare December 29, 2017 12:53
@codecov
Copy link

codecov bot commented Dec 29, 2017

Codecov Report

Merging #8785 into master will decrease coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #8785      +/-   ##
=========================================
- Coverage   85.32%   85.3%   -0.02%     
=========================================
  Files         227     194      -33     
  Lines        4696    4683      -13     
  Branches     1376    1384       +8     
=========================================
- Hits         4007    3995      -12     
+ Misses        689     688       -1
Impacted Files Coverage Δ
components/locale-provider/index.tsx 91.3% <100%> (+6.68%) ⬆️
components/dropdown/dropdown.tsx 100% <0%> (ø) ⬆️
components/date-picker/createPicker.tsx 92.59% <0%> (+1.85%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8de2b47...303a9e8. Read the comment docs.

import Pagination from 'rc-pagination/lib/locale/fr_FR';
import DatePicker from '../date-picker/locale/fr_FR';
import TimePicker from '../time-picker/locale/fr_FR';
import Calendar from '../calendar/locale/fr_FR';

export default {
locale: 'fr',
setMomentLocale() { moment.locale('fr'); },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这两个字符串如果都是一样的话,setMomentLocale 可以在 LocaleProvider 里写。

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

话说上面那个 locale 的作用是啥?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const localeCode = antLocale && antLocale.locale;

用于时间组件,如 DatePicker 内,强行设置 moment.locale,以应对 value 里面的 locale 与 LocaleProvider 的 locale 不一致的情况。

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

奥,那这个 localeCode 就是 moment 的 locale 表示。

@yesmeck yesmeck force-pushed the lazy-set-moment-locale branch 2 times, most recently from e1ef97c to 00c2ca5 Compare January 4, 2018 06:51
componentDidUpdate() {
const { locale } = this.props;
changeConfirmLocale(locale && locale.Modal);
}

componentWillUnMount() {
componentWillUnmount() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

原来写错了

@yesmeck yesmeck force-pushed the lazy-set-moment-locale branch 2 times, most recently from 7511474 to 3d69f4e Compare January 10, 2018 13:08
@yesmeck yesmeck force-pushed the lazy-set-moment-locale branch from 3d69f4e to bdf6016 Compare January 13, 2018 08:46
@yesmeck yesmeck force-pushed the lazy-set-moment-locale branch from bdf6016 to 303a9e8 Compare January 13, 2018 09:19
@yesmeck yesmeck merged commit 7f5922b into master Jan 13, 2018
@yesmeck yesmeck deleted the lazy-set-moment-locale branch January 13, 2018 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants