Composables

useSetI18nParams

The useSetI18nParams() returns a function to set translated parameters for the current route. For more details on its usage see the Lang Switcher guide.

The useSetI18nParams() returns a function to set translated parameters for the current route. For more details on its usage see the Lang Switcher guide.

Type

declare function useSetI18nParams(options?: SeoAttributesOptions): (locale: Record<Locale, unknown>) => void

Parameters

options

Type: SeoAttributesOptions | undefined

An SeoAttributesOptions object, default undefined. See the SEO guide for more details.

Usage

<script setup>
// fetch product from API... (red mug)

const setI18nParams = useSetI18nParams({
  canonicalQueries: ['foo']
})
setI18nParams({
  en: { slug: data.slugs.en }, // slug: 'red-mug'
  nl: { slug: data.slugs.nl } // slug: 'rode-mok'
})

const switchLocalePath = useSwitchLocalePath()
switchLocalePath('en') // /products/red-mug
switchLocalePath('nl') // /nl/products/rode-mok
</script>

<template>
  <!-- pages/products/[slug].vue -->
</template>

Copyright © 2024