nextjs i18n: move position of language code in url

Viewed 15

We are working on a nextjs app with i18n. Now nextjs adds the language code in url automatically like /{language-code}/subroute/my-page. But we need it to be like /subroute/{language-code}/my-page. Is it possible through some configuration?

I checked basePath at https://nextjs.org/docs/api-reference/next.config.js/basepath, but it adds a prefix to ALL pages in the app. We just need some pages.

Also there is a so-called middleware to add custom routing rules: https://nextjs.org/docs/advanced-features/middleware. Is it possible to use it to need our needs?

0 Answers
Related