readthedocs / sphinx_rtd_theme

Sphinx theme from Read the Docs
https://sphinx-rtd-theme.readthedocs.io/
MIT License
4.81k stars 1.74k forks source link

Language switching redirects to home page instead of the current page's translation #1628

Open Hyrla opened 2 weeks ago

Hyrla commented 2 weeks ago

Problem

Since migrating to Sphinx RTD Theme 3.0, switching language redirects the user to the doc's home page instead of displaying the current page's translation. This used to work properly on 2.0.

Reproducible Project

Example page: https://esieabot.readthedocs.io/fr/latest/assemble/esieabot/esieabot-2024/esieabot-2024.html (the issue is the same with every page)

Expected Results

I am expecting to display current page's translation when switching language, like it used to be. Is there a new setting to mitigate that?

Environment Info

humitos commented 2 weeks ago

Isn't this issue a duplicated of https://github.com/readthedocs/sphinx_rtd_theme/issues/1621?

Hyrla commented 2 weeks ago

Isn't this issue a duplicated of #1621?

I am sorry if my issue is not clear. It is a different issue here. Previously, if I switched language while I am reading a page in French, I was redirected to the same page in English (it's the same URL, but /fr/ was replaced by /en/). With the last version, switching language redirects to the home page instead of the current page translated in another language.

humitos commented 2 weeks ago

Gotcha, thanks for the extra details.

It seems we will need to replicate the chunk of code we added to addons that reads the readthedocs-resolver-filename META tag and appends it to the link:

https://github.com/readthedocs/addons/blob/0f025e3bf604f96506aebf2af120b4c20d02fde8/src/utils.js#L211-L241

Hyrla commented 2 weeks ago

Thank you. Do you need any more details?