Skip to content

Commit

Permalink
feat(i18n): metrics module (apache#326)
Browse files Browse the repository at this point in the history
* i18n metrics

* combine import
  • Loading branch information
TikWind authored Jul 24, 2020
1 parent d398fa4 commit a289aba
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/locales/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { PluginFormZhCN } from '@/components/PluginForm';

import { ConsumerZhCN } from '@/pages/Consumer';
import { RouteZhCN } from '@/pages/Route';

import component from './zh-CN/component';
import globalHeader from './zh-CN/globalHeader';
import menu from './zh-CN/menu';
Expand Down
9 changes: 5 additions & 4 deletions src/pages/Metrics/Metrics.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React, { useState, useEffect } from 'react';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { Empty, Button, Card } from 'antd';
import { history } from 'umi';
import { history, useIntl } from 'umi';

import { getGrafanaURL } from './service';

const Metrics: React.FC = () => {
const [grafanaURL, setGrafanaURL] = useState<string | undefined>();
const { formatMessage } = useIntl();

useEffect(() => {
getGrafanaURL().then((url) => {
Expand All @@ -15,15 +16,15 @@ const Metrics: React.FC = () => {
}, []);

return (
<PageHeaderWrapper title="监控">
<PageHeaderWrapper title={formatMessage({ id: 'metrics.monitor' })}>
<Card>
{!grafanaURL && (
<Empty
image="https://gw.alipayobjects.com/zos/antfincdn/ZHrcdLPrvN/empty.svg"
imageStyle={{
height: 60,
}}
description={<span>您还未配置 Grafana</span>}
description={<span>{formatMessage({ id: 'metrics.grafana.not.config' })}</span>}
>
<Button
type="primary"
Expand All @@ -33,7 +34,7 @@ const Metrics: React.FC = () => {
});
}}
>
现在配置
{formatMessage({ id: 'metrics.grafana.config' })}
</Button>
</Empty>
)}
Expand Down
1 change: 1 addition & 0 deletions src/pages/Metrics/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { default } from './Metrics';

5 changes: 5 additions & 0 deletions src/pages/Metrics/locales/en-US.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
'metrics.monitor': 'Monitor',
'metrics.grafana.not.config': 'You have not configured Grafana',
'metrics.grafana.config': 'Configure Now',
};
5 changes: 5 additions & 0 deletions src/pages/Metrics/locales/zh-CN.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
'metrics.monitor': '监控',
'metrics.grafana.not.config': '您还未配置 Grafana',
'metrics.grafana.config': '现在配置',
};

0 comments on commit a289aba

Please sign in to comment.