-
-
Notifications
You must be signed in to change notification settings - Fork 350
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Asynchronously import()
multiple translation files & merge them in runtime build?
#452
Comments
Hmmm... I just found use Promise.all([
import(/* webpackChunkName: "main-lang-[index]" */ `../i18n/dist/${langId}/main.json`),
import(/* webpackChunkName: "ui-lib-lang-[index]" */ `../ui-lib/i18n/${langId}.json`),
]).then(([mainObj, uiObj]) => {
Object.assign(mainObj.default, uiObj.default) // Merge!
i18n.global.setLocaleMessage(langId, mainObj.default)
i18n.global.locale.value = langId
return true
}).catch(() => {
return false
}) |
Thank you for your feedback! Have you tried to use Perhaps using it will help you solve your problem, I think. |
Ahh... It works! Thanks!
I've noticed another issue is that I don't sure if it is
|
I'm happy to hear it.
Thank you for your feedback! algolia/docsearch-configs#3957 Thanks! |
Is your feature request related to a problem? Please describe.
I'm wondering if
vue-i18n
is able to asynchronously load (import(...).then(...)
) multiple i18n files, under a CSP environment such as Electron? (#381, installation, optimization)Within CSP limitation, only
vue-i18n.runtime.esm-bundler.js
is available; but this one can load compiled i18n message object.That is to say:
runtime
buildvue-i18n
.vue-i18n-loader
to compile*.json
i18n files. (I guess... Because it seems I cannot merge a compiled i18n file?)import()
translation JSON objects, then merge them in runtime (?)Describe the solution you'd like
Describe alternatives you've considered
vue-i18n
forvue3
requires a compiled message ES module object instead of plain JSON object. To make*.ts
/*.js
able to be as message object?)vue-i18n.runtime.esm-bundler.js
? (I've checked@intlify/message-compiler
but it seems only to output plaintext file?)Additional context
Just a note, maybe useful to others / documentation: I'm curious that how to / what is the best practice to lazy load needed part of i18n file in a large scale application?
For example,
store/book
should load../i18n/${langId}/book.json
only,store/food
is../i18n/${langId}/food.json
, andstore/3c
is../i18n/${langId}/3c.json
...etc.The text was updated successfully, but these errors were encountered: