Last active
December 28, 2021 22:46
-
-
Save titusdecali/4ec3cdd8e8ce54e5e65785001d44d6aa to your computer and use it in GitHub Desktop.
Vue3 i18n main.js setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { createApp } from 'vue' | |
| import App from './App.vue' | |
| // i18n | |
| import I18n from './i18n.js' | |
| const i18n = createI18n({ | |
| locale: | |
| localStorage.getItem('lang') || | |
| // Detect user's browser language | |
| I18n.detectLanguage() || | |
| process.env.VUE_APP_I18N_LOCALE, | |
| fallbackLocale: process.env.VUE_APP_I18N_FALLBACK_LOCALE || 'ko', | |
| // Load selected lang's .json file | |
| messages: I18n.loadLocaleMessages() | |
| }) | |
| const app = createApp(App) | |
| app.use(i18n) | |
| app.mount('#app') |
Author
Can i show u? Have u free time to think about it?
For people coming this far, you need to run npm install vue-i18n@next to be able to import { createI18n } from 'vue-i18n'
https://vue-i18n.intlify.dev/guide/migration/breaking.html
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If it’s a string, the @ shouldn’t matter. It’s hard to say what went wrong without seeing the code directly.