From e0e91c2c9533f22baeb44b4a54e882bb1da867a5 Mon Sep 17 00:00:00 2001 From: YANG QIA <2013xile@gmail.com> Date: Thu, 7 Dec 2023 00:02:23 +0800 Subject: [PATCH] fix(lm): texts update hook after collection update (#3151) * fix(lm): texts update hook after collection update * fix: validate language * fix: typo --- .../client/src/nocobase-buildin-plugin/plugins/LocalePlugin.ts | 2 ++ packages/core/client/src/user/LanguageSettings.tsx | 1 - .../plugin-localization-management/src/server/plugin.ts | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) 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 8bee2828d..be904219c 100644 --- a/packages/core/client/src/nocobase-buildin-plugin/plugins/LocalePlugin.ts +++ b/packages/core/client/src/nocobase-buildin-plugin/plugins/LocalePlugin.ts @@ -3,6 +3,7 @@ import dayjs from 'dayjs'; import { loadConstrueLocale } from '../../antd-config-provider/loadConstrueLocale'; import { Plugin } from '../../application/Plugin'; import { dayjsLocale } from '../../locale'; +import { setValidateLanguage } from '@formily/validator'; export class LocalePlugin extends Plugin { locales: any = {}; @@ -27,6 +28,7 @@ export class LocalePlugin extends Plugin { Object.keys(data?.data?.resources || {}).forEach((key) => { this.app.i18n.addResources(data?.data?.lang, key, data?.data?.resources[key] || {}); }); + setValidateLanguage(data?.data?.lang); loadConstrueLocale(data?.data); const dayjsLang = dayjsLocale[data?.data?.lang] || 'en'; await import(`dayjs/locale/${dayjsLang}`); diff --git a/packages/core/client/src/user/LanguageSettings.tsx b/packages/core/client/src/user/LanguageSettings.tsx index a0f1dc8a9..092e9da7b 100644 --- a/packages/core/client/src/user/LanguageSettings.tsx +++ b/packages/core/client/src/user/LanguageSettings.tsx @@ -33,7 +33,6 @@ export const useLanguageSettings = () => { }, }); api.auth.setLocale(lang); - await i18n.changeLanguage(lang); window.location.reload(); }} /> diff --git a/packages/plugins/@nocobase/plugin-localization-management/src/server/plugin.ts b/packages/plugins/@nocobase/plugin-localization-management/src/server/plugin.ts index b049f7a37..265d3969b 100644 --- a/packages/plugins/@nocobase/plugin-localization-management/src/server/plugin.ts +++ b/packages/plugins/@nocobase/plugin-localization-management/src/server/plugin.ts @@ -96,7 +96,7 @@ export class LocalizationManagementPlugin extends Plugin { this.db .getModel('localizationTexts') .bulkCreate( - texts.map((text) => ({ + texts.map(({ text, module }) => ({ module, text, })),