diff --git a/.dumirc.ts b/.dumirc.ts
index fe1cd02..ae187c0 100644
--- a/.dumirc.ts
+++ b/.dumirc.ts
@@ -3,6 +3,7 @@ import { readdirSync } from 'fs';
import { join } from 'path';
const PUBLIC_PATH = '/lowcode-tools-public/';
+const isProduction = process.env.NODE_ENV === 'production';
const headPkgList: string[] = [];
const pkgDirList = readdirSync(join(__dirname, 'packages')).filter(
@@ -21,18 +22,17 @@ export const alias = pkgDirList.reduce((pre, name) => {
export default defineConfig({
alias,
// autoAlias: true,
+ base: isProduction ? '/lowcode-tools/' : '/',
resolve: {
docDirs: ['docs'],
atomDirs: [{ type: 'lowcode-tools', dir: 'packages' }],
},
favicons: [`${PUBLIC_PATH}img/favicon.ico`],
publicPath: PUBLIC_PATH,
+ outputPath: `./dist${PUBLIC_PATH}`,
themeConfig: {
logo: `${PUBLIC_PATH}img/logo.svg`,
- nav: [
- { title: '开发指南', link: '/guide' },
- { title: '组件总览', link: '/lowcode-tools/overview' },
- ],
+ nav: [{ title: '开发指南', link: '/guide' }],
},
ignoreMomentLocale: true,
mfsu: {
diff --git a/README.md b/README.md
index e62b4e7..cd3317f 100644
--- a/README.md
+++ b/README.md
@@ -59,7 +59,7 @@ pnpm install
Contributions of all types are more than welcome, if you are interested in contributing code, feel free to check out our GitHub [Issues][github-issues-link] to get stuck in to show us what you’re made of.
-\[!\[]\[pr-welcome-shield]]\[pr-welcome-link]
+[![][pr-welcome-shield]][pr-welcome-link]
[![][github-contrib-shield]][github-contrib-link]
@@ -103,3 +103,5 @@ This project is [MIT](./LICENSE) licensed.
[i18n-extract-github]: https://github.com/yuntijs/lowcode-tools/tree/master/packages/lowcode-i18n-extract/README.md
[i18n-extract-shield]: https://img.shields.io/npm/v/@yuntijs/lowcode-i18n-extract?color=369eff&labelColor=black&logo=npm&logoColor=white&style=flat-square
[i18n-extract-url]: https://www.npmjs.com/package/@yuntijs/lowcode-i18n-extract
+[pr-welcome-link]: https://github.com/yuntijs/lowcode-tools/pulls
+[pr-welcome-shield]: https://img.shields.io/badge/☁️_pr_welcome-%E2%86%92-ffcb47?labelColor=black&style=for-the-badge
diff --git a/docs/index.md b/docs/index.md
index 0de7b1d..9773480 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -1,10 +1,10 @@
---
hero:
title: LowCode Tools
- description: 云梯官方低码工具
+ description: 云梯官方低码工具集
actions:
- text: 立即上手
- link: /lowcode-tools
+ link: /guide
- text: GitHub
link: https://github.com/yuntijs/lowcode-tools
features:
diff --git a/package.json b/package.json
index b17dd89..51c6d23 100644
--- a/package.json
+++ b/package.json
@@ -3,9 +3,10 @@
"version": "0.1.0",
"description": "Tools for low-code engine.",
"keywords": [
+ "yuntijs",
+ "lowcode",
"low-code",
"low-code engine",
- "yunti-ui",
"tools"
],
"license": "MIT",
@@ -55,7 +56,7 @@
"@types/react-dom": "^17",
"@umijs/test": "^4",
"@yuntijs/lint": "^1.5.1",
- "@yuntijs/ui": "^1.0.0-beta.7",
+ "@yuntijs/ui": "^1.0.0-beta.8",
"commitlint": "^18",
"concurrently": "^8.2.2",
"cross-env": "^7.0.3",
diff --git a/packages/lowcode-i18n-extract/README.md b/packages/lowcode-i18n-extract/README.md
index a50b96b..cfb9728 100644
--- a/packages/lowcode-i18n-extract/README.md
+++ b/packages/lowcode-i18n-extract/README.md
@@ -4,7 +4,7 @@
Yunti Lowcode I18n Extract Tools
-🌐 @yuntijs/lowcode-i18n-extract is an i18n extract tools for lowcode schema and inspired by [Kiwi](https://github.com/alibaba/kiwi).
+🌐 [@yuntijs/lowcode-i18n-extract](https://www.npmjs.com/package/@yuntijs/lowcode-i18n-extract) is an i18n extract tools for schema of [lowcode engine](https://lowcode-engine.cn/index) inspired by [Kiwi](https://github.com/alibaba/kiwi).
English ・ [简体中文](./README.zh-CN.md) ・ [Changelog](./CHANGELOG.md) · [Report Bug][github-issues-link] · [Request Feature][github-issues-link]
@@ -77,6 +77,8 @@ const schema = {
};
const { matches, schema: schemaWithI18n } = extractI18n(schema);
+// matches are extracted i18n texts
+// schemaWithI18n is scheam with i18n injected
```
diff --git a/packages/lowcode-i18n-extract/demo/index.tsx b/packages/lowcode-i18n-extract/demo/index.tsx
index 67ec0d3..ccb1b0c 100644
--- a/packages/lowcode-i18n-extract/demo/index.tsx
+++ b/packages/lowcode-i18n-extract/demo/index.tsx
@@ -1,7 +1,7 @@
/* eslint-disable no-console */
import { extractI18n } from '@yuntijs/lowcode-i18n-extract';
import { MonacoEditor } from '@yuntijs/ui';
-import { Button, Flex } from 'antd';
+import { Button, Flex, Tabs } from 'antd';
import React, { useState } from 'react';
import schemaData from '../tests/data/schema.json';
@@ -9,11 +9,13 @@ import schemaData from '../tests/data/schema.json';
const LowcodeI18nExtractDemo: React.FC = () => {
const [schema, setSchema] = useState(JSON.stringify(schemaData, null, 2));
const [schemaExtracted, setSchemaExtracted] = useState
();
+ const [matches, setMatches] = useState();
const onExtractI18nBtnClick = () => {
- const { matches, schema: schemaWithI18n } = extractI18n(JSON.parse(schema));
- console.log('matches =>', matches);
- console.log('schemaWithI18n =>', schemaWithI18n);
- setSchemaExtracted(JSON.stringify(schemaWithI18n, null, 2));
+ const results = extractI18n(JSON.parse(schema));
+ console.log('matches =>', results.matches);
+ console.log('schemaWithI18n =>', results.schema);
+ setSchemaExtracted(JSON.stringify(results.schema, null, 2));
+ setMatches(JSON.stringify(results.matches, null, 2));
};
return (
@@ -30,12 +32,36 @@ const LowcodeI18nExtractDemo: React.FC = () => {
Extract I18n Texts
Results:
-
+ ),
+ },
+ {
+ key: 'matches',
+ label: 'maches',
+ children: (
+
+ ),
+ },
+ ]}
/>
);
diff --git a/packages/lowcode-i18n-extract/index.md b/packages/lowcode-i18n-extract/index.md
index bf3c161..2f19ded 100644
--- a/packages/lowcode-i18n-extract/index.md
+++ b/packages/lowcode-i18n-extract/index.md
@@ -1,10 +1,18 @@
---
-title: lowcode-i18n-extract
+title: i18n-extract
order: 0
---
+
+
+
Yunti Lowcode I18n Extract Tools
+
+🌐 [@yuntijs/lowcode-i18n-extract](https://www.npmjs.com/package/@yuntijs/lowcode-i18n-extract) is an i18n extract tools for schema of [lowcode engine](https://lowcode-engine.cn/index) inspired by [Kiwi](https://github.com/alibaba/kiwi).
+
+
+
## 📦 Installation
To install @yuntijs/lowcode-i18n-extract, run the following command:
@@ -23,6 +31,67 @@ const schema = {
};
const { matches, schema: schemaWithI18n } = extractI18n(schema);
+// matches are extracted i18n texts
+// schemaWithI18n is scheam with i18n injected
+```
+
+## 🤝 API
+
+### `extractI18n(schema, options)`
+
+#### `schema`
+
+The full project schema of [lowcode engine](https://lowcode-engine.cn/index).
+
+#### `options`
+
+```ts
+export interface ExtractI18nOptions {
+ /** schema 过滤器,可以过滤一些不需要提取中文的字段,不传使用默认的过滤器 `defaultSchemaFilter` */
+ schemaFilter?: (
+ schema: IPublicTypeProjectSchema
+ ) => IPublicTypeProjectSchema;
+}
+```
+
+`defaultSchemaFilter`:
+
+```ts
+export const defaultSchemaFilter = (
+ schema: IPublicTypeProjectSchema
+) => {
+ const pureSchmea = cloneDeep(schema);
+ const _filterChildren = (children: IPublicTypePageSchema['children']) => {
+ for (const key of Object.keys(children)) {
+ const value = (children as Record)[key];
+ if (!value) {
+ continue;
+ }
+ // 过滤 table 等数据源静态数据
+ if (key === 'dataSource' && Array.isArray(value)) {
+ delete (children as Record).dataSource;
+ }
+ if (typeof value === 'object') {
+ _filterChildren(value);
+ }
+ }
+ return children;
+ };
+ pureSchmea.componentsTree = pureSchmea.componentsTree?.map(container => {
+ const { props, state, methods, dataSource, lifeCycles, children } =
+ container as IPublicTypePageSchema;
+ // 默认仅提取以下几个字段中的中文
+ return {
+ props,
+ state,
+ methods,
+ dataSource,
+ lifeCycles,
+ children: _filterChildren(children),
+ } as T;
+ });
+ return pureSchmea;
+};
```
## 🛝 Playground
diff --git a/packages/lowcode-i18n-extract/package.json b/packages/lowcode-i18n-extract/package.json
index 0f81095..ad1abdb 100644
--- a/packages/lowcode-i18n-extract/package.json
+++ b/packages/lowcode-i18n-extract/package.json
@@ -5,8 +5,20 @@
"keywords": [
"yuntijs",
"lowcode",
- "i18n"
+ "low-code",
+ "low-code engine",
+ "i18n",
+ "extract",
+ "kiwi"
],
+ "homepage": "https://github.com/yuntijs/lowcode-tools",
+ "bugs": {
+ "url": "https://github.com/yuntijs/lowcode-tools/issues/new"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/yuntijs/lowcode-tools.git"
+ },
"license": "MIT",
"module": "dist/es/index.js",
"types": "dist/es/index.d.ts",
diff --git a/packages/lowcode-i18n-extract/src/index.ts b/packages/lowcode-i18n-extract/src/index.ts
index 909fb83..9e79522 100644
--- a/packages/lowcode-i18n-extract/src/index.ts
+++ b/packages/lowcode-i18n-extract/src/index.ts
@@ -11,8 +11,6 @@ export interface ExtractI18nOptions {
schemaFilter?: (
schema: IPublicTypeProjectSchema
) => IPublicTypeProjectSchema;
- /** 批量提取文案时生成 key 值时的默认翻译源, 默认 Pinyin,可选 Pinyin/Google/Baidu/Bing */
- defaultI18nKeyApi?: 'Pinyin' | 'Google' | 'Baidu' | 'Bing';
}
export const defaultSchemaFilter = (
diff --git a/packages/lowcode-i18n-extract/tests/data/schema.json b/packages/lowcode-i18n-extract/tests/data/schema.json
index 8ac88e7..75ab694 100644
--- a/packages/lowcode-i18n-extract/tests/data/schema.json
+++ b/packages/lowcode-i18n-extract/tests/data/schema.json
@@ -178,10 +178,7 @@
"bold": true,
"level": 1,
"bordered": false,
- "children": {
- "key": "i18n-s7vniwvk",
- "type": "i18n"
- },
+ "children": "国际化文案提取测试",
"ellipsis": true,
"__component_name": "Typography.Title"
},
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index f9fe04a..b38f21c 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -24,8 +24,8 @@ importers:
specifier: ^1.5.1
version: 1.5.1(@octokit/core@3.6.0)(eslint@8.56.0)(jest@27.5.1)(postcss@8.4.35)(prettier@3.2.5)(semantic-release@21.1.2)(stylelint@15.11.0)(typescript@5.3.3)
'@yuntijs/ui':
- specifier: ^1.0.0-beta.7
- version: 1.0.0-beta.7(@types/react-dom@17.0.25)(@types/react@17.0.75)(antd-style@3.6.1)(antd@5.15.2)(monaco-editor@0.47.0)(react-dom@17.0.2)(react@17.0.2)
+ specifier: ^1.0.0-beta.8
+ version: 1.0.0-beta.8(@types/react-dom@17.0.25)(@types/react@17.0.75)(antd-style@3.6.1)(antd@5.15.2)(monaco-editor@0.47.0)(react-dom@17.0.2)(react@17.0.2)
commitlint:
specifier: ^18
version: 18.6.1(@types/node@20.11.19)(typescript@5.3.3)
@@ -2290,7 +2290,7 @@ packages:
immer: 10.0.4
leva: 0.9.35(@types/react-dom@17.0.25)(@types/react@17.0.75)(react-dom@17.0.2)(react@17.0.2)
lodash-es: 4.17.21
- lucide-react: 0.356.0(react@17.0.2)
+ lucide-react: 0.358.0(react@17.0.2)
polished: 4.3.1
prism-react-renderer: 2.3.1(react@17.0.2)
query-string: 9.0.0
@@ -5274,8 +5274,8 @@ packages:
- typescript
dev: true
- /@yuntijs/ui@1.0.0-beta.7(@types/react-dom@17.0.25)(@types/react@17.0.75)(antd-style@3.6.1)(antd@5.15.2)(monaco-editor@0.47.0)(react-dom@17.0.2)(react@17.0.2):
- resolution: {integrity: sha512-w2PJd4Wpy/OLvrHyOImKESbxMAnFBsj5271vWm0SFTznU1NKd3BMDDMMCxovyrr3ucvfmDP35s6EyfdZa5tw+g==}
+ /@yuntijs/ui@1.0.0-beta.8(@types/react-dom@17.0.25)(@types/react@17.0.75)(antd-style@3.6.1)(antd@5.15.2)(monaco-editor@0.47.0)(react-dom@17.0.2)(react@17.0.2):
+ resolution: {integrity: sha512-TrbYkOG4i0KWp+4PjZFBni91iAJJZ+RO9ldtHTHnOTBrDPapzHWG1Cw4YlSHPWIu/1CIub3DcEvZJCvwVDcH+Q==}
peerDependencies:
antd: '>=5'
antd-style: '>=3'
@@ -5290,7 +5290,7 @@ packages:
antd-style: 3.6.1(@types/react@17.0.75)(antd@5.15.2)(react-dom@17.0.2)(react@17.0.2)
leva: 0.9.35(@types/react-dom@17.0.25)(@types/react@17.0.75)(react-dom@17.0.2)(react@17.0.2)
lodash-es: 4.17.21
- lucide-react: 0.356.0(react@17.0.2)
+ lucide-react: 0.358.0(react@17.0.2)
query-string: 8.2.0
react: 17.0.2
react-dom: 17.0.2(react@17.0.2)
@@ -12307,8 +12307,8 @@ packages:
engines: {node: '>=12'}
dev: true
- /lucide-react@0.356.0(react@17.0.2):
- resolution: {integrity: sha512-MDInjLrmZToccH2UxEshntujBlFwtOofGB22FN/eg39FfGVYV1TT1eMIv2j4rdaTJBpYjUuX7fEo9pwYkNFgwA==}
+ /lucide-react@0.358.0(react@17.0.2):
+ resolution: {integrity: sha512-rBSptRjZTMBm24zsFhR6pK/NgbT18JegZGKcH4+1H3+UigMSRpeoWLtR/fAwMYwYnlJOZB+y8WpeHne9D6X6Kg==}
peerDependencies:
react: ^16.5.1 || ^17.0.0 || ^18.0.0
dependencies: