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

Optimize internationalization related comments #54

Merged
merged 1 commit into from
Dec 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/common/menu.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { isUrl } from '../utils/utils';
import { getIntlContent } from '../utils/IntlUtils'
/** 菜单 移到 统一地方 处理 */

export const menuData = [
{
name: getIntlContent('SOUL.MENU.PLUGIN.LIST'),
Expand Down
16 changes: 7 additions & 9 deletions src/components/SiderMenu/SiderMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ export default class SiderMenu extends PureComponent {
}

/**
* 判断是否是http链接.返回 Link 或 a
* Judge whether it is http link.return a or Link
* @memberof SiderMenu
*
* member of SiderMenu
*/
getMenuItemPath = item => {
const itemPath = this.conversionPath(item.path);
Expand Down Expand Up @@ -145,7 +145,7 @@ export default class SiderMenu extends PureComponent {
getSubMenuOrItem = item => {
if (item.children && item.children.some(child => child.name)) {
const childrenItems = this.getNavMenuItems(item.children);
// 当无子菜单时就不展示菜单
// The menu is not displayed when there are no submenus
if (childrenItems && childrenItems.length > 0) {
return (
<SubMenu
Expand All @@ -172,8 +172,7 @@ export default class SiderMenu extends PureComponent {
};

/**
* 获得菜单子节点
* @memberof SiderMenu
* Get the menu items
*/
getNavMenuItems = menusData => {
if (!menusData) {
Expand All @@ -200,7 +199,6 @@ export default class SiderMenu extends PureComponent {
};

// conversion Path
// 转化路径
conversionPath = path => {
if (path && path.indexOf('http') === 0) {
return path;
Expand Down Expand Up @@ -232,7 +230,7 @@ export default class SiderMenu extends PureComponent {
});
};

/** 根据当前语言 修改 菜单 */
/** Modify the menu based on the current language */
updateMenuData() {
if (this.props.menuData.length === 0) {
return;
Expand All @@ -241,14 +239,14 @@ export default class SiderMenu extends PureComponent {
// eslint-disable-next-line no-plusplus
for ( let i = 0 ; i < this.props.menuData.length; i++) {
if (this.props.menuData[i].locale) {
this.props.menuData[i].name = getIntlContent(this.props.menuData[i].locale);
this.props.menuData[i].name = getIntlContent(this.props.menuData[i].locale, this.props.menuData[i].name);
}

if (this.props.menuData[i].children.length > 0) {
// eslint-disable-next-line no-plusplus
for (let j = 0; j < this.props.menuData[i].children.length; j++) {
if (this.props.menuData[i].children[j].locale) {
this.props.menuData[i].children[j].name = getIntlContent(this.props.menuData[i].children[j].locale);
this.props.menuData[i].children[j].name = getIntlContent(this.props.menuData[i].children[j].locale, this.props.menuData[i].children[j].name);
}
}
}
Expand Down
15 changes: 7 additions & 8 deletions src/layouts/BasicLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const { Content, Header } = Layout;
const { AuthorizedRoute, check } = Authorized;

/**
* 根据菜单取得重定向地址.
* Get the redirect address from the menu.
*/
const redirectData = [];
const getRedirect = item => {
Expand All @@ -44,9 +44,10 @@ const getRedirect = item => {
getMenuData().forEach(getRedirect);

/**
* 获取面包屑映射
* @param {Object} menuData 菜单配置
* @param {Object} routerData 路由配置
* Gets the breadcrumb map
*
* @param {Object} menuData
* @param {Object} routerData
*/
const getBreadcrumbNameMap = (menuData, routerData) => {
const result = {};
Expand Down Expand Up @@ -110,7 +111,7 @@ class BasicLayout extends React.PureComponent {
getPageTitle() {
const { routerData, location } = this.props;
const { pathname } = location;
let title = "网关管理";
let title = "Gateway Management";
let currRouterData = null;
// match params path
Object.keys(routerData).forEach(key => {
Expand All @@ -119,14 +120,13 @@ class BasicLayout extends React.PureComponent {
}
});
if (currRouterData && currRouterData.name) {
title = `soul - 网关管理`;
title = `Soul - Gateway Management`;
}
return title;
}

getBaseRedirect = () => {
// According to the url parameter to redirect
// 这里是重定向的,重定向到 url 的 redirect 参数所示地址
const urlParams = new URL(window.location.href);

const redirect = urlParams.searchParams.get("redirect");
Expand Down Expand Up @@ -166,7 +166,6 @@ class BasicLayout extends React.PureComponent {
<Layout>
<SiderMenu
logo={logo}
// 不带Authorized参数的情况下如果没有权限,会强制跳到403界面
// If you do not have the Authorized parameter
// you will be forced to jump to the 403 interface without permission
Authorized={Authorized}
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/UserLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class UserLayout extends React.PureComponent {
getPageTitle() {
const { routerData, location } = this.props;
const { pathname } = location;
let title = "登录";
let title = "Login";
if (routerData[pathname] && routerData[pathname].name) {
title = `${routerData[pathname].name} - bbex`;
}
Expand Down
6 changes: 5 additions & 1 deletion src/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
"SOUL.COMMON.YES":"YES",
"SOUL.COMMON.NO":"NO",
"SOUL.COMMON.PLEASESELECT":"Select",
"SOUL.COMMON.RESPONSE.ADD.SUCCESS":"Add Success",
"SOUL.COMMON.RESPONSE.UPDATE.SUCCESS":"Update Success",
"SOUL.COMMON.RESPONSE.DELETE.SUCCESS":"Delete Success",
"SOUL.COMMON.RESPONSE.SYNC.SUCCESS":"Sync Success",
"SOUL.COMMON.WARN.INPUT_SELECTOR":"Please add selector first",
"SOUL.MENU.PLUGIN.LIST": "PluginList",
"SOUL.MENU.PLUGIN.DIVIDE": "divide",
"SOUL.MENU.PLUGIN.HYSTRIX": "hystrix",
Expand All @@ -36,7 +41,6 @@
"SOUL.MENU.PLUGIN.RATE_LIMITER": "rate_limiter",
"SOUL.MENU.PLUGIN.DUBBO": "dubbo",
"SOUL.MENU.PLUGIN.MONITOR": "monitor",
"SOUL.MENU.PLUGIN.SPRINGCLOUD": "springCloud",
"SOUL.MENU.PLUGIN.SENTINEL": "sentinel",
"SOUL.MENU.PLUGIN.RESILIENCE4J": "resilience4j",
"SOUL.MENU.SYSTEM.MANAGMENT": "System Manage",
Expand Down
5 changes: 5 additions & 0 deletions src/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
"SOUL.COMMON.YES":"是",
"SOUL.COMMON.NO":"否",
"SOUL.COMMON.PLEASESELECT":"请选择",
"SOUL.COMMON.RESPONSE.ADD.SUCCESS":"添加成功",
"SOUL.COMMON.RESPONSE.UPDATE.SUCCESS":"修改成功",
"SOUL.COMMON.RESPONSE.DELETE.SUCCESS":"删除成功",
"SOUL.COMMON.RESPONSE.SYNC.SUCCESS":"同步成功",
"SOUL.COMMON.WARN.INPUT_SELECTOR":"请先添加选择器",
"SOUL.SIDERMENU.LOGO": "Soul网关管理",
"SOUL.MENU.PLUGIN.LIST": "插件列表",
"SOUL.MENU.PLUGIN.DIVIDE": "divide",
Expand Down
11 changes: 6 additions & 5 deletions src/models/auth.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { message } from 'antd';
import { getIntlContent } from '../utils/IntlUtils'
import { getAllAuths, findAuthData,findAuthDataDel, updateAuthData,updateAuthDel,updateAuthEnabled, deleteAuths, addAuthData, syncAuthsData,getAllMetadata, getAllMetadatas, getfetchMetaGroup } from '../services/api';

export default {
Expand Down Expand Up @@ -77,7 +78,7 @@ export default {
const { payload, callback, fetchValue } = params;
const json = yield call(addAuthData, payload);
if (json.code === 200) {
message.success("添加成功");
message.success(getIntlContent('SOUL.COMMON.RESPONSE.ADD.SUCCESS'));
callback();
yield put({ type: "reload", fetchValue });
} else {
Expand All @@ -89,7 +90,7 @@ export default {

const json = yield call(deleteAuths, payload );
if (json.code === 200) {
message.success("删除成功");
message.success(getIntlContent('SOUL.COMMON.RESPONSE.DELETE.SUCCESS'));
callback();
yield put({ type: "reload", fetchValue });
} else {
Expand All @@ -101,7 +102,7 @@ export default {

const json = yield call(updateAuthData, payload);
if (json.code === 200) {
message.success("修改成功");
message.success(getIntlContent('SOUL.COMMON.RESPONSE.UPDATE.SUCCESS'));
callback();
yield put({ type: "reload", fetchValue });
} else {
Expand All @@ -112,7 +113,7 @@ export default {
const { payload, callback, fetchValue } = params;
const json = yield call(updateAuthDel, payload);
if (json.code === 200) {
message.success("修改成功");
message.success(getIntlContent('SOUL.COMMON.RESPONSE.UPDATE.SUCCESS'));
callback();
yield put({ type: "reload", fetchValue });
} else {
Expand All @@ -129,7 +130,7 @@ export default {
const {payload,fetchValue,callback} = params;
const json = yield call (updateAuthEnabled,payload);
if(json.code===200){
message.success("修改成功");
message.success(getIntlContent('SOUL.COMMON.RESPONSE.UPDATE.SUCCESS'));
callback();
yield put({type: "reload", fetchValue});
} else {
Expand Down
13 changes: 7 additions & 6 deletions src/models/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
findRule,
updateRule,
} from "../services/api";
import {getIntlContent} from "../utils/IntlUtils";

export default {
namespace: "common",
Expand Down Expand Up @@ -82,7 +83,7 @@ export default {
const { payload, callback, fetchValue } = params;
const json = yield call(addSelector, payload);
if (json.code === 200) {
message.success("添加成功");
message.success(getIntlContent('SOUL.COMMON.RESPONSE.ADD.SUCCESS'));
callback();
yield put({ type: "reload", fetchValue });
} else {
Expand All @@ -94,7 +95,7 @@ export default {
const { payload, callback, fetchValue } = params;
const json = yield call(addRule, payload);
if (json.code === 200) {
message.success("添加成功");
message.success(getIntlContent('SOUL.COMMON.RESPONSE.ADD.SUCCESS'));
callback();
yield put({ type: "reloadRule", fetchValue });
} else {
Expand All @@ -115,7 +116,7 @@ export default {
const { list } = payload;
const json = yield call(deleteSelector, { list });
if (json.code === 200) {
message.success("删除成功");
message.success(getIntlContent('SOUL.COMMON.RESPONSE.DELETE.SUCCESS'));
yield put({
type: "saveRule",
payload: {
Expand All @@ -132,7 +133,7 @@ export default {
const { payload, callback, fetchValue } = params;
const json = yield call(updateSelector, payload);
if (json.code === 200) {
message.success("修改成功");
message.success(getIntlContent('SOUL.COMMON.RESPONSE.UPDATE.SUCCESS'));
callback();
yield put({ type: "reload", fetchValue });
} else {
Expand All @@ -144,7 +145,7 @@ export default {
const { list } = payload;
const json = yield call(deleteRule, { list });
if (json.code === 200) {
message.success("删除成功");
message.success(getIntlContent('SOUL.COMMON.RESPONSE.DELETE.SUCCESS'));
yield put({ type: "reloadRule", fetchValue });
} else {
message.warn(json.message);
Expand All @@ -162,7 +163,7 @@ export default {
const { payload, callback, fetchValue } = params;
const json = yield call(updateRule, payload);
if (json.code === 200) {
message.success("修改成功");
message.success(getIntlContent('SOUL.COMMON.RESPONSE.UPDATE.SUCCESS'));
callback();
yield put({ type: "reloadRule", fetchValue });
} else {
Expand Down
13 changes: 7 additions & 6 deletions src/models/divide.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
findRule,
updateRule,
} from "../services/api";
import {getIntlContent} from "../utils/IntlUtils";

export default {
namespace: "divide",
Expand Down Expand Up @@ -80,7 +81,7 @@ export default {
const { payload, callback, fetchValue } = params;
const json = yield call(addSelector, payload);
if (json.code === 200) {
message.success("添加成功");
message.success(getIntlContent('SOUL.COMMON.RESPONSE.ADD.SUCCESS'));
callback();
yield put({ type: "reload", fetchValue });
} else {
Expand All @@ -92,7 +93,7 @@ export default {
const { payload, callback, fetchValue } = params;
const json = yield call(addRule, payload);
if (json.code === 200) {
message.success("添加成功");
message.success(getIntlContent('SOUL.COMMON.RESPONSE.ADD.SUCCESS'));
callback();
yield put({ type: "reloadRule", fetchValue });
} else {
Expand All @@ -113,7 +114,7 @@ export default {
const { list } = payload;
const json = yield call(deleteSelector, { list });
if (json.code === 200) {
message.success("删除成功");
message.success(getIntlContent('SOUL.COMMON.RESPONSE.DELETE.SUCCESS'));
yield put({
type: "saveRule",
payload: {
Expand All @@ -130,7 +131,7 @@ export default {
const { payload, callback, fetchValue } = params;
const json = yield call(updateSelector, payload);
if (json.code === 200) {
message.success("修改成功");
message.success(getIntlContent('SOUL.COMMON.RESPONSE.UPDATE.SUCCESS'));
callback();
yield put({ type: "reload", fetchValue });
} else {
Expand All @@ -142,7 +143,7 @@ export default {
const { list } = payload;
const json = yield call(deleteRule, { list });
if (json.code === 200) {
message.success("删除成功");
message.success(getIntlContent('SOUL.COMMON.RESPONSE.DELETE.SUCCESS'));
yield put({ type: "reloadRule", fetchValue });
} else {
message.warn(json.message);
Expand All @@ -160,7 +161,7 @@ export default {
const { payload, callback, fetchValue } = params;
const json = yield call(updateRule, payload);
if (json.code === 200) {
message.success("修改成功");
message.success(getIntlContent('SOUL.COMMON.RESPONSE.UPDATE.SUCCESS'));
callback();
yield put({ type: "reloadRule", fetchValue });
} else {
Expand Down
3 changes: 2 additions & 1 deletion src/models/global.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { message } from "antd";
import { queryPlatform, getAllPlugins, asyncOnePlugin } from "../services/api";
import {getIntlContent} from "../utils/IntlUtils";

export default {
namespace: "global",
Expand Down Expand Up @@ -44,7 +45,7 @@ export default {
const { payload } = params;
const json = yield call(asyncOnePlugin, payload);
if (json.code === 200) {
message.success("同步成功");
message.success(getIntlContent('SOUL.COMMON.RESPONSE.SYNC.SUCCESS'));
} else {
message.warn(json.message);
}
Expand Down
Loading