Composables

defineI18nConfig

The defineI18nConfig() composables is used to define a function which returns the vue-i18n configuration which is passed to the createI18n() options on the Nuxt I18n module.

The defineI18nConfig() composables is used to define a function which returns the vue-i18n configuration which is passed to the createI18n() options on the Nuxt I18n module.

The loader function needs to return a Function or Promise that resolves a vue-i18n options object.

For more details on configuring vue-i18n, see the Vue I18n documentation.

Type

export function defineI18nConfig<Config extends I18nOptions>(
  loader: () => Config | Promise<Config>
): () => Config | Promise<Config>

Parameters

loader

A function that is the vue-i18n options loading.

Usage

An example defining a simple vue-i18n options object:

export default defineI18nConfig(() => ({
  legacy: false,
  locale: 'en',
  messages: {
    en: {
      welcome: 'Welcome'
    },
    fr: {
      welcome: 'Bienvenue'
    }
  }
}))

Copyright © 2024