diff --git a/packages/core/client/src/locale/index.ts b/packages/core/client/src/locale/index.ts index 66e00ede3..e09fbe03d 100644 --- a/packages/core/client/src/locale/index.ts +++ b/packages/core/client/src/locale/index.ts @@ -4,6 +4,76 @@ export type LocaleOptions = { export { default as cron } from '../schema-component/antd/cron/locale'; +export const dayjsLocale = { + 'ar-EG': 'ar', + 'az-AZ': 'az', + 'bg-BG': 'bg', + 'bn-BD': 'bn-bd', + 'by-BY': 'en', + 'ca-ES': 'ca', + 'cs-CZ': 'cs', + 'da-DK': 'da', + 'de-DE': 'de', + 'el-GR': 'el', + 'en-GB': 'en-gb', + 'en-US': 'en', + 'es-ES': 'es', + 'et-EE': 'et', + 'fa-IR': 'fa', + 'fi-FI': 'fi', + 'fr-BE': 'fr', + 'fr-CA': 'fr', + 'fr-FR': 'fr', + 'ga-IE': 'ga', + 'gl-ES': 'gl', + 'he-IL': 'he', + 'hi-IN': 'hi', + 'hr-HR': 'hr', + 'hu-HU': 'hu', + 'hy-AM': 'hy-am', + 'id-ID': 'id', + 'is-IS': 'is', + 'it-IT': 'it', + 'ja-JP': 'ja', + 'ka-GE': 'ka', + 'kk-KZ': 'kk', + 'km-KH': 'km', + // 'kmr-IQ': { label: 'kmr_IQ' }, + 'kn-IN': 'kn', + 'ko-KR': 'kko', + 'ku-IQ': 'ku', + 'lt-LT': 'lt', + 'lv-LV': 'lv', + 'mk-MK': 'mk', + 'ml-IN': 'ml', + 'mn-MN': 'mn', + 'ms-MY': 'ms', + 'nb-NO': 'nb', + 'ne-NP': 'ne', + 'nl-BE': 'nl-be', + 'nl-NL': 'nl', + 'pl-PL': 'pl', + 'pt-BR': 'pt-br', + 'pt-PT': 'pt', + 'ro-RO': 'ro', + 'ru-RU': 'ru', + 'si-LK': 'si', + 'sk-SK': 'sk', + 'sl-SI': 'sl', + 'sr-RS': 'sr', + 'sv-SE': 'sv', + 'ta-IN': 'ta', + 'th-TH': 'th', + 'tk-TK': 'tk', + 'tr-TR': 'tr', + 'uk-UA': 'uk', + 'ur-PK': 'ur', + 'vi-VN': 'vi', + 'zh-CN': 'zh-cn', + 'zh-HK': 'zh-hk', + 'zh-TW': 'zh-tw', +}; + export default { 'ar-EG': { label: 'العربية' }, 'az-AZ': { label: 'Azərbaycan dili' }, 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 a5baafacf..c15793bab 100644 --- a/packages/core/client/src/nocobase-buildin-plugin/plugins/LocalePlugin.ts +++ b/packages/core/client/src/nocobase-buildin-plugin/plugins/LocalePlugin.ts @@ -2,6 +2,7 @@ import { dayjs } from '@nocobase/utils/client'; import { ConfigProvider } from 'antd'; import { loadConstrueLocale } from '../../antd-config-provider/loadConstrueLocale'; import { Plugin } from '../../application/Plugin'; +import { dayjsLocale } from '../../locale'; export class LocalePlugin extends Plugin { locales: any = {}; @@ -25,6 +26,8 @@ export class LocalePlugin extends Plugin { this.app.i18n.addResources(data?.data?.lang, key, data?.data?.resources[key] || {}); }); loadConstrueLocale(data?.data); + const dayjsLang = dayjsLocale[data?.data?.lang] || 'en'; + await import(`dayjs/locale/${dayjsLang}`); dayjs.locale(data?.data?.moment); window['cronLocale'] = data?.data?.cron; } catch (error) { diff --git a/packages/core/client/src/schema-component/antd/calendar/Calendar.tsx b/packages/core/client/src/schema-component/antd/calendar/Calendar.tsx index c2b4dff2a..142fe5af6 100644 --- a/packages/core/client/src/schema-component/antd/calendar/Calendar.tsx +++ b/packages/core/client/src/schema-component/antd/calendar/Calendar.tsx @@ -21,8 +21,8 @@ import type { ToolbarProps } from './types'; import { formatDate } from './utils'; const Weeks = ['month', 'week', 'day'] as View[]; - const localizer = dayjsLocalizer(dayjs); + export const DeleteEventContext = React.createContext({ close: () => {}, }); @@ -46,31 +46,6 @@ function Toolbar(props: ToolbarProps) { ); } -const messages: any = { - allDay: '', - previous: ( -
- -
- ), - next: ( -
- -
- ), - today: i18n.t('Today'), - month: i18n.t('Month'), - week: i18n.t('Week'), - work_week: i18n.t('Work week'), - day: i18n.t('Day'), - agenda: i18n.t('Agenda'), - date: i18n.t('Date'), - time: i18n.t('Time'), - event: i18n.t('Event'), - noEventsInRange: i18n.t('None'), - showMore: (count) => i18n.t('{{count}} more items', { count }), -}; - const useEvents = (dataSource: any, fieldNames: any, date: Date, view: (typeof Weeks)[number]) => { const { t } = useTranslation(); return useMemo(() => { @@ -214,6 +189,31 @@ export const Calendar: any = observer( }; }, [showLunar]); + const messages: any = { + allDay: '', + previous: ( +
+ +
+ ), + next: ( +
+ +
+ ), + today: i18n.t('Today'), + month: i18n.t('Month'), + week: i18n.t('Week'), + work_week: i18n.t('Work week'), + day: i18n.t('Day'), + agenda: i18n.t('Agenda'), + date: i18n.t('Date'), + time: i18n.t('Time'), + event: i18n.t('Event'), + noEventsInRange: i18n.t('None'), + showMore: (count) => i18n.t('{{count}} more items', { count }), + }; + return wrapSSR(