fix: update the locale file requires a reboot

This commit is contained in:
chenos 2024-03-25 09:46:45 +08:00
parent 88d1bdbefb
commit aa6e753b35
2 changed files with 7 additions and 1 deletions

View File

@ -67,6 +67,9 @@ export class Locale {
async getCacheResources(lang: string) {
this.resourceCached.set(lang, true);
if (process.env.APP_ENV !== 'production') {
await this.cache.reset();
}
return await this.wrapCache(`resources:${lang}`, () => this.getResources(lang));
}

View File

@ -25,7 +25,10 @@ export const getResource = (packageName: string, lang: string, isPlugin = true)
for (const prefix of prefixes) {
try {
const file = `${packageName}/${prefix}/locale/${lang}`;
require.resolve(file);
const f = require.resolve(file);
if (process.env.APP_ENV !== 'production') {
delete require.cache[f];
}
const resource = requireModule(file);
resources.push(resource);
} catch (error) {