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

Custom route paths doesnt work with strategy no_prefix #2729

Closed
MickL opened this issue Jan 24, 2024 · 5 comments
Closed

Custom route paths doesnt work with strategy no_prefix #2729

MickL opened this issue Jan 24, 2024 · 5 comments

Comments

@MickL
Copy link
Contributor

MickL commented Jan 24, 2024

Environment

- Operating System: Darwin
- Node Version:     v21.2.0
- Nuxt Version:     3.9.3
- CLI Version:      3.10.0
- Nitro Version:    2.8.1
- Package Manager:  bun@1.0.21
- Builder:          -
- User Config:      devtools, css, modules, i18n, image, ignore, build
- Runtime Modules:  @nuxtjs/i18n@8.0.0, @nuxt/image@1.3.0, nuxt-icon@0.6.8
- Build Modules:    -

Reproduction

https://stackblitz.com/edit/github-bvgtxu?file=nuxt.config.ts

Describe the bug

Config:

  i18n: {
    vueI18n: './i18n.config.ts',
    strategy: 'no_prefix',
    locales: [
      {
        code: 'de',
        iso: 'de-DE',
      },
      {
        code: 'es',
        iso: 'es-ES',
      },
    ],
    customRoutes: 'config',
    pages: {
      'my-page': {
        de: '/my-page-de',
        es: '/my-page-es',
      },
    },
  },

With strategy no_prefix we have the following bugs:

  • Route /my-page is still available
  • Route /my-page-de is not available
  • Using localePath({ name: 'my-page' }) returns the /my-page instead of /my-page-de

Additional context

It works when using strategy prefix_except_default

Logs

No response

@BobbieGoede
Copy link
Collaborator

As documented, the no_prefix strategy does not support custom paths.

@BobbieGoede BobbieGoede closed this as not planned Won't fix, can't repro, duplicate, stale Jan 27, 2024
@MickL
Copy link
Contributor Author

MickL commented Feb 1, 2024

Too bad! The use case is the following:

I have a website which currently only has one language but it already uses nuxt-i18n and is prepared to be translated in the future. Right now the correct strategy to use (if I am not wrong) would be no_prefix but it does not support custom paths.

When using differentDomains: true, shouldnt also the strategy be no_prefix? This would mean that different domains and custom paths dont work together, or am I wrong?

@MickL
Copy link
Contributor Author

MickL commented Feb 9, 2024

@BobbieGoede Do you mind answering my last question? :)

When using differentDomains: true, shouldnt also the strategy be no_prefix? This would mean that different domains and custom paths dont work together, or am I wrong?

@BobbieGoede
Copy link
Collaborator

I didn't build the differentDomains support and I haven't used it myself, based on the docs (https://i18n.nuxtjs.org/options/domain) it looks like no prefixes will be added when using differentDomains, and in the code I can see a warning will be logged if no_prefix strategy is used at the same time (https://github.com/nuxt-modules/i18n/blob/main/src/module.ts#L117-L122).

From what I can gather from this is that differentDomains is a unique case in which custom paths will probably work, and that you can't use no_prefix strategy, though prefixes will not be added, I can only guess this is to ensure localized routes are generated (which would be skipped when using no_prefix).

@bezoerb
Copy link

bezoerb commented Jun 5, 2024

@MickL: it is working up to version v8.2.0 when omitting the strategy option.

See: #2705 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants