Skip to content

Instantly share code, notes, and snippets.

@titusdecali
Last active December 28, 2021 22:46
Show Gist options
  • Save titusdecali/4ec3cdd8e8ce54e5e65785001d44d6aa to your computer and use it in GitHub Desktop.
Save titusdecali/4ec3cdd8e8ce54e5e65785001d44d6aa to your computer and use it in GitHub Desktop.
Vue3 i18n main.js setup
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')
@ATLANT-Z
Copy link

Can i show u? Have u free time to think about it?

@demircancelebi
Copy link

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