Guide

Locale fallback

How a fallback gets selected when a translation is missing.

Nuxt i18n module takes advantage of Vue I18n ability to handle localization fallback. It is possible to define a single fallback locale, an array of locales, or a decision map for more specific needs.

i18n.config.ts
export default {
  fallbackLocale: 'en',
  // or
  fallbackLocale: ['en', 'fr'],
  // or
  fallbackLocale: {
    'de-CH': ['fr', 'it'],
    'zh-Hant': ['zh-Hans'],
    'es-CL': ['es-AR'],
    es: ['en-GB'],
    pt: ['es-AR'],
    default: ['en', 'da']
  }
  // ...
}

More information in Vue I18n documentation


Copyright © 2024