Locale duplication in URL when switching languages via the dropdown
Which Fern component?
Fern Docs
How urgent is this?
P2 - Medium (Would be helpful)
What's the issue?
Testing out @chdeskur 's recent internationalization commits. Really excited to get this to work!
Steps to reproduce:
- Create a new repo with the docs-starter template: https://github.com/fern-api/docs-starter
- Add languages to the docs.yml:
languages:
- en
- es
- fr
- Run
fern write-translation - Run
fern docs dev - change language multiple times
https://github.com/sameggert/fern-language-dropdown-issue
Expected Behavior:
The dropdown will redirect to a new url with the most recently selected locale:
localhost:3000/en/welcome
localhost:3000/es/welcome
localhost:3000/fr/welcome
Actual Behavior:
The dropdown will insert the locale code, but not remove the previous ones.
localhost:3000/welcome
localhost:3000/es/welcome
localhost:3000/fr/es/welcome
localhost:3000/es/fr/es/welcome
localhost:3000/en/es/fr/es/welcome
https://github.com/user-attachments/assets/5342f482-59ad-4e6d-a97e-f3924f1695f4
Environment:
- OS: macOS Sequoia v15.6.1
- Node.js version: v22.20.0
- Browser: Chrome Version 142.0.7444.135 (Official Build) (arm64)
Fern CLI & Generator Versions
Fern CLI: v0.121.0
Workaround
Using 'versions' in the docs.yml instead will properly redirect to the correct locale, but will not include translations to the hardcoded fern ui, and will not work on docs that are already using versions.
versions:
- display-name: 🇺🇸 English
path: ./en.yml
slug: en
- display-name: 🇪🇸 Español
path: ./translations/es.yml
slug: es
An example of an internationalized starter app using versions:
https://github.com/SamEggert/fern-11-9/tree/main/fern
Are you interested in contributing a fix?
Yes
Addressed in this PR - will be released on the next docs release tag: https://github.com/fern-api/fern-platform/pull/5178