LocalePrivider should not dependconfirm

This commit is contained in:
afc163 2016-05-12 13:25:00 +08:00
parent a33c3d12a7
commit a3850a4df8
3 changed files with 23 additions and 17 deletions

View File

@ -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 = {

View File

@ -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 };
@ -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;

View File

@ -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;
}