Skip to content

Commit

Permalink
LocalePrivider should not dependconfirm
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 committed May 12, 2016
1 parent a33c3d1 commit a3850a4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
2 changes: 1 addition & 1 deletion components/locale-provider/index.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { changeConfirmLocale } from '../modal/confirm';
import { changeConfirmLocale } from '../modal/locale';

export default class LocaleProvider extends React.Component {
static propTypes = {
Expand Down
19 changes: 3 additions & 16 deletions components/modal/confirm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,7 @@ import Dialog from './Modal';
import Icon from '../icon';
import Button from '../button';
import classNames from 'classnames';

const defaultLocale = {
okText: '确定',
cancelText: '取消',
justOkText: '知道了',
};

let runtimeLocale = { ...defaultLocale };

export function changeConfirmLocale(newLocale) {
if (newLocale) {
runtimeLocale = { ...runtimeLocale, ...newLocale };
} else {
runtimeLocale = { ...defaultLocale };
}
}
import { getConfirmLocale } from './locale';

export default function confirm(config) {
const props = { ...config };
Expand All @@ -37,6 +22,8 @@ export default function confirm(config) {
props.okCancel = true;
}

const runtimeLocale = getConfirmLocale();

props.okText = props.okText ||
(props.okCancel ? runtimeLocale.okText : runtimeLocale.justOkText);
props.cancelText = props.cancelText || runtimeLocale.cancelText;
Expand Down
19 changes: 19 additions & 0 deletions components/modal/locale.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const defaultLocale = {
okText: '确定',
cancelText: '取消',
justOkText: '知道了',
};

let runtimeLocale = { ...defaultLocale };

export function changeConfirmLocale(newLocale) {
if (newLocale) {
runtimeLocale = { ...runtimeLocale, ...newLocale };
} else {
runtimeLocale = { ...defaultLocale };
}
}

export function getConfirmLocale(newLocale) {
return runtimeLocale;
}

0 comments on commit a3850a4

Please sign in to comment.