Skip to content

Commit d9ab58f

Browse files
committed
fix(filterrules): support i18n
1 parent 950c864 commit d9ab58f

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

.dumi/global.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
@import "antd/dist/antd.css";
2+
@import '@dtinsight/react-icons/dist/index.css';

src/filterRules/index.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ export enum ROW_PERMISSION_RELATION {
1111
AND = 1,
1212
OR = 2,
1313
}
14-
export const ROW_PERMISSION_RELATION_TEXT = {
15-
[ROW_PERMISSION_RELATION.AND]: '且',
16-
[ROW_PERMISSION_RELATION.OR]: '或',
17-
};
1814

1915
export interface IComponentProps<T> {
2016
rowKey: string; // 当前节点的唯一标识

src/filterRules/ruleController/index.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@ import React from 'react';
22
import { MinusCircleOutlined, PlusCircleOutlined } from '@dtinsight/react-icons';
33
import { InternalNamePath } from 'antd/lib/form/interface';
44
import classnames from 'classnames';
5+
import { useLocale } from 'dt-react-component';
56

6-
import {
7-
IComponentProps,
8-
IFilterValue,
9-
ROW_PERMISSION_RELATION,
10-
ROW_PERMISSION_RELATION_TEXT,
11-
} from '..';
7+
import { IComponentProps, IFilterValue, ROW_PERMISSION_RELATION } from '..';
128
import './index.scss';
139

1410
interface IProps<T> {
@@ -46,6 +42,13 @@ export const RulesController = <T,>(props: IProps<T>) => {
4642
onChangeRowValues,
4743
} = props;
4844

45+
const locale = useLocale('FilterRules');
46+
47+
const ROW_PERMISSION_RELATION_TEXT = {
48+
[ROW_PERMISSION_RELATION.AND]: locale.and,
49+
[ROW_PERMISSION_RELATION.OR]: locale.or,
50+
};
51+
4952
const isCondition = (item: IFilterValue<T>) =>
5053
item?.type &&
5154
[ROW_PERMISSION_RELATION.AND, ROW_PERMISSION_RELATION.OR].includes(item?.type);

src/locale/useLocale.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ export interface Locale {
2121
};
2222
FilterRules: {
2323
message: string;
24+
and: string;
25+
or: string;
2426
};
2527
Fullscreen: { exitFull: string; full: string };
2628
GlobalLoading: { loading: string };

0 commit comments

Comments
 (0)