Skip to content

Commit

Permalink
feat: 资产国际化更改为 must 方案 & basic 包国际化完成
Browse files Browse the repository at this point in the history
  • Loading branch information
yangzy0603 committed Jun 27, 2023
1 parent 6c81055 commit f6fbe5a
Show file tree
Hide file tree
Showing 169 changed files with 3,146 additions and 1,117 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,5 @@ packages/gi-site/src/services/inject.ts
scripts/publish_yuyan.mjs
packages/gi-httpservice-xxx
release/gi-httpservice

**/unprocessed-code.ts.txt
93 changes: 93 additions & 0 deletions packages/gi-assets-basic/.must.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// more config: http://gitlab.alibaba-inc.com/parrot/parrot-tool-must/blob/master/doc/config.md
module.exports = {
extract: {
name: 'basic',
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: 'basic' });
}
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: 'basic' }
);
} else if (typeof id === 'object' && id.dm) {
id.defaultMessage = id.dm;
}
return stringFormat.format(
{
id: id.id,
defaultString: id.dm,
},
variable,
{ name: 'basic' }
);
}
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',
},
};
2 changes: 2 additions & 0 deletions packages/gi-assets-basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
"postpublish": "tnpm sync @antv/gi-assets-basic"
},
"dependencies": {
"@aligov/global-locale": "^1.0.5",
"@aligov/global-string-format": "^1.0.7",
"@ant-design/icons": "latest",
"@antv/algorithm": "^0.1.26-beta.0",
"@antv/g2plot": "^2.4.20",
Expand Down
23 changes: 18 additions & 5 deletions packages/gi-assets-basic/src/components/ActivateRelations/info.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
import { AssetInfo } from '@antv/gi-sdk';
import $i18n from '../../i18n';
const info: AssetInfo = {
id: 'ActivateRelations',
name: '元素高亮',
desc: '通过交互,激活相关联的节点与边',
name: $i18n.get({ id: 'basic.components.ActivateRelations.info.ElementHighlighting', dm: '元素高亮' }),
desc: $i18n.get({
id: 'basic.components.ActivateRelations.info.ActivateAssociatedNodesAndEdges',
dm: '通过交互,激活相关联的节点与边',
}),
icon: 'icon-canvas-setting',
cover: 'http://xxxx.jpg',
category: 'elements-interaction',
type: 'AUTO',
docs: 'https://www.yuque.com/antv/gi/rqq14h0071psf9ks',
features: [
'支持点击节点,高亮展示关联节点和边',
'支持配置节点或者边,悬停高亮效果',
'支持配置节点「上游N度」「下游M度」的高亮效果',
$i18n.get({
id: 'basic.components.ActivateRelations.info.YouCanClickNodesTo',
dm: '支持点击节点,高亮展示关联节点和边',
}),
$i18n.get({
id: 'basic.components.ActivateRelations.info.YouCanConfigureNodesOr',
dm: '支持配置节点或者边,悬停高亮效果',
}),
$i18n.get({
id: 'basic.components.ActivateRelations.info.YouCanConfigureTheHighlighting',
dm: '支持配置节点「上游N度」「下游M度」的高亮效果',
}),
],
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,48 +1,49 @@
import $i18n from '../../i18n';
const registerMeta = context => {
return {
/** 分类信息 */
enableNodeHover: {
title: '节点悬停',
title: $i18n.get({ id: 'basic.components.ActivateRelations.registerMeta.NodeHover', dm: '节点悬停' }),
'x-component': 'Switch',
'x-decorator': 'FormItem',
type: 'boolean',
default: true,
},
enableEdgeHover: {
title: '边悬停',
title: $i18n.get({ id: 'basic.components.ActivateRelations.registerMeta.EdgeHover', dm: '边悬停' }),
'x-component': 'Switch',
'x-decorator': 'FormItem',
type: 'boolean',
default: true,
},
enable: {
title: '启用关联',
title: $i18n.get({ id: 'basic.components.ActivateRelations.registerMeta.EnableAssociation', dm: '启用关联' }),
'x-component': 'Switch',
'x-decorator': 'FormItem',
type: 'boolean',
default: true,
},
trigger: {
title: '触发方式',
title: $i18n.get({ id: 'basic.components.ActivateRelations.registerMeta.TriggerMode', dm: '触发方式' }),
type: 'string',
'x-component': 'Select',
'x-decorator': 'FormItem',
'x-component-props': {
options: [
{
label: '鼠标点击',
label: $i18n.get({ id: 'basic.components.ActivateRelations.registerMeta.MouseClick', dm: '鼠标点击' }),
value: 'click',
},
{
label: '鼠标移入',
label: $i18n.get({ id: 'basic.components.ActivateRelations.registerMeta.MoveTheMouseIn', dm: '鼠标移入' }),
value: 'mouseenter',
},
],
},
default: 'click',
},
upstreamDegree: {
title: '上游度数',
title: $i18n.get({ id: 'basic.components.ActivateRelations.registerMeta.UpstreamDegree', dm: '上游度数' }),
type: 'number',
'x-component': 'NumberPicker',
'x-decorator': 'FormItem',
Expand All @@ -52,7 +53,7 @@ const registerMeta = context => {
},
},
downstreamDegree: {
title: '下游度数',
title: $i18n.get({ id: 'basic.components.ActivateRelations.registerMeta.DownstreamDegrees', dm: '下游度数' }),
type: 'number',
'x-component': 'NumberPicker',
'x-decorator': 'FormItem',
Expand All @@ -62,7 +63,10 @@ const registerMeta = context => {
},
},
multiSelectEnabled: {
title: '允许多选',
title: $i18n.get({
id: 'basic.components.ActivateRelations.registerMeta.MultipleSelectionsAllowed',
dm: '允许多选',
}),
type: 'string',
'x-component': 'Switch',
'x-decorator': 'FormItem',
Expand All @@ -72,7 +76,10 @@ const registerMeta = context => {
},
},
modifierKey: {
title: '多选组合键, 按下键盘输入组合键,支持Alt, Control, Shift, Meta',
title: $i18n.get({
id: 'basic.components.ActivateRelations.registerMeta.MultipleKeyCombinationsPressThe',
dm: '多选组合键, 按下键盘输入组合键,支持Alt, Control, Shift, Meta',
}),
type: 'string',
'x-component': 'ModifierPicker',
'x-decorator': 'FormItem',
Expand Down
23 changes: 16 additions & 7 deletions packages/gi-assets-basic/src/components/CanvasSetting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,30 @@ 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: 'CanvasSetting',
name: '画布设置',
desc: '设置画布的背景,缩放,移动等交互',
name: $i18n.get({ id: 'basic.components.CanvasSetting.CanvasSettings', dm: '画布设置' }),
desc: $i18n.get({
id: 'basic.components.CanvasSetting.SetTheBackgroundOfThe',
dm: '设置画布的背景,缩放,移动等交互',
}),
icon: 'icon-canvas-setting',
cover: 'http://xxxx.jpg',
category: 'canvas-interaction',
type: 'AUTO',
docs: 'https://www.yuque.com/antv/gi/aa34nmszaivikxi1',
features: [
'支持框选「画布」节点或者边',
'支持双击「画布」自动自适应居中',
'支持配置「画布」的背景色',
'支持配置「画布」的缩放,平移交互',
$i18n.get({ id: 'basic.components.CanvasSetting.SelectCanvasNodeOrEdge', dm: '支持框选「画布」节点或者边' }),
$i18n.get({
id: 'basic.components.CanvasSetting.SupportsAutomaticAdaptiveCenteringBy',
dm: '支持双击「画布」自动自适应居中',
}),
$i18n.get({ id: 'basic.components.CanvasSetting.YouCanConfigureTheBackground', dm: '支持配置「画布」的背景色' }),
$i18n.get({
id: 'basic.components.CanvasSetting.SupportsScalingAndTranslationInteraction',
dm: '支持配置「画布」的缩放,平移交互',
}),
],
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import $i18n from '../../i18n';
const registerMeta = context => {
const { services } = context;

return {
/** 分类信息 */

styleCanvas: {
title: '画布样式',
title: $i18n.get({ id: 'basic.components.CanvasSetting.registerMeta.CanvasStyle', dm: '画布样式' }),
type: 'object',
properties: {
backgroundColor: {
title: '背景颜色',
title: $i18n.get({ id: 'basic.components.CanvasSetting.registerMeta.BackgroundColor', dm: '背景颜色' }),
'x-component': 'ColorInput',
'x-decorator': 'FormItem',
type: 'string',
default: '#fff',
},
backgroundImage: {
title: '背景图片',
title: $i18n.get({ id: 'basic.components.CanvasSetting.registerMeta.BackgroundImage', dm: '背景图片' }),
type: 'string',
'x-component': 'Input',
'x-decorator': 'FormItem',
Expand All @@ -25,41 +26,41 @@ const registerMeta = context => {
},
},
dragCanvas: {
title: '拖拽画布',
title: $i18n.get({ id: 'basic.components.CanvasSetting.registerMeta.DragCanvas', dm: '拖拽画布' }),
type: 'object',
properties: {
disabled: {
title: '拖拽禁用',
title: $i18n.get({ id: 'basic.components.CanvasSetting.registerMeta.DragDisabled', dm: '拖拽禁用' }),
'x-component': 'Switch',
'x-decorator': 'FormItem',
type: 'boolean',
default: false,
},
direction: {
title: '拖拽方向',
title: $i18n.get({ id: 'basic.components.CanvasSetting.registerMeta.DragDirection', dm: '拖拽方向' }),
type: 'select',
'x-component': 'Select',
'x-decorator': 'FormItem',
'x-component-props': {
options: [
{
label: '自由',
label: $i18n.get({ id: 'basic.components.CanvasSetting.registerMeta.Freedom', dm: '自由' }),
value: 'both',
},
{
label: 'X方向',
label: $i18n.get({ id: 'basic.components.CanvasSetting.registerMeta.XDirection', dm: 'X方向' }),
value: 'x',
},
{
label: 'Y方向',
label: $i18n.get({ id: 'basic.components.CanvasSetting.registerMeta.YDirection', dm: 'Y方向' }),
value: 'y',
},
],
},
default: 'both',
},
enableOptimize: {
title: '拖拽优化',
title: $i18n.get({ id: 'basic.components.CanvasSetting.registerMeta.DragOptimization', dm: '拖拽优化' }),
'x-component': 'Switch',
'x-decorator': 'FormItem',
type: 'boolean',
Expand All @@ -68,18 +69,18 @@ const registerMeta = context => {
},
},
zoomCanvas: {
title: '缩放画布',
title: $i18n.get({ id: 'basic.components.CanvasSetting.registerMeta.ZoomCanvas', dm: '缩放画布' }),
type: 'object',
properties: {
disabled: {
title: '缩放禁用',
title: $i18n.get({ id: 'basic.components.CanvasSetting.registerMeta.ZoomDisabled', dm: '缩放禁用' }),
'x-component': 'Switch',
'x-decorator': 'FormItem',
type: 'boolean',
default: false,
},
enableOptimize: {
title: '缩放优化',
title: $i18n.get({ id: 'basic.components.CanvasSetting.registerMeta.ZoomOptimization', dm: '缩放优化' }),
type: 'boolean',
'x-component': 'Switch',
'x-decorator': 'FormItem',
Expand All @@ -88,14 +89,20 @@ const registerMeta = context => {
},
},
clearStatus: {
title: '点击画布,清空状态',
title: $i18n.get({
id: 'basic.components.CanvasSetting.registerMeta.ClickTheCanvasToClear',
dm: '点击画布,清空状态',
}),
'x-component': 'Switch',
'x-decorator': 'FormItem',
type: 'boolean',
default: true,
},
doubleClick: {
title: '双击画布,自适应',
title: $i18n.get({
id: 'basic.components.CanvasSetting.registerMeta.DoubleClickTheCanvasTo',
dm: '双击画布,自适应',
}),
'x-component': 'Switch',
'x-decorator': 'FormItem',
type: 'boolean',
Expand Down
Loading

0 comments on commit f6fbe5a

Please sign in to comment.