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

feat:站点资产国际化 #385

Merged
merged 28 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
9ed6725
feat: 基于 react-intl 的资产国际化
Jun 21, 2023
b708bce
feat: merge master & fix conflicts
Jun 21, 2023
201dade
Revert "feat: merge master & fix conflicts"
Jun 21, 2023
a4ab454
feat: merge master
Jun 21, 2023
4148b6a
fix: 修复 locales 参数丢失
Jun 21, 2023
9e47d79
fix: hard code 当前语言环境(测试用)
Jun 21, 2023
686c6e9
feat: 单独提供当前语言环境
Jun 21, 2023
5e93188
feat: info & registerMeta 多语言方案
Jun 25, 2023
cd55448
feat: 统一命名范式
Jun 25, 2023
4244395
feat: 调整示例 locale 文件组织方式
Jun 26, 2023
e827613
feat: 修改 locales 为可选项
Jun 26, 2023
b5286b3
feat: locales for gi-site
Yanyan-Wang Jun 26, 2023
62dac7f
chore: update button style for locale change
Yanyan-Wang Jun 26, 2023
989b8e1
Merge pull request #389 from antvis/site-locale
pomelo-nwu Jun 26, 2023
6c81055
feat: update
pomelo-nwu Jun 26, 2023
f6fbe5a
feat: 资产国际化更改为 must 方案 & basic 包国际化完成
Jun 27, 2023
726c732
feat: galaxybase 包国际化
Jun 27, 2023
7fd2315
feat: graphscope 包国际化
Jun 27, 2023
2ba5760
feat: HugeGraph 国际化
Jun 27, 2023
4167b7d
feat: janusgraph 国际化
Jun 27, 2023
d65042c
feat: neo4j 国际化
Jun 27, 2023
2d22a83
feat: gi-assets-scene 国际化
Jun 27, 2023
642bde9
feat: gi-assets-tugraph 国际化
Jun 27, 2023
d9ea1ab
feat: gi-common-components 国际化
Jun 27, 2023
238bc0a
feat: gi-assets-tugraph-analytics 国际化
Jun 27, 2023
a82c32c
feat: gi-assets-advance 国际化
Jun 27, 2023
b5da979
feat: gi-sdk 国际化
Jun 27, 2023
d590d78
Merge branch 'master' into feat/locale
pomelo-nwu Jun 27, 2023
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ G6VP 取名意为 AntV G6 Visualization Platform,曾用名 `AntV/GraphInsight`

![image](https://github.com/antvis/G6VP/assets/10703060/85667759-70b2-4166-8181-47cb9e9fa3a3)

### 1.2 创建工作薄
### 1.2 创建工作簿

有了数据,我们便可以创建一个分析画布,创建画布的时候,我们可以选择不同的模版,模版来自资产包,也可以来自用户手动保存或者从资产清单选购的模版。

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ const FilterPanel: React.FunctionComponent<FilterPanelProps> = props => {
node: { propertyName: string; entropy: number }[];
edge: { propertyName: string; entropy: number }[];
}>({ node: [], edge: [] });
const { source, updateContext, updateHistory, transform, schemaData, graph, propertyGraphData, useIntl } = useContext();
const { source, updateContext, updateHistory, transform, schemaData, graph, propertyGraphData, useIntl } =
useContext();
const { formatMessage } = useIntl();

useEffect(() => {
Expand Down Expand Up @@ -338,7 +339,7 @@ const FilterPanel: React.FunctionComponent<FilterPanelProps> = props => {
onClick={() => addFilter()}
icon={<PlusOutlined />}
>
{formatMessage({id: 'FilterPanel.addfilter'})}
{formatMessage({ id: 'FilterPanel.addfilter' })}
</Button>
{enableInfoDetect ? (
<Button style={{ width: '100px', marginLeft: '4px' }} onClick={handleClickRecommend}>
Expand Down
2 changes: 1 addition & 1 deletion packages/gi-httpservice/app/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default (app: Application) => {
// router.post('/dataset/delete', controller.graphinsight.removeProjectById);
// router.post('/dataset/update', controller.graphinsight.updateProjectById);

// project 工作薄
// project 工作簿
router.post('/project/create', controller.graphinsight.createProject);
router.post('/project/list', controller.graphinsight.listProject);
router.post('/project/delete', controller.graphinsight.removeProjectById);
Expand Down
1 change: 1 addition & 0 deletions packages/gi-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"postpublish": "tnpm sync @antv/gi-sdk"
},
"dependencies": {
"@aligov/global-locale": "^1.0.5",
"@antv/gi-common-components": "workspace:*",
"@ant-design/icons": "^4.7.0",
"immer": "^9.0.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/gi-sdk/src/GISDK.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ const GISDK = (props: Props) => {
}, [data]);

return (
<IntlProvider locale={language} messages={localeMessages}>
<IntlProvider locale={language as string} messages={localeMessages}>
{/* @ts-ignore */}
<GraphInsightContext.Provider value={ContextValue}>
<GICC_LAYOUT_COMPONENT {...GICC_LAYOUT_PROPS}>
Expand Down
4 changes: 2 additions & 2 deletions packages/gi-sdk/src/typing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ export interface Props {
/** 注册的全局数据服务 */
services: GIService[];
/** 国际化语言配置 */
locales: {
locales?: {
language: LANGUAGE_KEY_NAME;
[k: string]: string;
}
};
/**
* style
*/
Expand Down
42 changes: 42 additions & 0 deletions packages/gi-site/.must.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// more config: http://gitlab.alibaba-inc.com/parrot/parrot-tool-must/blob/master/doc/config.md
module.exports = {
extract: {
name: 'gi-site',
sourcePath: 'src',
fileType: 'ts',
prettier: true,
macro: {
path: 'src/i18n',
method: '$i18n.get({id:"$key$",dm:"$defaultMessage$"})',
import: 'import $i18n from "src/i18n"',
keySplitter: '.',
placeholder: variable => {
return `{${variable}}`;
},
dependencies: ['@aligov/global-locale', '@aligov/global-string-format'],
},
babel: {
allowImportExportEverywhere: true,
decoratorsBeforeExport: true,
plugins: [
'asyncGenerators',
'classProperties',
'decorators-legacy',
'doExpressions',
'exportExtensions',
'exportDefaultFrom',
'typescript',
'functionSent',
'functionBind',
'jsx',
'objectRestSpread',
'dynamicImport',
'numericSeparator',
'optionalChaining',
'optionalCatchBinding',
],
},
isNeedUploadCopyToMedusa: true,
sourceLang: 'zh-CN',
},
};
5 changes: 3 additions & 2 deletions packages/gi-site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
"build": "node --experimental-json-modules scripts/pre-build.mjs && NODE_OPTIONS=--max_old_space_size=4096 umi build",
"build:docker": "node scripts/link.mjs && cd ../../ && npm run build:all:umd && cd packages/gi-site/ && BUILD_MODE=docker node scripts/pre-build.mjs && node scripts/copy-assets.mjs && BUILD_MODE=docker NODE_OPTIONS=--max_old_space_size=4096 umi build",
"deploy": "node ./scripts/deploy.js",
"start": "node --experimental-json-modules scripts/link.mjs && node scripts/pre-build.mjs && cross-env NODE_OPTIONS=--max_old_space_size=4096 cross-env PORT=8000 umi dev",
"start": "node --experimental-json-modules scripts/link.mjs && node scripts/pre-build.mjs && cross-env NODE_OPTIONS=--openssl-legacy-provider --max_old_space_size=4096 cross-env PORT=8000 umi dev",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pomelo-nwu @Yanyan-Wang

--openssl-legacy-provider是Node 17之后的flag,node 16下运行报错:

image

去掉后可以跑起来。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"link": "node scripts/link.mjs",
"unlink": "cross-env UNLINK=true node scripts/link.mjs",
"eject": "cross-env EJECT=true node scripts/link.mjs"

},
"dependencies": {
"@aligov/global-locale": "^1.0.5",
"@aligov/global-string-format": "^1.0.7",
"@ant-design/charts": "^1.0.21",
"@ant-design/compatible": "^1.0.2",
"@ant-design/icons": "^4.0.6",
Expand Down
38 changes: 32 additions & 6 deletions packages/gi-site/src/components/AntGroupLogin/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@
import { AlipayCircleOutlined } from '@ant-design/icons';
import { Button, Popover } from 'antd';
import React from 'react';
import $i18n from '../../i18n';
const Notification = () => {
const content = (
<div>
<p>蚂蚁集团,阿里集团的同学,可以访问 G6VP 域内站点啦 🎉</p>
<p>✅ 支持域内用户,数据存放在云端,可根据权限进行查看与分享</p>
<p>✅ 支持域内用户,根据权限,新增/查看/使用 业务沉淀的图分析资产</p>
<p>✅ 支持域内用户,使用 ODPS 数据源,支持多款图计算引擎</p>
<p>
{$i18n.get({
id: 'gi-site.components.AntGroupLogin.AntGroupAlibabaGroupS',
dm: '蚂蚁集团,阿里集团的同学,可以访问 G6VP 域内站点啦 🎉',
})}
</p>
<p>
{$i18n.get({
id: 'gi-site.components.AntGroupLogin.SupportsUsersInTheDomain',
dm: '✅ 支持域内用户,数据存放在云端,可根据权限进行查看与分享',
})}
</p>
<p>
{$i18n.get({
id: 'gi-site.components.AntGroupLogin.SupportsUsersInTheDomain.1',
dm: '✅ 支持域内用户,根据权限,新增/查看/使用 业务沉淀的图分析资产',
})}
</p>
<p>
{$i18n.get({
id: 'gi-site.components.AntGroupLogin.SupportsDomainUsersOdpsData',
dm: '✅ 支持域内用户,使用 ODPS 数据源,支持多款图计算引擎',
})}
</p>
</div>
);

Expand All @@ -17,9 +38,14 @@ const Notification = () => {

return (
<>
<Popover title="内网登陆" content={content} placement="bottom" trigger="hover">
<Popover
title={$i18n.get({ id: 'gi-site.components.AntGroupLogin.IntranetLogin', dm: '内网登陆' })}
content={content}
placement="bottom"
trigger="hover"
>
<Button icon={<AlipayCircleOutlined style={{ color: 'var(--primary-color)' }} />} onClick={handleClick}>
内网登陆
{$i18n.get({ id: 'gi-site.components.AntGroupLogin.IntranetLogin', dm: '内网登陆' })}
</Button>
</Popover>
</>
Expand Down
8 changes: 5 additions & 3 deletions packages/gi-site/src/components/AssetsCenter/AllAssets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import React from 'react';
import { queryAssetList } from '../../services/assets';
import AssetCard from './Card';
import ComponentsPanel from './Components';
import $i18n from '../../i18n';
import './index.less';

const { TabPane } = Tabs;
const { Paragraph } = Typography;

Expand All @@ -16,17 +18,17 @@ interface AssetsCenterProps {
}
const options = [
{
name: '组件',
name: $i18n.get({ id: 'gi-site.components.AssetsCenter.AllAssets.Component', dm: '组件' }),
key: 'components',
icon: <AppstoreOutlined />,
},
{
name: '元素',
name: $i18n.get({ id: 'gi-site.components.AssetsCenter.AllAssets.Element', dm: '元素' }),
key: 'elements',
icon: <BgColorsOutlined />,
},
{
name: '布局',
name: $i18n.get({ id: 'gi-site.components.AssetsCenter.AllAssets.Layout', dm: '布局' }),
key: 'layouts',
icon: <BranchesOutlined />,
},
Expand Down
27 changes: 14 additions & 13 deletions packages/gi-site/src/components/AssetsCenter/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,72 +10,73 @@ import {
SelectOutlined,
SlackOutlined,
} from '@ant-design/icons';
import $i18n from '../../i18n';

export const CategroyOptions = {
'container-components': {
name: '容器组件',
name: $i18n.get({ id: 'gi-site.components.AssetsCenter.constants.ContainerComponents', dm: '容器组件' }),
icon: <InsertRowBelowOutlined />,
order: 1,
},
'canvas-interaction': {
name: '画布交互',
name: $i18n.get({ id: 'gi-site.components.AssetsCenter.constants.CanvasInteraction', dm: '画布交互' }),
icon: <SelectOutlined />,
order: 2,
},
'elements-interaction': {
name: '元素交互',
name: $i18n.get({ id: 'gi-site.components.AssetsCenter.constants.ElementInteraction', dm: '元素交互' }),
icon: <PieChartOutlined />,
order: 3,
},
'node-interaction': {
name: '节点交互',
name: $i18n.get({ id: 'gi-site.components.AssetsCenter.constants.NodeInteraction', dm: '节点交互' }),
icon: <PieChartOutlined />,
order: 3,
},
'system-interaction': {
name: '系统交互',
name: $i18n.get({ id: 'gi-site.components.AssetsCenter.constants.SystemInteraction', dm: '系统交互' }),
icon: <SlackOutlined />,
order: 4,
},
'styling-analysis': {
name: '样式分析',
name: $i18n.get({ id: 'gi-site.components.AssetsCenter.constants.StyleAnalysis', dm: '样式分析' }),
icon: <BgColorsOutlined />,
order: 5,
},
'data-analysis': {
name: '数据分析',
name: $i18n.get({ id: 'gi-site.components.AssetsCenter.constants.DataAnalysis', dm: '数据分析' }),
icon: <BarChartOutlined />,
order: 6,
},

'layout-analysis': {
name: '布局分析',
name: $i18n.get({ id: 'gi-site.components.AssetsCenter.constants.LayoutAnalysis', dm: '布局分析' }),
icon: <BranchesOutlined />,
order: 7,
},
'data-query': {
name: '数据查询',
name: $i18n.get({ id: 'gi-site.components.AssetsCenter.constants.DataQuery', dm: '数据查询' }),
icon: <ConsoleSqlOutlined />,
order: 8,
},
'algorithm-analysis': {
name: '算法分析',
name: $i18n.get({ id: 'gi-site.components.AssetsCenter.constants.AlgorithmAnalysis', dm: '算法分析' }),
icon: <PieChartOutlined />,
order: 9,
},
'scene-analysis': {
name: '场景分析',
name: $i18n.get({ id: 'gi-site.components.AssetsCenter.constants.ScenarioAnalysis', dm: '场景分析' }),
icon: <PieChartOutlined />,
order: 10,
},
workbook: {
name: '工作簿',
name: $i18n.get({ id: 'gi-site.components.AssetsCenter.constants.Workbook', dm: '工作簿' }),
icon: <CarryOutOutlined />,
order: 11,
},
};
export const otherCategory = {
name: '未分类',
name: $i18n.get({ id: 'gi-site.components.AssetsCenter.constants.Uncategorized', dm: '未分类' }),
icon: <QuestionCircleOutlined />,
order: 12,
};
Expand Down
Loading