diff --git a/packages/xgen/components/base/Filter/index.tsx b/packages/xgen/components/base/Filter/index.tsx
index cbebd12e..06506bc6 100644
--- a/packages/xgen/components/base/Filter/index.tsx
+++ b/packages/xgen/components/base/Filter/index.tsx
@@ -12,7 +12,7 @@ import { getLocale, useSearchParams } from '@umijs/max'
import Actions from './components/Actions'
import { useCalcLayout, useVisibleMore } from './hooks'
import styles from './index.less'
-import locales from './locales'
+import { Message } from './locales'
import type { IPropsFilter, IPropsActions } from './types'
@@ -41,8 +41,8 @@ const Index = (props: IPropsFilter) => {
if (!Object.keys(search_params).length) return
setFieldsValue(search_params)
- }, [ parent, params ])
-
+ }, [parent, params])
+
if (!columns.length && !actions?.length) return null
const onReset = () => {
@@ -87,7 +87,7 @@ const Index = (props: IPropsFilter) => {
type='primary'
htmlType='submit'
>
- {locales[locale].search}
+ {Message(locale).search}
@@ -95,7 +95,7 @@ const Index = (props: IPropsFilter) => {
className='btn_filter_action flex justify_center align_center'
htmlType='reset'
>
- {locales[locale].reset}
+ {Message(locale).reset}
diff --git a/packages/xgen/components/base/Filter/locales.ts b/packages/xgen/components/base/Filter/locales.ts
index 39c76620..294ca1a6 100644
--- a/packages/xgen/components/base/Filter/locales.ts
+++ b/packages/xgen/components/base/Filter/locales.ts
@@ -1,6 +1,6 @@
-import type { Locale } from './types'
+import type { Locale, LocaleFilter } from './types'
-export default {
+const locale = {
'zh-CN': {
search: '搜索',
reset: '重置'
@@ -10,3 +10,9 @@ export default {
reset: 'Reset'
}
} as Locale
+
+export default locale
+
+export const Message = (key: any): LocaleFilter => {
+ return locale[key] || locale['en-US']
+}
diff --git a/packages/xgen/components/base/Filter/types.ts b/packages/xgen/components/base/Filter/types.ts
index c6d4703b..2ba6d7a1 100644
--- a/packages/xgen/components/base/Filter/types.ts
+++ b/packages/xgen/components/base/Filter/types.ts
@@ -20,9 +20,11 @@ export interface IPropsActions {
query: any
}
+export interface LocaleFilter {
+ search: string
+ reset: string
+}
+
export interface Locale {
- [key: string]: {
- search: string
- reset: string
- }
+ [key: string]: LocaleFilter
}
diff --git a/packages/xgen/components/base/Form/index.tsx b/packages/xgen/components/base/Form/index.tsx
index d2fe34a3..d2d8848b 100644
--- a/packages/xgen/components/base/Form/index.tsx
+++ b/packages/xgen/components/base/Form/index.tsx
@@ -12,7 +12,7 @@ import Anchor from './components/Anchor'
import Breadcrumb from './components/Breadcrumb'
import { useHooks, usePageTitle } from './hooks'
import styles from './index.less'
-import locales from './locales'
+import { Message } from './locales'
import Model from './model'
import type { Component } from '@/types'
@@ -23,19 +23,19 @@ const Index = (props: Component.FormComponent) => {
const { parent, parentNamespace, model, id, form, onBack } = props
const [x] = useState(() => container.resolve(Model))
const locale = getLocale()
- const page_title_prefix = usePageTitle(locales[locale], id!, form!.type)
+ const page_title_prefix = usePageTitle(Message(locale), id!, form!.type)
const hooks = useHooks(toJS(x.setting.hooks!), toJS(x.setting.fields), toJS(x.data))
const ref_container = useRef(null)
const [is_fullscreen, { toggleFullscreen }] = useFullscreen(ref_container)
- const title = useMemo(() => {
- if (x.setting?.config?.viewTitle && x.type === 'view') {
- return x.setting.config.viewTitle
- }
+ const title = useMemo(() => {
+ if (x.setting?.config?.viewTitle && x.type === 'view') {
+ return x.setting.config.viewTitle
+ }
- if (x.setting?.config?.editTitle && x.type === 'edit') {
- return x.setting.config.editTitle
- }
+ if (x.setting?.config?.editTitle && x.type === 'edit') {
+ return x.setting.config.editTitle
+ }
return page_title_prefix + x.setting.name
}, [page_title_prefix, x.setting.name, x.type, x.setting?.config?.viewTitle, x.setting?.config?.editTitle])
diff --git a/packages/xgen/components/base/Form/locales.ts b/packages/xgen/components/base/Form/locales.ts
index 0d595cd8..ff7b33e2 100644
--- a/packages/xgen/components/base/Form/locales.ts
+++ b/packages/xgen/components/base/Form/locales.ts
@@ -1,6 +1,6 @@
-import type { Locale } from './types'
+import type { Locale, LocaleForm } from './types'
-export default {
+const locale = {
'zh-CN': {
page: {
title: {
@@ -20,3 +20,9 @@ export default {
}
}
} as Locale
+
+export default locale
+
+export const Message = (key: any): LocaleForm => {
+ return locale[key] || locale['en-US']
+}
diff --git a/packages/xgen/components/base/Form/types.ts b/packages/xgen/components/base/Form/types.ts
index 611710f1..ad783483 100644
--- a/packages/xgen/components/base/Form/types.ts
+++ b/packages/xgen/components/base/Form/types.ts
@@ -15,14 +15,16 @@ export interface IPropsAnchorItem {
item: FormType.Column
}
-export interface Locale {
- [key: string]: {
- page: {
- title: {
- add: string
- view: string
- edit: string
- }
+export interface LocaleForm {
+ page: {
+ title: {
+ add: string
+ view: string
+ edit: string
}
}
}
+
+export interface Locale {
+ [key: string]: LocaleForm
+}
diff --git a/packages/xgen/components/base/PureChart/components/ChartItem.tsx b/packages/xgen/components/base/PureChart/components/ChartItem.tsx
index a49fbf1e..baa744c9 100644
--- a/packages/xgen/components/base/PureChart/components/ChartItem.tsx
+++ b/packages/xgen/components/base/PureChart/components/ChartItem.tsx
@@ -4,7 +4,7 @@ import { X } from '@/components'
import { Card } from '@/widgets'
import { useIntl } from '@umijs/max'
-import locales from '../locales'
+import { Message } from '../locales'
import ChartLink from './ChartLink'
import type { IPropsChartItem } from '../types'
@@ -13,7 +13,7 @@ const Index = (props: IPropsChartItem) => {
const { item, data } = props
const { cardStyle, ...view_props } = item.view.props
const { locale } = useIntl()
- const locale_messages = locales[locale]
+ const locale_messages = Message(locale)
return (
diff --git a/packages/xgen/components/base/PureChart/locales.ts b/packages/xgen/components/base/PureChart/locales.ts
index e9eb42b4..0f88ca39 100644
--- a/packages/xgen/components/base/PureChart/locales.ts
+++ b/packages/xgen/components/base/PureChart/locales.ts
@@ -1,6 +1,6 @@
-import type { Locale } from './types'
+import type { Locale, LocalePureChart } from './types'
-export default {
+const locale = {
'zh-CN': {
link_tooltip: '查看更多数据'
},
@@ -8,3 +8,9 @@ export default {
link_tooltip: 'Check more data'
}
} as Locale
+
+export default locale
+
+export const Message = (key: any): LocalePureChart => {
+ return locale[key] || locale['en-US']
+}
diff --git a/packages/xgen/components/base/PureChart/types.ts b/packages/xgen/components/base/PureChart/types.ts
index ca5a784e..26426cf6 100644
--- a/packages/xgen/components/base/PureChart/types.ts
+++ b/packages/xgen/components/base/PureChart/types.ts
@@ -16,8 +16,10 @@ export interface IPropsChartLink {
link: string
}
+export interface LocalePureChart {
+ link_tooltip: string
+}
+
export interface Locale {
- [key: string]: {
- link_tooltip: string
- }
+ [key: string]: LocalePureChart
}
diff --git a/packages/xgen/components/base/PureTable/index.tsx b/packages/xgen/components/base/PureTable/index.tsx
index eee37c0d..8562a3f1 100644
--- a/packages/xgen/components/base/PureTable/index.tsx
+++ b/packages/xgen/components/base/PureTable/index.tsx
@@ -5,7 +5,7 @@ import { useLayoutEffect, useMemo } from 'react'
import { getLocale } from '@umijs/max'
import { useColumns } from './hooks'
-import locales from './locales'
+import { Message } from './locales'
import type { TablePaginationConfig } from 'antd'
import type { IPropsPureTable } from './types'
@@ -41,7 +41,7 @@ const Index = (props: IPropsPureTable) => {
showSizeChanger: true,
showTotal: useMemoizedFn(
(total: number) =>
- locales[locale].pagination.total.before + total + locales[locale].pagination.total.after
+ Message(locale).pagination.total.before + total + Message(locale).pagination.total.after
)
}
diff --git a/packages/xgen/components/base/PureTable/locales.ts b/packages/xgen/components/base/PureTable/locales.ts
index 209617b6..39de3712 100644
--- a/packages/xgen/components/base/PureTable/locales.ts
+++ b/packages/xgen/components/base/PureTable/locales.ts
@@ -1,6 +1,6 @@
-import type { Locale } from './types'
+import type { Locale, LocalePureTable } from './types'
-export default {
+const locale = {
'zh-CN': {
pagination: {
total: {
@@ -18,3 +18,9 @@ export default {
}
}
} as Locale
+
+export default locale
+
+export const Message = (key: any): LocalePureTable => {
+ return locale[key] || locale['en-US']
+}
diff --git a/packages/xgen/components/base/PureTable/types.ts b/packages/xgen/components/base/PureTable/types.ts
index 48b58d3d..deb6ffb8 100644
--- a/packages/xgen/components/base/PureTable/types.ts
+++ b/packages/xgen/components/base/PureTable/types.ts
@@ -41,13 +41,15 @@ export interface IPropsActions {
data_item: any
}
-export interface Locale {
- [key: string]: {
- pagination: {
- total: {
- before: string
- after: string
- }
+export interface LocalePureTable {
+ pagination: {
+ total: {
+ before: string
+ after: string
}
}
}
+
+export interface Locale {
+ [key: string]: LocalePureTable
+}