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

Search plugin just works for the default language #31

Closed
Caetan95 opened this issue Jun 4, 2021 · 5 comments
Closed

Search plugin just works for the default language #31

Caetan95 opened this issue Jun 4, 2021 · 5 comments

Comments

@Caetan95
Copy link

Caetan95 commented Jun 4, 2021

Hello again. Sorry for the inconvenience, but we found another problem in the plugin, now is the integration with the search plugin. The thing is that the search function only works with the default language, so when we are in a different language it searches only in the default language, ignoring the other languages. I think the problem is with the plugin itself, which is maybe disabling something that the search plugin needs, as long as for example this other one works.

Do you know what the problem could be and if it is easy to solve?

Thank you very much.

@ultrabug
Copy link
Owner

ultrabug commented Jun 4, 2021

@Caetan95 hi; sure it should not be a problem if you can provide me with an example and what you expect from it?

@Caetan95
Copy link
Author

Caetan95 commented Jun 4, 2021

Thanks for your quick reply @ultrabug we really appreciate it.

I would expect to search in each language separately, so depending on which language I am, it will search into it.

Currently, the behavior is that it always searches in the default language (in your example, in English), and if I change to français it will continue searching in the English version. In addition, if I search for some French word (in the French version) that is present in the text it can't find anything, since as far as I understand it just searches into English files (the default language) without taking into account the language that is currently selected.

1. English language search
image

2. French language search (no results)
image

3. French language search (searching for English stuff)
image

So taking into account this example, I would expect that 2. French language search (no results) shows some results (as the word décrite appears in the files) and it would be nice too that 3. French language search (searching for English stuff) doesn't show any results from other languages (just the selected one, which is French in this screenshot), but maybe this last one is not as critical as the second one, the French language search with no results (by extension all languages that are not the default).

I would like to thank you again for your collaboration :)

@ultrabug
Copy link
Owner

ultrabug commented Jun 9, 2021

FYI @Caetan95 the way the search plugin is implemented prevents us from having a search index per language.

I'm almost done with this, it works good on mkdocs 1.1.2 but not on 1.2... looking into it now.

@Caetan95
Copy link
Author

Caetan95 commented Jun 9, 2021

Hello @ultrabug, thanks for your commitment. Just FYI, I have been testing the new mkdocs 1.2 release with your plugin and I haven't found any other conflict (apart from those that we have already discuss).

Thanks again for your work :)

ultrabug added a commit that referenced this issue Jun 9, 2021
Search results will include all the pages from all the localized contents.

This means that your search results can't be contextual to the language
you are currently browsing.

The `mkdocs-static-i18n` plugin will try to be smart and deduplicate the
pages from the `default_language` so that search results are not polluted.

This is because the MkDocs `search` plugin is hardcoded in the themes
javascript sources so there can only be one search index for the whole
build.
@ultrabug
Copy link
Owner

ultrabug commented Jun 9, 2021

version 0.15 is out mate, thanks!

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