0👍
✅
import(/* webpackChunkName: "lang-[request]" */ `~/lang/${locale}`)
is a Webpack Async Import, so it will be loaded after your main app script is loaded, not at the same time.
I will recommend two solution (pick the one that suits you better):
- remove your
loadMessages
functions and load all Json-s synchronously. The app bundle will grow (all translations will be inside) but it will load them on the app start. - Delay router creation (
router = new Router(...)
) until all the locales are loaded (loadMessages
finished).
Source:stackexchange.com