mkdocs-static-i18n icon indicating copy to clipboard operation
mkdocs-static-i18n copied to clipboard

[Bug?] 404 page not generated for selected language

Open nathancatania opened this issue 1 year ago • 3 comments

I have a site with two languages: English and Japanese.

If a user hits the 404 page when the English language is selected (English is the default), the nav and all elements switch to Japanese and the user is left on the Japanese version of the site.

This also occurs with the site for this plugin!

  1. Access the English version of the site: https://ultrabug.github.io/mkdocs-static-i18n/
  2. Click a URL (or edit the URL) that points to a page that doesn't exist, eg: https://ultrabug.github.io/mkdocs-static-i18n/w
  3. The URL will be that of the English site (and the page that doesn't exist), but the site itself will be the French version.

image

  1. Attempting to navigate away from the page results in the user being stuck on the alternative language (i.e: French) and having to use the language switcher to get back.

nathancatania avatar Dec 20 '23 06:12 nathancatania

AFAIK only one 404 page is allowed, as the web server has to load a working file with a proper error message and styling. As for why the 404 page is in French/Japanese is because it's the last language that is built, and therefore overwrites the English (initial) version.

I don't think there is an easy solution to this, because the 404 html source is rendered in another language, so even if there was some kind of working solution to remember the selected language it still wouldn't help in this case 🤔

The only solution I see right now, is to override the 404 page yourself and define your own additional logic on the JavaScript side to render the correct language, which of course I understand, isn't ideal.

kamilkrzyskow avatar Dec 20 '23 09:12 kamilkrzyskow

Same as @kamilkrzyskow this is problem is tied to MkDocs itself and the plugin can't have a generic solution for all themes either...

ultrabug avatar Feb 27 '24 11:02 ultrabug