ultrabug / mkdocs-static-i18n

MkDocs i18n plugin using static translation markdown files
https://ultrabug.github.io/mkdocs-static-i18n/
MIT License
228 stars 38 forks source link

mkdocs-material 9, search only includes results from the default language #182

Closed kamilkrzyskow closed 1 year ago

kamilkrzyskow commented 1 year ago

Edit: I've got to the solution after some time https://github.com/ultrabug/mkdocs-static-i18n/issues/182#issuecomment-1401984264

Minimal example repository: https://github.com/kamilkrzyskow/gmc/tree/minimal-example

Search for Text and Tekst, only the first will show up as it's the English en default language.

Issue is probably related to the new mkdocs-material version 9, as it has changed the search plugin. Only tested with plugin version 0.53, tested all of 9.0.0, 9.0.1 ... 9.0.6 of mkdocs-material. Works with mkdocs-material version 8.5.11

I've also tried to run the built-in tests of the plugin, all of the test_search.py cases passed with mkdocs-material 9.

Expected behavior: image

Actual behavior: image

kamilkrzyskow commented 1 year ago

I looked over the PRs before, but I missed https://github.com/ultrabug/mkdocs-static-i18n/pull/148 🤔 Seems like it won't be an easy fix 😞 Kind of sad that the material plugin has become such a monopoly with it's Insiders features that it's diverging from MkDocs so much it breaks backwards compatibility.

kamilkrzyskow commented 1 year ago

Some progress image changing the order of plugins in the mkdocs.yml did the trick. The search plugin had to be after i18n.

kamilkrzyskow commented 1 year ago

I managed to get the expected behavior working. It turned out that the if search_plugin: check wasn't passing because the new plugin is stored under a different name, also it has a slightly different API, after getting everything in order it works, even when the search plugin is before i18n.

kamilkrzyskow commented 1 year ago

So after cleaning up my solution it's almost exactly the same as https://github.com/ultrabug/mkdocs-static-i18n/pull/148 which wasn't continued 🤔 and I don't know if you don't want to support both search plugins or if that user just didn't follow up with a solution that passed the tests 😅

My solution should work for both search plugins, and the tests available in the repository pass. ✋ So let me know if the issue is still open to discuss.

squidfunk commented 1 year ago

Kind of sad that the material plugin has become such a monopoly with it's Insiders features that it's diverging from MkDocs so much it breaks backwards compatibility.

We try to keep compatibility wherever possible. For the new search plugin, however, some breaking changes were necessary. Sometimes you need to break stuff to move things forward. The result is a much faster and more powerful search than the one that comes with MkDocs.

If somebody wants to upstream the new search into MkDocs – it is freely available now! Material for MkDocs is licensed under MIT so anybody who wants to, can copy my work and integrate it into the MkDocs search plugin 😊

ultrabug commented 1 year ago

@kamilkrzyskow thanks for your report and help. I'll eventually come to this issue and apply a proper "fix" somehow but I have other issues / fixes to release here first I'm afraid.

Please bear with me

kamilkrzyskow commented 1 year ago

@kamilkrzyskow thanks for your report and help. I'll eventually come to this issue and apply a proper "fix" somehow but I have other issues / fixes to release here first I'm afraid.

Please bear with me

Sure, I'm in no rush. I will be happy to see what a proper fix is once it releases, so thanks for your time. For now I'm using my fix posted in the comments.

kamilkrzyskow commented 1 year ago

🤔 Then again my solution passed all tests last time I checked, so it kind of works with pure MkDocs and default themes, assuming of course the tests properly checked the search feature. I'm using it with the Material with MkDocs theme both on Windows and Linux (GitHub Actions). So could you hint at what is missing @ultrabug?

Ok, I see there are more parts of the code that influence the base search plugin in different ways 🥶 Doing a Ctrl + F in the project files the other parts are related to the lang section of the plugin and adding LangOptions, as far as I know this part is still compatible in the new material plugin. Everything that is missing there is handling the other namespaces plugin name.