diff --git a/packages/core/client/src/i18n/i18n.ts b/packages/core/client/src/i18n/i18n.ts index 03ab745b8..3cf16ea2f 100644 --- a/packages/core/client/src/i18n/i18n.ts +++ b/packages/core/client/src/i18n/i18n.ts @@ -1,7 +1,14 @@ -import i18next from 'i18next'; +import i18next, { TFuncKey, TOptions } from 'i18next'; import { initReactI18next } from 'react-i18next'; import locale from '../locale'; +export function tval(text: TFuncKey | TFuncKey[], options?: TOptions) { + if (options) { + return `{{t(${JSON.stringify(text)}, ${JSON.stringify(options)})}}`; + } + return `{{t(${JSON.stringify(text)})}}`; +} + export const i18n = i18next.createInstance(); const resources = {}; diff --git a/packages/core/client/src/nocobase-buildin-plugin/plugins/LocalePlugin.ts b/packages/core/client/src/nocobase-buildin-plugin/plugins/LocalePlugin.ts index 7bdbcfa3f..8bee2828d 100644 --- a/packages/core/client/src/nocobase-buildin-plugin/plugins/LocalePlugin.ts +++ b/packages/core/client/src/nocobase-buildin-plugin/plugins/LocalePlugin.ts @@ -1,4 +1,4 @@ -import { ConfigProvider } from 'antd'; +import { App, ConfigProvider } from 'antd'; import dayjs from 'dayjs'; import { loadConstrueLocale } from '../../antd-config-provider/loadConstrueLocale'; import { Plugin } from '../../application/Plugin'; @@ -19,6 +19,7 @@ export class LocalePlugin extends Plugin { const data = res?.data; this.locales = data?.data || {}; this.app.use(ConfigProvider, { locale: this.locales.antd, popupMatchSelectWidth: false }); + this.app.use(App); if (data?.data?.lang && !locale) { api.auth.setLocale(data?.data?.lang); this.app.i18n.changeLanguage(data?.data?.lang); diff --git a/packages/core/client/src/schema-component/antd/action/Action.Designer.tsx b/packages/core/client/src/schema-component/antd/action/Action.Designer.tsx index 237b674e6..d41dc4a88 100644 --- a/packages/core/client/src/schema-component/antd/action/Action.Designer.tsx +++ b/packages/core/client/src/schema-component/antd/action/Action.Designer.tsx @@ -7,9 +7,10 @@ import { cloneDeep } from 'lodash'; import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { RemoteSelect, useCompile, useDesignable } from '../..'; +import { useApp } from '../../../application'; import { usePlugin } from '../../../application/hooks'; +import { SchemaSettingOptions, SchemaSettings } from '../../../application/schema-settings'; import { useSchemaToolbar } from '../../../application/schema-toolbar'; -import { SchemaSettings, SchemaSettingOptions } from '../../../application/schema-settings'; import { CollectionOptions, useCollection, useCollectionManager } from '../../../collection-manager'; import { FlagProvider } from '../../../flag-provider'; import { useRecord } from '../../../record-provider'; @@ -30,7 +31,6 @@ import { import { DefaultValueProvider } from '../../../schema-settings/hooks/useIsAllowToSetDefaultValue'; import { useLinkageAction } from './hooks'; import { requestSettingsSchema } from './utils'; -import { useApp } from '../../../application'; const Tree = connect( AntdTree, @@ -1089,7 +1089,7 @@ export const ActionDesigner = (props) => { const fieldSchema = useFieldSchema(); const isDraggable = fieldSchema?.parent['x-component'] !== 'CollectionField'; const settingsName = `ActionSettings:${fieldSchema['x-action']}`; - const defaultActionSettings = 'ActionSettings'; + const defaultActionSettings = schemaSettings || 'ActionSettings'; const hasAction = app.schemaSettingsManager.has(settingsName); return ( diff --git a/packages/core/client/src/schema-initializer/buttons/GridCardActionInitializers.tsx b/packages/core/client/src/schema-initializer/buttons/GridCardActionInitializers.tsx index a9f66c320..328b68022 100644 --- a/packages/core/client/src/schema-initializer/buttons/GridCardActionInitializers.tsx +++ b/packages/core/client/src/schema-initializer/buttons/GridCardActionInitializers.tsx @@ -222,7 +222,7 @@ export const gridCardItemActionInitializers = new SchemaInitializer({ }, }, { - name: 'custom-request', + name: 'customRequest', title: '{{t("Custom request")}}', Component: 'CustomRequestInitializer', schema: { diff --git a/packages/core/client/src/schema-initializer/buttons/TableActionColumnInitializers.tsx b/packages/core/client/src/schema-initializer/buttons/TableActionColumnInitializers.tsx index aa3c3dce1..fa932a8bb 100644 --- a/packages/core/client/src/schema-initializer/buttons/TableActionColumnInitializers.tsx +++ b/packages/core/client/src/schema-initializer/buttons/TableActionColumnInitializers.tsx @@ -275,26 +275,11 @@ export const tableActionColumnInitializers = new SchemaInitializer({ }, }, { - type: 'item', - title: '{{t("Custom request")}}', name: 'customRequest', - Component: 'CustomizeActionInitializer', + title: '{{t("Custom request")}}', + Component: 'CustomRequestInitializer', schema: { - title: '{{ t("Custom request") }}', - 'x-component': 'Action.Link', 'x-action': 'customize:table:request', - 'x-designer': 'Action.Designer', - 'x-action-settings': { - requestSettings: {}, - onSuccess: { - manualClose: false, - redirecting: false, - successMessage: '{{t("Request success")}}', - }, - }, - 'x-component-props': { - useProps: '{{ useCustomizeRequestActionProps }}', - }, }, useVisible() { const collection = useCollection();