refactor: reconstruct language files into multi-file structures (#4683)

* refactor: reconstruct language files into multi-file structures

* chore: typo
This commit is contained in:
Vben
2024-10-19 14:28:21 +08:00
committed by GitHub
parent d1ca09c7bb
commit 0df8c5c02c
93 changed files with 1707 additions and 1514 deletions

View File

@@ -41,7 +41,7 @@ const withDefaultPlaceholder = <T extends Component>(
type: 'input' | 'select',
) => {
return (props: any, { attrs, slots }: Omit<SetupContext, 'expose'>) => {
const placeholder = props?.placeholder || $t(`placeholder.${type}`);
const placeholder = props?.placeholder || $t(`ui.placeholder.${type}`);
return h(component, { ...props, ...attrs, placeholder }, slots);
};
};

View File

@@ -28,13 +28,13 @@ setupVbenForm<ComponentType>({
defineRules: {
required: (value, _params, ctx) => {
if (value === undefined || value === null || value.length === 0) {
return $t('formRules.required', [ctx.label]);
return $t('ui.formRules.required', [ctx.label]);
}
return true;
},
selectRequired: (value, _params, ctx) => {
if (value === undefined || value === null) {
return $t('formRules.selectRequired', [ctx.label]);
return $t('ui.formRules.selectRequired', [ctx.label]);
}
return true;
},

View File

@@ -53,7 +53,7 @@ Drawer 内的内容一般业务中,会比较复杂,所以我们可以将 dra
::: info 注意
- `VbenDrawer` 组件对与参数的处理优先级是 `slot` > `props` > `state`(通过api更新的状态以及useVbenDrawer参数)。如果你已经传入了 `slot` 或者 `props`,那么 `setState` 将不会生效,这种情况下你可以通过 `slot` 或者 `props` 来更新状态。
- 如果你使用到了 `connectedComponent` 参数,那么会存在 2 个`useVbenDrawer`, 此时,如果同时设置了相同的参数,那么以内部为准(也就是没有设置 connectedComponent 的代码)。比如 同时设置了 `onComfirm`,那么以内部的 `onComfirm` 为准。`onOpenChange`事件除外,内外都会触发。
- 如果你使用到了 `connectedComponent` 参数,那么会存在 2 个`useVbenDrawer`, 此时,如果同时设置了相同的参数,那么以内部为准(也就是没有设置 connectedComponent 的代码)。比如 同时设置了 `onConfirm`,那么以内部的 `onConfirm` 为准。`onOpenChange`事件除外,内外都会触发。
:::

View File

@@ -51,14 +51,14 @@ setupVbenForm<ComponentType>({
// 输入项目必填国际化适配
required: (value, _params, ctx) => {
if (value === undefined || value === null || value.length === 0) {
return $t('formRules.required', [ctx.label]);
return $t('ui.formRules.required', [ctx.label]);
}
return true;
},
// 选择项目必填国际化适配
selectRequired: (value, _params, ctx) => {
if (value === undefined || value === null) {
return $t('formRules.selectRequired', [ctx.label]);
return $t('ui.formRules.selectRequired', [ctx.label]);
}
return true;
},
@@ -120,7 +120,7 @@ const withDefaultPlaceholder = <T extends Component>(
type: 'input' | 'select',
) => {
return (props: any, { attrs, slots }: Omit<SetupContext, 'expose'>) => {
const placeholder = props?.placeholder || $t(`placeholder.${type}`);
const placeholder = props?.placeholder || $t(`ui.placeholder.${type}`);
return h(component, { ...props, ...attrs, placeholder }, slots);
};
};

View File

@@ -59,7 +59,7 @@ Modal 内的内容一般业务中,会比较复杂,所以我们可以将 moda
::: info 注意
- `VbenModal` 组件对与参数的处理优先级是 `slot` > `props` > `state`(通过api更新的状态以及useVbenModal参数)。如果你已经传入了 `slot` 或者 `props`,那么 `setState` 将不会生效,这种情况下你可以通过 `slot` 或者 `props` 来更新状态。
- 如果你使用到了 `connectedComponent` 参数,那么会存在 2 个`useVbenModal`, 此时,如果同时设置了相同的参数,那么以内部为准(也就是没有设置 connectedComponent 的代码)。比如 同时设置了 `onComfirm`,那么以内部的 `onComfirm` 为准。`onOpenChange`事件除外,内外都会触发。
- 如果你使用到了 `connectedComponent` 参数,那么会存在 2 个`useVbenModal`, 此时,如果同时设置了相同的参数,那么以内部为准(也就是没有设置 connectedComponent 的代码)。比如 同时设置了 `onConfirm`,那么以内部的 `onConfirm` 为准。`onOpenChange`事件除外,内外都会触发。
:::

View File

@@ -106,7 +106,7 @@ const routes: RouteRecordRaw[] = [
icon: 'ic:baseline-view-in-ar',
keepAlive: true,
order: 1000,
title: $t('page.demos.title'),
title: $t('demos.title'),
},
name: 'Demos',
path: '/demos',
@@ -116,7 +116,7 @@ const routes: RouteRecordRaw[] = [
{
meta: {
icon: 'ic:round-menu',
title: $t('page.demos.nested.title'),
title: $t('demos.nested.title'),
},
name: 'NestedDemos',
path: '/demos/nested',
@@ -129,7 +129,7 @@ const routes: RouteRecordRaw[] = [
meta: {
icon: 'ic:round-menu',
keepAlive: true,
title: $t('page.demos.nested.menu1'),
title: $t('demos.nested.menu1'),
},
},
{
@@ -138,7 +138,7 @@ const routes: RouteRecordRaw[] = [
meta: {
icon: 'ic:round-menu',
keepAlive: true,
title: $t('page.demos.nested.menu2'),
title: $t('demos.nested.menu2'),
},
redirect: '/demos/nested/menu2/menu2-1',
children: [
@@ -149,7 +149,7 @@ const routes: RouteRecordRaw[] = [
meta: {
icon: 'ic:round-menu',
keepAlive: true,
title: $t('page.demos.nested.menu2_1'),
title: $t('demos.nested.menu2_1'),
},
},
],
@@ -159,7 +159,7 @@ const routes: RouteRecordRaw[] = [
path: '/demos/nested/menu3',
meta: {
icon: 'ic:round-menu',
title: $t('page.demos.nested.menu3'),
title: $t('demos.nested.menu3'),
},
redirect: '/demos/nested/menu3/menu3-1',
children: [
@@ -170,7 +170,7 @@ const routes: RouteRecordRaw[] = [
meta: {
icon: 'ic:round-menu',
keepAlive: true,
title: $t('page.demos.nested.menu3_1'),
title: $t('demos.nested.menu3_1'),
},
},
{
@@ -178,7 +178,7 @@ const routes: RouteRecordRaw[] = [
path: 'menu3-2',
meta: {
icon: 'ic:round-menu',
title: $t('page.demos.nested.menu3_2'),
title: $t('demos.nested.menu3_2'),
},
redirect: '/demos/nested/menu3/menu3-2/menu3-2-1',
children: [
@@ -190,7 +190,7 @@ const routes: RouteRecordRaw[] = [
meta: {
icon: 'ic:round-menu',
keepAlive: true,
title: $t('page.demos.nested.menu3_2_1'),
title: $t('demos.nested.menu3_2_1'),
},
},
],

View File

@@ -58,7 +58,7 @@ updateLocale('en-US');
To add new translation texts, simply find `src/locales/langs/` in the corresponding application and add the texts accordingly, for example:
**src/locales/langs/zh-CN.ts**
**src/locales/langs/zh-CN/\*.json**
````ts
```json

View File

@@ -105,7 +105,7 @@ const routes: RouteRecordRaw[] = [
icon: 'ic:baseline-view-in-ar',
keepAlive: true,
order: 1000,
title: $t('page.demos.title'),
title: $t('demos.title'),
},
name: 'Demos',
path: '/demos',
@@ -115,7 +115,7 @@ const routes: RouteRecordRaw[] = [
{
meta: {
icon: 'ic:round-menu',
title: $t('page.demos.nested.title'),
title: $t('demos.nested.title'),
},
name: 'NestedDemos',
path: '/demos/nested',
@@ -128,7 +128,7 @@ const routes: RouteRecordRaw[] = [
meta: {
icon: 'ic:round-menu',
keepAlive: true,
title: $t('page.demos.nested.menu1'),
title: $t('demos.nested.menu1'),
},
},
{
@@ -137,7 +137,7 @@ const routes: RouteRecordRaw[] = [
meta: {
icon: 'ic:round-menu',
keepAlive: true,
title: $t('page.demos.nested.menu2'),
title: $t('demos.nested.menu2'),
},
redirect: '/demos/nested/menu2/menu2-1',
children: [
@@ -148,7 +148,7 @@ const routes: RouteRecordRaw[] = [
meta: {
icon: 'ic:round-menu',
keepAlive: true,
title: $t('page.demos.nested.menu2_1'),
title: $t('demos.nested.menu2_1'),
},
},
],
@@ -158,7 +158,7 @@ const routes: RouteRecordRaw[] = [
path: '/demos/nested/menu3',
meta: {
icon: 'ic:round-menu',
title: $t('page.demos.nested.menu3'),
title: $t('demos.nested.menu3'),
},
redirect: '/demos/nested/menu3/menu3-1',
children: [
@@ -169,7 +169,7 @@ const routes: RouteRecordRaw[] = [
meta: {
icon: 'ic:round-menu',
keepAlive: true,
title: $t('page.demos.nested.menu3_1'),
title: $t('demos.nested.menu3_1'),
},
},
{
@@ -177,7 +177,7 @@ const routes: RouteRecordRaw[] = [
path: 'menu3-2',
meta: {
icon: 'ic:round-menu',
title: $t('page.demos.nested.menu3_2'),
title: $t('demos.nested.menu3_2'),
},
redirect: '/demos/nested/menu3/menu3-2/menu3-2-1',
children: [
@@ -189,7 +189,7 @@ const routes: RouteRecordRaw[] = [
meta: {
icon: 'ic:round-menu',
keepAlive: true,
title: $t('page.demos.nested.menu3_2_1'),
title: $t('demos.nested.menu3_2_1'),
},
},
],

View File

@@ -58,7 +58,7 @@ updateLocale('en-US');
新增翻译文本,只需要在对应的应用内,找到 `src/locales/langs/`,新增对应的文本即可,例:
**src/locales/langs/zh-CN.ts**
**src/locales/langs/zh-CN/\*.json**
````ts
```json