Skip to content

UNavigationMenu lacks built-in support for localized routes (i18n) #4465

Open
@al1maher

Description

@al1maher

Environment

  • Operating System: Windows_NT
  • Node Version: v22.12.0
  • Nuxt Version: 3.17.4
  • CLI Version: 3.25.1
  • Nitro Version: 2.11.12
  • Package Manager: npm@10.9.0
  • User Config: compatibilityDate, devtools, ssr, future, app, css, modules, build, vite, eslint, i18n, runtimeConfig, experimental, imports
  • Runtime Modules: @nuxt/eslint@1.4.1, @nuxt/test-utils@3.19.1, @nuxt/ui@3.2.0, @nuxtjs/i18n@9.5.5

Is this bug related to Nuxt or Vue?

Nuxt

Version

v3.2.0

Reproduction

https://codesandbox.io/p/devbox/nuxt-ui3-n3sxks

Description

The UNavigationMenu component doesn't have built-in support for generating localized routes when using @nuxtjs/i18n. When using locale prefixes (e.g., /en/dashboard, /ar/dashboard), the navigation items don't automatically adapt to the current locale.

Expected behavior:

The component should automatically handle locale prefixes when @nuxtjs/i18n is configured, similar to how works with localePath().

Proposed solution:

Auto-detect @nuxtjs/i18n configuration
Apply localePath() internally to to props
Add optional localized prop for explicit control
Maintain backward compatibility

This would eliminate boilerplate code and improve DX for internationalized applications using Nuxt UI navigation components.

Additional context

Current Workaround Required:

<script setup>
const { locale } = useI18n()

// Manual helper function needed
const getLocalizedRoute = (path) => {
  if (locale.value === 'ar') {
    return `/example/ar${path}`
  }
  return `/example${path}`
}

const sidebarItems = computed(() => [
  [{
    label: 'Dashboard',
    icon: 'i-lucide-home',
    to: getLocalizedRoute('/dashboard/'), // Manual localization
  }]
])
</script>

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriagev3#1289

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions