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

English pages shows in the Swedish menu #161

Open
tirithen opened this issue Nov 23, 2022 · 4 comments
Open

English pages shows in the Swedish menu #161

tirithen opened this issue Nov 23, 2022 · 4 comments

Comments

@tirithen
Copy link

I'm working on a mkdocs site using this plugin. It solves a lot around localization, but when there is a file called my-page.en.md but NO my-page.sv.md the Swedish menu will list the English page (as a fallback?).

I would like it to only include the pages that has translations, and skip the other pages.

How can I configure i18n to do this?

@ultrabug
Copy link
Owner

ultrabug commented Dec 1, 2022

Hello @tirithen ; indeed the design of this plugin is to always fallback to the default language because MkDocs itself has a build system that needs to create a navigation from a main directory tree (docs_dir).

So while you could have pages in Swedish that do not have a translation at all, you cannot avoid the fallback so far.

This could MAYBE be doable that being said but would require deep analysis and quite some time..

@tirithen
Copy link
Author

tirithen commented Dec 2, 2022

It would have been very nice with an option flag so that the user could choose whether or not it should use a fallback language or not, as the end user that visits the page might not understand the language that they get presented with, and it therefore would have been better to not generate these fallback pages in the first place. It could have been an opt-in feature to not have it being a breaking change.

For now I will go for generating multiple sites instead of using this plugin as the solution I'm working on cannot have mixed languages.

Thank you for taking the time to answer!

The other features of this plugin is really nice and intuitive, such as the file name language suffixes, and sending the user to the same page when selecting a new language from the menu. :)

@ultrabug
Copy link
Owner

ultrabug commented Dec 9, 2022

Thanks for this input @tirithen ; in your opinion what should happen in the given situations if where were to have an opt in configuration flag to disable default language fallback?

  1. the homepage of the site has no translation
  2. the mkdocs.yml lists a static nav: with non translated pages

Thanks for your kind words, I'm happy you considered using this plugin

@tirithen
Copy link
Author

@ultrabug

I think that one clear option is to fail the build in both cases, putting an error message to the user that there are references to non-existing pages. It does not have to be a bad thing as if an index page is missing it would probably a pretty serious issue for the visitors of the website. Another advantage is that with good clear error messages this makes the behavior of the build command more clear and easy to understand for authors.

There are other possible variations where a missing index page would add an empty page, and missing pages listed under the nav: config might be silently excluded. But I'm thinking that this might lead to authors missing out on the configuration problem.

If you would go for the more strict configuration, the configuration flag could possible be called something like "strict" or similar rather than "disable language fallback" as well.

As the behavior is deterministic, and the cause of the error is clear I as a user would see no problem with the mkdocs build command failing to output any HTML as the website would anyway have had invalid or missing text content if the build would have continued running.

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

No branches or pull requests

2 participants