Skip to content

Commit

Permalink
feat: gi-assets-advance 国际化
Browse files Browse the repository at this point in the history
  • Loading branch information
yangzy0603 committed Jun 27, 2023
1 parent 238bc0a commit a82c32c
Show file tree
Hide file tree
Showing 96 changed files with 2,416 additions and 587 deletions.
94 changes: 94 additions & 0 deletions packages/gi-assets-advance/.must.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
// more config: http://gitlab.alibaba-inc.com/parrot/parrot-tool-must/blob/master/doc/config.md
const name = 'advance';
module.exports = {
extract: {
name,
sourcePath: 'src',
fileType: 'ts',
prettier: true,
exclude: (path)=>{
return path.includes('/pages/') ; //
},
macro: {
path: 'src/i18n',
method: '$i18n.get({id:"$key$",dm:"$defaultMessage$"})',
import: 'import $i18n from "src/i18n"',
keySplitter: '.',
placeholder: variable => {
return `{${variable}}`;
},
implement: `import locale from '@aligov/global-locale';
import stringFormat from '@aligov/global-string-format';
import strings from './strings';
let language; // Current language
let intl; // Instance of intl-universal. Create by provideIntl
function update() {
const { lang } = locale.getLocale();
language = lang;
intl = stringFormat.init(lang, strings, { name: '${name}' });
}
function change(langTag) {
locale.setLang(langTag);
update();
}
function get(id, variable = {}) {
if (!intl) update();
if (typeof id === 'string') {
return stringFormat.format(
{
id: id,
},
variable,
{ name: '${name}' }
);
} else if (typeof id === 'object' && id.dm) {
id.defaultMessage = id.dm;
}
return stringFormat.format(
{
id: id.id,
defaultString: id.dm,
},
variable,
{ name: '${name}' }
);
}
export default {
get,
update,
change,
language,
};
`,
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: false,
sourceLang: 'zh-CN',
},
};
11 changes: 7 additions & 4 deletions packages/gi-assets-advance/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
"postpublish": "tnpm sync @antv/gi-assets-advance"
},
"dependencies": {
"@aligov/global-locale": "^1.0.5",
"@aligov/global-string-format": "^1.0.7",
"@ant-design/icons": "^4.6.2",
"@antv/algorithm": "^0.1.26-beta.0",
"@antv/g2plot": "^2.4.4",
Expand All @@ -48,14 +50,14 @@
"lodash": "^4.17.21",
"nanoid": "^4.0.0",
"query-string": "^7.1.1",
"react-draggable": "^4.4.5",
"react-force-graph-3d": "^1.21.10",
"react-json-view": "^1.21.3",
"react-spring": "9.3.2",
"react-transition-group": "^4.4.5",
"react-draggable": "^4.4.5",
"size-sensor": "^1.0.1",
"three": "^0.135.0",
"use-immer": "^0.6.0",
"size-sensor": "^1.0.1"
"use-immer": "^0.6.0"
},
"peerDependencies": {
"@antv/graphin": "^2.7.15",
Expand All @@ -65,5 +67,6 @@
},
"publishConfig": {
"access": "public"
}
},
"repository": "[email protected]:antvis/G6VP.git"
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { extra, IGIAC, useContext } from '@antv/gi-sdk';
import { message } from 'antd';
import * as React from 'react';
import $i18n from '../../i18n';

const { GIAComponent } = extra;
export interface AddSheetbarProps {
Expand Down Expand Up @@ -28,7 +29,12 @@ const AddSheetbar: React.FunctionComponent<AddSheetbarProps> = props => {
return;
}
if (!handleAddSheetbar) {
message.warn('请在默认画布中使用该功能,暂不支持其他画布的「添加页签」功能');
message.warn(
$i18n.get({
id: 'advance.components.AddSheetbar.Component.PleaseUseThisFunctionIn',
dm: '请在默认画布中使用该功能,暂不支持其他画布的「添加页签」功能',
}),
);
}
handleAddSheetbar &&
handleAddSheetbar({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { AssetInfo } from '@antv/gi-sdk';
import Component from './Component';
import registerMeta from './registerMeta';

/** index.md 中解析得到默认值,也可用户手动修改 */
/** index.md 中解析得到默认值,也可用户手动修改 */ import $i18n from '../../i18n';

const info: AssetInfo = {
id: 'AddSheetbar',
name: '新增页签',
desc: '新增页签',
name: $i18n.get({ id: 'advance.components.AddSheetbar.AddATab', dm: '新增页签' }),
desc: $i18n.get({ id: 'advance.components.AddSheetbar.AddATab', dm: '新增页签' }),
cover: 'http://xxxx.jpg',
category: 'system-interaction',
icon: 'icon-plus',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import { extra } from '@antv/gi-sdk';
import $i18n from '../../i18n';
const { deepClone, GIAC_METAS } = extra;

const metas = deepClone(GIAC_METAS);
metas.GIAC.properties.GIAC.properties.title.default = '将选中的节点与边添加到新画布中';
metas.GIAC.properties.GIAC.properties.title.default = $i18n.get({
id: 'advance.components.AddSheetbar.registerMeta.AddTheSelectedNodesAnd',
dm: '将选中的节点与边添加到新画布中',
});
metas.GIAC.properties.GIAC.properties.icon.default = 'icon-plus';
metas.GIAC.properties.GIAC.properties.isShowTitle.default = false;
metas.GIAC.properties.GIAC.properties.tooltipPlacement.default = 'right';

const registerMeta = () => {
return {
isRelayout: {
title: '是否重新布局',
title: $i18n.get({ id: 'advance.components.AddSheetbar.registerMeta.RelayoutOrNot', dm: '是否重新布局' }),
type: 'boolean',
'x-decorator': 'FormItem',
'x-component': 'Switch',
Expand Down
37 changes: 27 additions & 10 deletions packages/gi-assets-advance/src/components/AjustLayout/Component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Button, Collapse, Select } from 'antd';
import React from 'react';
import { useImmer } from 'use-immer';
import './index.less';
import $i18n from '../../i18n';

const { Panel } = Collapse;

Expand All @@ -22,7 +23,7 @@ export interface IGremlinQueryProps {
const LAYOUTS = [
{
value: 'grid',
label: '网格布局',
label: $i18n.get({ id: 'advance.components.AjustLayout.Component.GridLayout', dm: '网格布局' }),
options: {
type: 'grid',
rows: 4,
Expand All @@ -31,11 +32,11 @@ const LAYOUTS = [
},
{
value: 'circular',
label: '同心圆布局',
label: $i18n.get({ id: 'advance.components.AjustLayout.Component.ConcentricCircleLayout', dm: '同心圆布局' }),
},
{
value: 'dagre',
label: '层次布局',
label: $i18n.get({ id: 'advance.components.AjustLayout.Component.HierarchicalLayout', dm: '层次布局' }),
},
];

Expand Down Expand Up @@ -225,7 +226,13 @@ const AjustLayout: React.FC<IGremlinQueryProps> = ({ visible, onClose, serviceId
{layouts.map((item, index) => {
return (
<Panel
header={`布局${index}`}
header={$i18n.get(
{
id: 'advance.components.AjustLayout.Component.LayoutIndex',
dm: '布局{index}',
},
{ index: index },
)}
key={index}
className="site-collapse-custom-panel"
extra={
Expand All @@ -243,12 +250,17 @@ const AjustLayout: React.FC<IGremlinQueryProps> = ({ visible, onClose, serviceId
>
<div>
<div style={{ marginBottom: '6px' }} className="custom-item">
<div>选择节点:</div>
<div>
{$i18n.get({ id: 'advance.components.AjustLayout.Component.SelectANode', dm: '选择节点:' })}
</div>
<Select
mode="multiple"
allowClear
style={{ width: '316px' }}
placeholder="请选择节点"
placeholder={$i18n.get({
id: 'advance.components.AjustLayout.Component.SelectANode.1',
dm: '请选择节点',
})}
value={item.nodes.map(node => node.id)}
disabled={item.locked}
onChange={values => {
Expand Down Expand Up @@ -279,11 +291,16 @@ const AjustLayout: React.FC<IGremlinQueryProps> = ({ visible, onClose, serviceId
</Button>
</div>
<div style={{ marginBottom: '6px' }} className="custom-item">
<div>选择布局:</div>
<div>
{$i18n.get({ id: 'advance.components.AjustLayout.Component.SelectLayout', dm: '选择布局:' })}
</div>
<Select
allowClear
style={{ maxWidth: '247px' }}
placeholder="请选择布局"
placeholder={$i18n.get({
id: 'advance.components.AjustLayout.Component.PleaseSelectALayout',
dm: '请选择布局',
})}
value={item.type}
defaultValue={item.type}
onChange={val => {
Expand All @@ -308,11 +325,11 @@ const AjustLayout: React.FC<IGremlinQueryProps> = ({ visible, onClose, serviceId
</Collapse>

<Button type="dashed" style={{ width: '100%' }} onClick={handlePlus}>
添加布局
{$i18n.get({ id: 'advance.components.AjustLayout.Component.AddLayout', dm: '添加布局' })}
</Button>

<Button type="primary" style={{ width: '100%', marginTop: '12px' }} onClick={handleClick}>
开始调整
{$i18n.get({ id: 'advance.components.AjustLayout.Component.StartAdjustment', dm: '开始调整' })}
</Button>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import Component from './Component';
import registerMeta from './registerMeta';

/** index.md 中解析得到默认值,也可用户手动修改 */
/** index.md 中解析得到默认值,也可用户手动修改 */ import $i18n from '../../i18n';
const info = {
id: 'AjustLayout',
name: '布局调整',
name: $i18n.get({ id: 'advance.components.AjustLayout.LayoutAdjustment', dm: '布局调整' }),
category: 'layout-analysis',
desc: '布局调整',
desc: $i18n.get({ id: 'advance.components.AjustLayout.LayoutAdjustment', dm: '布局调整' }),
cover: 'http://xxxx.jpg',
type: 'GIAC_CONTENT',
docs: 'https://www.yuque.com/antv/gi/kehgv931z5v1fmg8',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { extra } from '@antv/gi-sdk';
import $i18n from '../../i18n';

const { GIAC_CONTENT_METAS, deepClone } = extra;

const metas = deepClone(GIAC_CONTENT_METAS);
metas.GIAC_CONTENT.properties.GIAC_CONTENT.properties.title.default = '子图布局';
metas.GIAC_CONTENT.properties.GIAC_CONTENT.properties.title.default = $i18n.get({
id: 'advance.components.AjustLayout.registerMeta.SubgraphLayout',
dm: '子图布局',
});
metas.GIAC_CONTENT.properties.GIAC_CONTENT.properties.icon.default = 'icon-branches';

export default () => {
Expand Down
Loading

0 comments on commit a82c32c

Please sign in to comment.