Skip to content

Commit 49ee9b5

Browse files
committed
mod: update i18n
1 parent 589736b commit 49ee9b5

File tree

75 files changed

+158
-180
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+158
-180
lines changed

.npmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
registry=https://registry.npm.taobao.org
1+
# registry=https://registry.npm.taobao.org

app/components/CSVPreviewLink/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Button, Popover, Table } from 'antd';
22
import { } from 'antd/lib/button';
33
import React, { useState } from 'react';
4-
import { useI18n } from '@app/context';
4+
import { useI18n } from '@vesoft-inc/i18n';
55
import { v4 as uuidv4 } from 'uuid';
66
import cls from 'classnames';
77
import styles from './index.module.less';

app/components/ErrorBoundary/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import errorImg from '@app/static/images/errorBoundary.png';
3-
import { I18nContext } from '@app/context';
3+
import { I18nContext } from '@vesoft-inc/i18n';
44
import { CopyToClipboard } from 'react-copy-to-clipboard';
55
import { Button, message } from 'antd';
66
import { withRouter, RouteComponentProps } from 'react-router-dom';

app/components/GQLCodeMirror/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Collapse } from 'antd';
22
import React from 'react';
3-
import { useI18n } from '@app/context';
3+
import { useI18n } from '@vesoft-inc/i18n';
44

55
import CodeMirror from '@app/components/CodeMirror';
66

app/config/rules.ts

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
import { MAX_COMMENT_BYTES, NAME_REGEX, POSITIVE_INTEGER_REGEX } from '@app/utils/constant';
22
import { getByteLength } from '@app/utils/function';
3-
import intl from 'react-intl-universal';
43

5-
export const hostRulesFn = () => [
4+
export const hostRulesFn = (intl) => [
65
{
76
required: true,
87
message: intl.get('formRules.hostRequired'),
98
},
109
];
1110

12-
export const usernameRulesFn = () => [
11+
export const usernameRulesFn = (intl) => [
1312
{
1413
required: true,
1514
message: intl.get('formRules.usernameRequired'),
1615
},
1716
];
1817

19-
export const passwordRulesFn = () => [
18+
export const passwordRulesFn = (intl) => [
2019
{
2120
required: true,
2221
message: intl.get('formRules.passwordRequired'),
2322
},
2423
];
2524

26-
export const nameRulesFn = () => {
25+
export const nameRulesFn = (intl) => {
2726
const version = sessionStorage.getItem('nebulaVersion');
2827
const nameRequired = [
2928
{
@@ -40,14 +39,14 @@ export const nameRulesFn = () => {
4039
return version?.startsWith('v2') ? [...nameRequired, ...nameValidate] : nameRequired;
4140
};
4241

43-
export const numberRulesFn = () => [
42+
export const numberRulesFn = (intl) => [
4443
{
4544
pattern: POSITIVE_INTEGER_REGEX,
4645
message: intl.get('formRules.numberRequired'),
4746
},
4847
];
4948

50-
export const replicaRulesFn = (activeMachineNum) => [
49+
export const replicaRulesFn = (activeMachineNum, intl) => [
5150
{
5251
pattern: POSITIVE_INTEGER_REGEX,
5352
message: intl.get('formRules.numberRequired'),
@@ -64,7 +63,7 @@ export const replicaRulesFn = (activeMachineNum) => [
6463
},
6564
];
6665

67-
export const stringByteRulesFn = () => [
66+
export const stringByteRulesFn = (intl) => [
6867
{ validator: (_, value) => {
6968
const byteLength = getByteLength(value);
7069
if (byteLength <= MAX_COMMENT_BYTES) {

app/context/I18nContext.tsx

-50
This file was deleted.

app/context/index.ts

-5
This file was deleted.

app/index.tsx

+5-7
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import dayjs from 'dayjs';
88
import duration from 'dayjs/plugin/duration';
99
import Cookie from 'js-cookie';
1010
import { trackPageView } from '@app/utils/stat';
11-
import { I18nProvider, useI18n } from '@app/context';
11+
import { I18nProvider, getI18n } from '@vesoft-inc/i18n';
12+
import { INTL_LOCALES } from '@app/config/constants';
1213
import { useStore } from '@app/stores';
1314
import AuthorizedRoute from './AuthorizedRoute';
1415
import rootStore, { StoreProvider } from './stores';
@@ -22,7 +23,8 @@ message.config({
2223
maxCount: 1,
2324
});
2425
const defaultLanguage = Cookie.get('lang') || document.documentElement.getAttribute('lang');
25-
26+
const { initI18n } = getI18n();
27+
initI18n(defaultLanguage, INTL_LOCALES);
2628
const PageRoot = observer(() => {
2729
const { global: { version } } = useStore();
2830
useEffect(() => {
@@ -31,7 +33,7 @@ const PageRoot = observer(() => {
3133

3234
return (
3335
<StoreProvider value={rootStore}>
34-
<I18nProvider>
36+
<I18nProvider locales={INTL_LOCALES}>
3537
<Router>
3638
<App />
3739
</Router>
@@ -42,10 +44,6 @@ const PageRoot = observer(() => {
4244

4345
const App = () => {
4446
const history = useHistory();
45-
const { init18n } = useI18n();
46-
useEffect(() => {
47-
init18n(defaultLanguage);
48-
}, []);
4947
rootStore.global.history = history;
5048

5149
return (

app/pages/Console/CypherParameterBox.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Tooltip } from 'antd';
22
import React, { useState } from 'react';
3-
import { useI18n } from '@app/context';
3+
import { useI18n } from '@vesoft-inc/i18n';
44
import Icon from '@app/components/Icon';
55
import styles from './index.module.less';
66

app/pages/Console/ExportModal.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React from 'react';
33
import { observer } from 'mobx-react-lite';
44
import { useStore } from '@app/stores';
55

6-
import { useI18n } from '@app/context';
6+
import { useI18n } from '@vesoft-inc/i18n';
77
import styles from './index.module.less';
88
const Option = Select.Option;
99

app/pages/Console/FavoriteBtn.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { observer } from 'mobx-react-lite';
44
import Icon from '@app/components/Icon';
55
import { useStore } from '@app/stores';
66

7-
import { useI18n } from '@app/context';
7+
import { useI18n } from '@vesoft-inc/i18n';
88
import styles from './index.module.less';
99

1010

app/pages/Console/HistoryBtn.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Button, List, Modal, Tooltip } from 'antd';
22
import React, { useState } from 'react';
33
import Icon from '@app/components/Icon';
4-
import { useI18n } from '@app/context';
4+
import { useI18n } from '@vesoft-inc/i18n';
55
import styles from './index.module.less';
66

77

app/pages/Console/OutputBox/ForceGraph/DisplayPanel/ExpandForm/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Tabs } from 'antd';
22
import React, { useEffect, useState } from 'react';
33
import { LinkObject, NodeObject } from '@vesoft-inc/force-graph';
4-
import { useI18n } from '@app/context';
4+
import { useI18n } from '@vesoft-inc/i18n';
55
import ExpandItem from '../ExpandItem';
66
import styles from './index.module.less';
77

app/pages/Console/OutputBox/ForceGraph/DisplayPanel/ExpandItem/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React, { useState } from 'react';
33
import Icon from '@app/components/Icon';
44
import { convertBigNumberToString, removeNullCharacters } from '@app/utils/function';
55
import cls from 'classnames';
6-
import { useI18n } from '@app/context';
6+
import { useI18n } from '@vesoft-inc/i18n';
77
import styles from './index.module.less';
88

99
interface IProps {

app/pages/Console/OutputBox/ForceGraph/Menu/ColorChangeBtn/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { observer } from 'mobx-react-lite';
33
import MenuButton from '@app/components/Button';
44
import { uniq } from 'lodash';
55
import { GraphStore } from '@app/stores/graph';
6-
import { useI18n } from '@app/context';
6+
import { useI18n } from '@vesoft-inc/i18n';
77
import NodeStyleSetBtn from '../NodeStyleSetBtn';
88

99
interface IProps {

app/pages/Console/OutputBox/ForceGraph/Menu/NodeStyleSetBtn/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useState } from 'react';
22
import { Popover, Tabs } from 'antd';
33
import ColorPicker from '@app/components/ColorPicker';
44

5-
import { useI18n } from '@app/context';
5+
import { useI18n } from '@vesoft-inc/i18n';
66
import styles from './index.module.less';
77

88
interface IProps {

app/pages/Console/OutputBox/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Icon from '@app/components/Icon';
99
import { parseSubGraph } from '@app/utils/parseData';
1010
import cls from 'classnames';
1111
import { GraphStore } from '@app/stores/graph';
12-
import { useI18n } from '@app/context';
12+
import { useI18n } from '@vesoft-inc/i18n';
1313
import Graphviz from './Graphviz';
1414
import ForceGraph from './ForceGraph';
1515

app/pages/Console/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Icon from '@app/components/Icon';
88
import CodeMirror from '@app/components/CodeMirror';
99
import { maxLineNum } from '@app/config/nebulaQL';
1010
import classnames from 'classnames';
11-
import { useI18n } from '@app/context';
11+
import { useI18n } from '@vesoft-inc/i18n';
1212
import OutputBox from './OutputBox';
1313
import HistoryBtn from './HistoryBtn';
1414
import FavoriteBtn from './FavoriteBtn';

app/pages/Import/FileUpload/FileList.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import CSVPreviewLink from '@app/components/CSVPreviewLink';
55
import { getFileSize } from '@app/utils/file';
66
import cls from 'classnames';
77
import { StudioFile } from '@app/interfaces/import';
8-
import { useI18n } from '@app/context';
8+
import { useI18n } from '@vesoft-inc/i18n';
99
import styles from './index.module.less';
1010
interface IProps {
1111
fileList: any[];

app/pages/Import/FileUpload/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { trackPageView } from '@app/utils/stat';
55
import { debounce } from 'lodash';
66
import { message } from 'antd';
77
import { StudioFile } from '@app/interfaces/import';
8-
import { useI18n } from '@app/context';
8+
import { useI18n } from '@vesoft-inc/i18n';
99
import FileList from './FileList';
1010

1111
const FileUpload = () => {

app/pages/Import/TaskCreate/FileSelect/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { observer } from 'mobx-react-lite';
44
import { useStore } from '@app/stores';
55
import { v4 as uuidv4 } from 'uuid';
66
import Icon from '@app/components/Icon';
7-
import { useI18n } from '@app/context';
7+
import { useI18n } from '@vesoft-inc/i18n';
88
import styles from './index.module.less';
99

1010
const Option = Select.Option;

app/pages/Import/TaskCreate/PasswordInputModal/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useI18n } from '@app/context';
1+
import { useI18n } from '@vesoft-inc/i18n';
22
import { Button, Input, Modal } from 'antd';
33
import React, { useState } from 'react';
44

app/pages/Import/TaskCreate/SchemaConfig/EdgeConfig/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { observer } from 'mobx-react-lite';
55
import { useStore } from '@app/stores';
66
import CSVPreviewLink from '@app/components/CSVPreviewLink';
77
import classNames from 'classnames';
8-
import { useI18n } from '@app/context';
8+
import { useI18n } from '@vesoft-inc/i18n';
99
import styles from '../index.module.less';
1010

1111
const Option = Select.Option;

app/pages/Import/TaskCreate/SchemaConfig/TagConfig/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { observer } from 'mobx-react-lite';
55
import { useStore } from '@app/stores';
66
import CSVPreviewLink from '@app/components/CSVPreviewLink';
77
import classNames from 'classnames';
8-
import { useI18n } from '@app/context';
8+
import { useI18n } from '@vesoft-inc/i18n';
99
import styles from '../index.module.less';
1010

1111
const Option = Select.Option;

app/pages/Import/TaskCreate/SchemaConfig/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { observer } from 'mobx-react-lite';
55
import { useStore } from '@app/stores';
66
import CSVPreviewLink from '@app/components/CSVPreviewLink';
77
import Icon from '@app/components/Icon';
8-
import { useI18n } from '@app/context';
8+
import { useI18n } from '@vesoft-inc/i18n';
99
import TagConfig from './TagConfig';
1010
import EdgeConfig from './EdgeConfig';
1111
const { Panel } = Collapse;

app/pages/Import/TaskCreate/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { trackPageView } from '@app/utils/stat';
77
import cls from 'classnames';
88
import { useHistory } from 'react-router-dom';
99
import { POSITIVE_INTEGER_REGEX } from '@app/utils/constant';
10-
import { useI18n } from '@app/context';
10+
import { useI18n } from '@vesoft-inc/i18n';
1111
import styles from './index.module.less';
1212
import PasswordInputModal from './PasswordInputModal';
1313
import SchemaConfig from './SchemaConfig';

app/pages/Import/TaskList/TaskItem/LogModal/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Icon from '@app/components/Icon';
44
import { useStore } from '@app/stores';
55
import { ITaskStatus } from '@app/interfaces/import';
66
import classnames from 'classnames';
7-
import { useI18n } from '@app/context';
7+
import { useI18n } from '@vesoft-inc/i18n';
88
import styles from './index.module.less';
99

1010
interface ILogDimension {

app/pages/Import/TaskList/TaskItem/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import dayjs from 'dayjs';
66
import { floor } from 'lodash';
77
import { getFileSize } from '@app/utils/file';
88
import Icon from '@app/components/Icon';
9-
import { useI18n } from '@app/context';
9+
import { useI18n } from '@vesoft-inc/i18n';
1010
import styles from './index.module.less';
1111
interface IProps {
1212
data: ITaskItem;

app/pages/Import/TaskList/TemplateModal/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { readFileContent } from '@app/utils/file';
88
import yaml from 'js-yaml';
99
import json2yaml from 'json2yaml';
1010
import { exampleJson } from '@app/utils/import';
11-
import { useI18n } from '@app/context';
11+
import { useI18n } from '@vesoft-inc/i18n';
1212
import styles from './index.module.less';
1313
const { Dragger } = Upload;
1414
const { TextArea } = Input;

app/pages/Import/TaskList/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Icon from '@app/components/Icon';
66
import { useStore } from '@app/stores';
77
import { trackPageView } from '@app/utils/stat';
88
import { ITaskStatus } from '@app/interfaces/import';
9-
import { useI18n } from '@app/context';
9+
import { useI18n } from '@vesoft-inc/i18n';
1010
import LogModal from './TaskItem/LogModal';
1111
import TemplateModal from './TemplateModal';
1212

app/pages/Import/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React, { useEffect, useState } from 'react';
33
import { Route, useHistory, useLocation } from 'react-router-dom';
44
import { trackPageView } from '@app/utils/stat';
55
import cls from 'classnames';
6-
import { useI18n } from '@app/context';
6+
import { useI18n } from '@vesoft-inc/i18n';
77
import FileUpload from './FileUpload';
88
import styles from './index.module.less';
99
import TaskList from './TaskList';

0 commit comments

Comments
 (0)