fix(lm): texts update hook after collection update (#3151)

* fix(lm): texts update hook after collection update

* fix: validate language

* fix: typo
This commit is contained in:
YANG QIA 2023-12-07 00:02:23 +08:00 committed by GitHub
parent 3b324f31a2
commit e0e91c2c95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 2 deletions

View File

@ -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}`);

View File

@ -33,7 +33,6 @@ export const useLanguageSettings = () => {
},
});
api.auth.setLocale(lang);
await i18n.changeLanguage(lang);
window.location.reload();
}}
/>

View File

@ -96,7 +96,7 @@ export class LocalizationManagementPlugin extends Plugin {
this.db
.getModel('localizationTexts')
.bulkCreate(
texts.map((text) => ({
texts.map(({ text, module }) => ({
module,
text,
})),