You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now it shows error Uncaught (in promise) EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "default-src 'self' 'unsafe-inline'".
For this error , I guess I should use runtime build of vue-i18n
/// webpack.config.jsresolve: {alias: {// Suppress warning "You are running the esm-bundler build of vue-i18n. It is recommended to configure your bundler to explicitly replace feature flag globals with boolean literals to get proper tree-shaking in the final bundle."// https://github.com/intlify/vue-i18n-next/issues/219// https://vue-i18n.intlify.dev/installation.html#with-a-bundler"vue-i18n": "vue-i18n/dist/vue-i18n.runtime.esm-bundler.js",// No `CSP eval` warning, but still has `esm-bundle` warning.// "vue-i18n": "vue-i18n/dist/vue-i18n.runtime.esm-browser.prod.js", // No `CSP eval` nor `esm-bundle` warning anymore, but all warning I need to read for dev are also be omitted.}},
[[[ 2.5. warning esm-bundler ]]]
This issue seems little against the topic, but still need to mention and have a reference.
Simultaneously, vue-i18n warns me You are running the esm-bundler build of vue-i18n. It is recommended to configure your bundler to explicitly replace feature flag globals with boolean literals to get proper tree-shaking in the final bundle. (issue #254 ? #219 ?)
This warning message seems can be omitted if use runtime + prod build, however, all warning message I need during development are also be wiped away... I don't know how to omit only the esm-bundle warning.
[[[ 3. vue-i18n says it need pre-compiled message instead of JSON ]]]
Now it shows warning [intlify] The message format compilation is not supported in this build. Because message compiler isn't included. You need to pre-compilation all message format. So translate function return 'title.window'.
So I guess I should use vue-i18n-loader to compile json files into functions:
/// webpack.config.js
module: {rules: [{test: /\.(json5?|ya?ml)$/,// target json, json5, yaml and yml filestype: 'javascript/auto',loader: '@intlify/vue-i18n-loader',include: [// Use `Rule.include` to specify the files of locale messages to be pre-compiledpath.resolve(__dirname,'i18n/dist')]},}
/// i18n.tsimportenObjfrom'../../i18n/dist/en-US/main.json'exporttypelanguage_t='en-US'|'zh-TW'|'ja-JP'exportconstALL_LANG_KEY: language_t[]=['en-US','zh-TW','ja-JP']// our default language that is preloadedexportconstDEFAULT_LANGUAGE: language_t='en-US'exportconsti18n=createI18n({legacy: false,globalInjection: true,locale: DEFAULT_LANGUAGE,// set localefallbackLocale: DEFAULT_LANGUAGE,messages: {[DEFAULT_LANGUAGE]: enObj},})exportfunctionloadLangFileAsync<T>(langId: language_t): Promise<boolean>{if(i18n.global.locale.value!==langId){returnimport(/* webpackChunkName: "lang-[request]" */`../../i18n/dist/${langId}/main.json`).then(jsonObj=>{i18n.global.setLocaleMessage(langId,jsonObj)i18n.global.locale.value=langreturntrue})}returnPromise.resolve(false)}
[[[ 4. (Stuck) ]]]
Terrible, seems all translation files cannot be loaded correctly now.
shared.esm-bundler.js:54 [intlify] Not found 'title.window' key in 'en-US' locale messages.
shared.esm-bundler.js:54 [intlify] Fall back to translate 'title.window' key with 'en' locale.
shared.esm-bundler.js:54 [intlify] Not found 'title.window' key in 'en' locale messages.
shared.esm-bundler.js:54 [intlify] Not found 'title.window' key in 'en-US' locale messages.
shared.esm-bundler.js:54 [intlify] Fall back to translate 'title.window' key with 'en' locale.
shared.esm-bundler.js:54 [intlify] Not found 'title.window' key in 'en' locale messages.
I don't sure if the vue-i18n-loader work correctly, at least the file appeared in devtools:
Now I stuck here... Unable to find any way to get out of here...
The text was updated successfully, but these errors were encountered:
Aaahh, I should use npm i -D vue-i18n-loader@next instead of 1.x release... Is this possible to give user a warning about this when installing or runtime?
vue & vue-i18n version
ex:
webpack.config.js
manually, instead of usevue-cli
'svue.config.js
. I don't sure if this is related to theimport
ofen-US/main.json
)Steps to reproduce
Story is a little long, I will manage to make this story easy to read and comprehensible...
[[[ 0. init ]]]
At beginning, vue-i18n works well.
[[[ 1. Error from Electron CSP ]]]
I'm using Vue I18n under Electron, it always give CSP warning:
so I have to turn
unsafe-eval
off:[[[ 2.
vue-i18n
says it cannot eval() ]]]Now it shows error
Uncaught (in promise) EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "default-src 'self' 'unsafe-inline'".
For this error , I guess I should use
runtime
build ofvue-i18n
[[[ 3.
vue-i18n
says it need pre-compiled message instead of JSON ]]]Now it shows warning
[intlify] The message format compilation is not supported in this build. Because message compiler isn't included. You need to pre-compilation all message format. So translate function return 'title.window'.
So I guess I should use vue-i18n-loader to compile json files into functions:
[[[ 4. (Stuck) ]]]
Terrible, seems all translation files cannot be loaded correctly now.
I don't sure if the
vue-i18n-loader
work correctly, at least the file appeared in devtools:Now I stuck here... Unable to find any way to get out of here...
The text was updated successfully, but these errors were encountered: