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 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') |
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
Can i show u? Have u free time to think about it?