Api

编译器宏

Nuxt i18n 模块的编译器宏

defineI18nRoute

defineI18nRoute 是一个编译器宏,您可以使用它为位于 pages/ 目录中的 页面 组件设置自定义路由路径(除非 另有设置)。通过这种方式,您可以为 Nuxt 应用程序的每个静态或动态路由设置自定义路由路径。

pages/some-page.vue
<script setup>
defineI18nRoute({
  paths: {
    en: '/about-us',
    fr: '/a-propos',
    ja: '/about-ja'
  }
})
</script>

类型

defineI18nRoute(route: I18nRoute | false) => void

interface I18nRoute {
  paths?: Record<string, string>
  locales?: string[]
}

参数

false

禁用目标页面组件路由的本地化。

I18nRoute

一个接受以下 i18n 路由设置的对象:

  • paths
    • 类型: Record<Locale, string>
      按区域设置自定义页面组件路由。您可以为 vue-router 指定静态和动态路径。
  • locales
    • 类型: string[]
      页面组件应本地化的一些区域设置。