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

Language selector (i18n) points to missing URLs #4347

Open
Peque opened this issue Nov 8, 2024 · 0 comments
Open

Language selector (i18n) points to missing URLs #4347

Peque opened this issue Nov 8, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@Peque
Copy link

Peque commented Nov 8, 2024

Describe the bug

If you are navigating https://example.com/en/foo/bar and have another language es configured, the language selector would link to https://example.com/es/foo/bar.

This is fine as long as /es/foo/bar exists. But this does not need to be always the case. Even with complete translations, there are some pages that are localized and only make sense in certain languages.

For those cases, the language selector should link to the first parent directory that exists (i.e.: /es/foo/ or /es/).

Reproduction

Create a project with internationalization and have one page available in one language (/en/), but not available in another language (/es/). Visit the English version and, from the drop-down language selector, the /es/ page would be linked for the Spanish version of the site, even if that page does not exist.

Expected behavior

The language selector should not link to pages that do not exist. For those cases, it could use the first existing parent or just link to the top-level language URL (i.e: /es/).

System Info

System:
    OS: Linux 6.11 Fedora Linux 39 (Container Image)
    CPU: (8) x64 Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz
    Memory: 8.19 GB / 15.54 GB
    Container: Yes
    Shell: 5.2.15 - /bin/bash
  Binaries:
    Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node
    npm: 10.2.3 - ~/.nvm/versions/node/v20.10.0/bin/npm
  npmPackages:
    vitepress: ^1.5.0 => 1.5.0


### Additional context

_No response_

### Validations

- [X] Check if you're on the [latest VitePress version](https://github.com/vuejs/vitepress/releases/latest).
- [X] Follow our [Code of Conduct](https://vuejs.org/about/coc.html)
- [X] Read the [docs](https://vitepress.dev).
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
@Peque Peque added the bug: pending triage Maybe a bug, waiting for confirmation label Nov 8, 2024
@brc-dd brc-dd added enhancement New feature or request and removed bug: pending triage Maybe a bug, waiting for confirmation labels Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants