feat: support i18n

Signed-off-by: RobotHuang <1183598761@qq.com>
This commit is contained in:
RobotHuang
2021-02-19 23:23:59 +08:00
parent a09a8b2af0
commit e301121c21
18 changed files with 373 additions and 102 deletions

View File

@ -18,6 +18,7 @@ import {Button, Col, Popconfirm, Row, Switch, Table} from 'antd';
import moment from "moment";
import * as Setting from "./Setting";
import * as UserBackend from "./backend/UserBackend";
import i18next from "i18next";
class UserListPage extends React.Component {
constructor(props) {
@ -90,7 +91,7 @@ class UserListPage extends React.Component {
renderTable(users) {
const columns = [
{
title: 'Organization',
title: i18next.t("general:Organization"),
dataIndex: 'owner',
key: 'owner',
width: '120px',
@ -104,7 +105,7 @@ class UserListPage extends React.Component {
}
},
{
title: 'Name',
title: i18next.t("general:Name"),
dataIndex: 'name',
key: 'name',
width: '100px',
@ -118,7 +119,7 @@ class UserListPage extends React.Component {
}
},
{
title: 'Created Time',
title: i18next.t("general:Created Time"),
dataIndex: 'createdTime',
key: 'createdTime',
width: '160px',
@ -142,14 +143,14 @@ class UserListPage extends React.Component {
// sorter: (a, b) => a.password.localeCompare(b.password),
// },
{
title: 'Display Name',
title: i18next.t("general:Display Name"),
dataIndex: 'displayName',
key: 'displayName',
// width: '100px',
sorter: (a, b) => a.displayName.localeCompare(b.displayName),
},
{
title: 'Avatar',
title: i18next.t("general:Avatar"),
dataIndex: 'avatar',
key: 'avatar',
width: '100px',
@ -162,7 +163,7 @@ class UserListPage extends React.Component {
}
},
{
title: 'Email',
title: i18next.t("general:Email"),
dataIndex: 'email',
key: 'email',
width: '160px',
@ -183,21 +184,21 @@ class UserListPage extends React.Component {
// sorter: (a, b) => a.phone.localeCompare(b.phone),
// },
{
title: 'Affiliation',
title: i18next.t("user:Affiliation"),
dataIndex: 'affiliation',
key: 'affiliation',
width: '120px',
sorter: (a, b) => a.affiliation.localeCompare(b.affiliation),
},
{
title: 'Tag',
title: i18next.t("user:Tag"),
dataIndex: 'tag',
key: 'tag',
width: '100px',
sorter: (a, b) => a.tag.localeCompare(b.tag),
},
{
title: 'Is Admin',
title: i18next.t("user:Is Admin"),
dataIndex: 'isAdmin',
key: 'isAdmin',
width: '120px',
@ -209,7 +210,7 @@ class UserListPage extends React.Component {
}
},
{
title: 'Is Global Admin',
title: i18next.t("user:Is Global Admin"),
dataIndex: 'isGlobalAdmin',
key: 'isGlobalAdmin',
width: '120px',
@ -221,19 +222,19 @@ class UserListPage extends React.Component {
}
},
{
title: 'Action',
title: i18next.t("general:Action"),
dataIndex: '',
key: 'op',
width: '170px',
render: (text, record, index) => {
return (
<div>
<Button style={{marginTop: '10px', marginBottom: '10px', marginRight: '10px'}} type="primary" onClick={() => this.props.history.push(`/users/${record.owner}/${record.name}`)}>Edit</Button>
<Button style={{marginTop: '10px', marginBottom: '10px', marginRight: '10px'}} type="primary" onClick={() => this.props.history.push(`/users/${record.owner}/${record.name}`)}>{i18next.t("general:Edit")}</Button>
<Popconfirm
title={`Sure to delete user: ${record.name} ?`}
onConfirm={() => this.deleteUser(index)}
>
<Button style={{marginBottom: '10px'}} type="danger">Delete</Button>
<Button style={{marginBottom: '10px'}} type="danger">{i18next.t("general:Delete")}</Button>
</Popconfirm>
</div>
)
@ -246,8 +247,8 @@ class UserListPage extends React.Component {
<Table columns={columns} dataSource={users} rowKey="name" size="middle" bordered pagination={{pageSize: 100}}
title={() => (
<div>
Users&nbsp;&nbsp;&nbsp;&nbsp;
<Button type="primary" size="small" onClick={this.addUser.bind(this)}>Add</Button>
{i18next.t("general:Users")}&nbsp;&nbsp;&nbsp;&nbsp;
<Button type="primary" size="small" onClick={this.addUser.bind(this)}>{i18next.t("general:Add")}</Button>
</div>
)}
loading={users === null}