ultrabug / mkdocs-static-i18n

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

Problem with search plugin #98

Closed champsblanc closed 2 years ago

champsblanc commented 2 years ago

Hi, is there a way to disable this default behavior?

If you enabled the search plugin embedded with MkDocs, this plugin will automatically populate its lang option with the configured languages as long as they are supported by lunr.

Our search index is getting too large (with 2 languages) for our server to handle and we're having some issues.

We thought another way to do it would be to use mkdocs-exclude-search to exclude es/* files from the index but we can't make it work. I can ask there too if it should be compatible.

Thanks!

ultrabug commented 2 years ago

hello @sirchampsblanc ; so your goal is to have the search index built only for the default language and not for any other language, is that right?

champsblanc commented 2 years ago

hello @sirchampsblanc ; so your goal is to have the search index built only for the default language and not for any other language, is that right?

Yeah, that's it.

mondeja commented 2 years ago

Hi @ultrabug.

I've faced with a related problem in the development of mkdocs-mdpo-plugin. Seems that an internationalization plugin must be able to split search indexes by language, beyond than only searching across the main language.

It is not a simple problem I guess because some files must be patched depending on the theme. In summary, you need to build a search index for each language, replacing the main search index loaded by the theme because it does not make sense to make cross language searches. I've ended creating a patcher class which works for the default themes and mkdocs-material. We can join forces to separate the mkdocs-mdpo code if you find it useful, but I'm not sure if you can use it as is in mkdocs-static-i18n.

Anyways, ask me anything if I can help you. Cheers!

ultrabug commented 2 years ago

Thanks for the heads-up @mondeja ; I find that helper class intimidating tbh.

I'm not very keen on starting to do magic directly on themes files structure because this will endlessly tie us to their evolution and breaking changes. Maybe what we should do instead is to propose to those theme upstreams to add a configuration option for their search index file lookup?

@sirchampsblanc I think I'm gonna add a configuration option so that you can disable the feature in the meantime.

champsblanc commented 2 years ago

Thanks for the heads-up @mondeja ; I find that helper class intimidating tbh.

I'm not very keen on starting to do magic directly on themes files structure because this will endlessly tie us to their evolution and breaking changes. Maybe what we should do instead is to propose to those theme upstreams to add a configuration option for their search index file lookup?

@sirchampsblanc I think I'm gonna add a configuration option so that you can disable the feature in the meantime.

We've patched it manually but that feature should be useful for us and maybe other projects.

Thanks.