Skip to content

Commit 145a5ce

Browse files
committed
feat: virtual messages hmr
1 parent 322bdb7 commit 145a5ce

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

packages/unplugin-vue-i18n/src/core/resource.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,19 @@ const mergeDeep = (target, ...sources) => {
584584
585585
export default mergeDeep({},
586586
${codes.map(code => `{${code}}`).join(',\n')}
587-
);`
587+
);
588+
589+
if(import.meta.hot) {
590+
import.meta.hot.accept(mod => {
591+
// retrieve global i18n instance
592+
const i18n = document.querySelector('#app').__vue_app__.__VUE_I18N__.global
593+
594+
// set locale messages per locale
595+
for(const locale in mod.default){
596+
i18n.setLocaleMessage(locale, mod.default[locale])
597+
}
598+
})
599+
}`
588600
}
589601

590602
async function getCode(

0 commit comments

Comments
 (0)