Fallback

Summary: Use fallbackLocale: 'lang' to choose which language to use when your preferred language lacks a translation.

Implicit fallback using locales

If the main language cannot translate something automatically, the default fallback is activated.

Example

Configuration

import { createApp } from 'vue'
import App from './App.vue'
import createMultilang from "vue3multilang"
const app = createApp(App)
const messages = {
    "en-UK":{
    },
    "ro-RO":{
        welcome:"Bine ati venit!",
    }
}
app.use(createMultilang(),{
    locale: "en-UK",
    fallbackLocale:"ro-RO",
    messages,
})
app.mount('#app')

Template

 <p>{{ $t("welcome") }}</p>

Output

The main language en-EN is not welcome and the fallback for ro-RO is automatically activated.

 <p>Bine ati venit!</p>

Last updated