Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

You are running the esm-bundler build of vue-i18n. It is recommended to configure your bundler to explicitly replace feature flag globals with

I have created an ionic app and added vue-i18n.

npx ionic start myapp tabs --type vue
npm install vue-i18n@next

I did the very first step of the VueI18n setup and added this to "./src/main.ts":

import { createI18n } from 'vue-i18n';

const i18n = createI18n({
  locale: 'de',
  fallbackLocale: 'en',
  messages: {en: {testMessage: 'Test message'}, de: {testMessage: 'Testnachricht'}}
});

When looking at the result after npx ionic serve I get the following warning in the browser console:

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.

And I get this info in the browser console:

You are running a development build of vue-i18n. Make sure to use the production build (*.prod.js) when deploying for production.

When I comment out the snippet added to "./src/main.ts" both the notifications disappear. So they really seem to be caused by vue-i18n.

After asking Google I still don't know what to do about these notifications. What are they telling me? Should I do something about them? What can I do specifically?

These are the files that were automatically created in the root folder of the new project:

./ionic.config.json
./cypress.json
./jest.config.js
./babel.config.js
./.gitignore
./package-lock.json
./package.json
./.eslintrc.js
./tsconfig.json
./capacitor.config.json
./.browserslistrc

Please also tell me where I would need to change something. Also

$ find . -type f ! -name package-lock.json -maxdepth 1 -exec grep -iH webpack {} \;
./tsconfig.json:      "webpack-env",

so I will not know what to do if you tell me to "just set up webpack properly".

like image 796
jonas Avatar asked Feb 10 '21 16:02

jonas


People also ask

How do I change my locale on Vue i18n?

Since $i18n. locale is bound with v-model , you can switch it by selecting the option of the select element, which sets its value to $i18n. locale . As you can see, the global scope is very useful because it allows you to switch the messages displayed in the UI for all components of the application at once.

How do I use i18n in setup Vue 3?

Basic Usage To compose with useI18n in setup of Vue 3, there is one thing you need to do, you need set the legacy option of the createI18n function to false . The following is an example of adding the legacy option to createI18n : // ... // 2. Create i18n instance with options const i18n = VueI18n.

What is i18n in Vue?

Vue I18n is internationalization plugin of Vue. js. It easily integrates some localization features to your Vue. js Application.


3 Answers

Now i am using this way to import the i18n, the warning is disapear

import { createI18n } from 'vue-i18n/index'
like image 173
KK Liu Avatar answered Nov 09 '22 16:11

KK Liu


vue-i18n has instructions for every bundler how to set global feature flags so this warning will go away

https://vue-i18n.intlify.dev/guide/advanced/optimization.html#reduce-bundle-size-with-feature-build-flags

I'm using Vite, and I added this to vite.config.ts

import { defineConfig } from 'vite';

export default defineConfig({
    define: {
        __VUE_I18N_FULL_INSTALL__: true,
        __VUE_I18N_LEGACY_API__: false,
        __INTLIFY_PROD_DEVTOOLS__: false,
    },
    // ...
});
like image 22
iamandrewluca Avatar answered Nov 09 '22 16:11

iamandrewluca


This is a known bug apparently. They say it will be fixed in the 9.2 version.

See more info in this thread: https://github.com/intlify/vue-i18n-next/issues/391

like image 5
Nifel Avatar answered Nov 09 '22 18:11

Nifel