Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usePathname (from _i18n/navigation) return wrong path when changing locale #1804

Closed
3 tasks done
GhostvOne opened this issue Mar 20, 2025 · 1 comment
Closed
3 tasks done
Labels
bug Something isn't working unconfirmed Needs triage.

Comments

@GhostvOne
Copy link

GhostvOne commented Mar 20, 2025

Description

I'm on this page : /en/legal-mentions
When I switch the lang and navigate to /fr/mentions-legales

usePathname is returning another route (/[category_slug_plural]/[post_type] instead of /legal-mentions) :

Error: Insufficient params provided for localized pathname.
Template: /[category_slug_plural]/[post_type]
Params: undefined

If I hard refresh the page (with the same url /fr/mentions-legales) it works.

import { defineRouting } from 'next-intl/routing'

export const routing = defineRouting({
  // A list of all locales that are supported
  locales: ['en', 'fr'],

  // Used when no locale matches
  defaultLocale: 'en',

  localeDetection: true,

  pathnames: {
    '/': '/',
    '/legal-mentions': {
      en: '/legal-mentions',
      fr: '/mentions-legales',
    },
    '/[category_slug_plural]/[post_type]': {
      en: '/[category_slug_plural]/[post_type]',
      fr: '/[category_slug_plural]/[post_type]',
    },
  },
})

Verifications

Mandatory reproduction URL

https://expert-happiness-vxjqg54x6fxjvx.github.dev/

Reproduction description

Steps to reproduce:

  1. Open reproduction
  2. navigate on legal mentions
  3. switch between lang

Expected behaviour

it should return legal-mentions instead of /[category_slug_plural]/[post_type]

@GhostvOne GhostvOne added bug Something isn't working unconfirmed Needs triage. labels Mar 20, 2025
@GhostvOne
Copy link
Author

Nevermind, it's because i'm using parrallels route. Parrallels routes should have the same directories as your main directories

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working unconfirmed Needs triage.
Projects
None yet
Development

No branches or pull requests

1 participant