Composables

useLocalePath

The useLocalePath() composable returns a function that resolves a path according to the current locale.

The useLocalePath() composable returns a function that resolves a path according to the current locale.

Type

declare function useLocalePath(
  options?: I18nCommonRoutingOptionsWithComposable
): (route: RawLocation | RouteLocation, locale?: Locale) => string

Usage

<script setup>
const localePath = useLocalePath()
</script>

<template>
  <NuxtLink :to="localePath('index')">{{ $t('home') }}</NuxtLink>
</template>

Copyright © 2024