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 does not work in french language #1745

Closed
3 of 4 tasks
kevung opened this issue Jun 6, 2020 · 11 comments
Closed
3 of 4 tasks

Search does not work in french language #1745

kevung opened this issue Jun 6, 2020 · 11 comments

Comments

@kevung
Copy link

kevung commented Jun 6, 2020

I checked that...

  • ... the documentation does not mention anything about my problem
  • ... the problem doesn't occur with the default MkDocs template
  • ... the problem is not in any of my customizations (CSS, JS, template)
  • ... there are no open or closed issues that are related to my problem

Description

Search word in with mkdocs-material fir french language does not work properly

Expected behavior

Simple word such as 'plage' should be found.
Accented words are not consistently found.

Actual behavior

'plag' is found, but not 'plage'

Steps to reproduce the bug

  1. Install mkdocs-material (5.2.2)
  2. Use this mkdocs.yml file:
site_name: My Docs
theme:
  name: material
  language: fr

plugins:
  - search

and this ./docs/index.md

Cet été ensoleillé, nous irons à la plage.
  1. serve mkdocs (python -m mkdocs serve) and search for plage.

Package versions

  • Python: `3.8.3
  • MkDocs: 1.1.2
  • Material: 5.2.2

Project configuration

site_name: My Docs
theme:
  name: material
  language: fr

plugins:
  - search

System information

  • OS: Linux 5.6.15-arch1-1 x86_64 GNU/Linux
  • Browser: firefox
@squidfunk
Copy link
Owner

As already noted in #419, it's very likely related to #1603 and #1675. Please, see the comments on these issues.

@kevung
Copy link
Author

kevung commented Jun 6, 2020

@squidfunk Thank you very for your reply. I will just put here some simple tests here.
Here are the following tests I made. I use each time the same ./docs/index.md file:

Cet été ensoleillé, nous irons à la plage.

I want to search the word plage.

  • With this docs.yml, the search is correct:
site_name: My Docs
theme:
  name: material
  language: en

plugins:
  - search
  • With this docs.yml, plag is found but plage is not found:
site_name: My Docs
theme:
  name: material
  language: fr

plugins:
  - search

@squidfunk
Copy link
Owner

As noted in the comments, it's not fixable without losing the type-ahead experience.

@kevung
Copy link
Author

kevung commented Jun 6, 2020

I use each time the same ./docs/index.md file:

Cet été ensoleillé, nous irons à la plage.

With this docs.yml:

site_name: My Docs
theme:
  name: material
  language: en

plugins:
  - search:
      lang:
        - fr

the word ensoleilléis properly found, but à is not. Maybe it is because à begins with an accent.
(same result with language: en)

@kevung
Copy link
Author

kevung commented Jun 6, 2020

I use each time the same ./docs/index.md file:

Cet été ensoleillé, nous irons à la plage.

With this docs.yml:

site_name: My Docs
theme:
  name: material
  language: en

plugins:
  - search:
      lang:
        - en

the word irons à is properly found,
but when activating the french option in search plugin:

site_name: My Docs
theme:
  name: material
  language: en

plugins:
  - search:
      lang:
        - fr

the word irons à is not found any more.
And strangely, with this docs.yml

site_name: My Docs
theme:
  name: material
  language: fr

plugins:
  - search:
      lang:
        - en

the word irons à is also not found.

It seems that there is a tight intrication between language option from theme, and lang from the search plugin

@squidfunk
Copy link
Owner

squidfunk commented Jun 7, 2020

I took some time on this Sunday and think I have a fix in place as part of 36e1e3d.

It seems like swapping the pipeline initialization and also resetting the search pipeline (something that was added in lunr 2.0) seems to do the trick for most of the languages. I tried to test as many languages as possible and added some fixes to the default initialization.

@squidfunk
Copy link
Owner

Note that search is super tricky to get right for 40 languages. This may have introduced new problems I'm not aware of. I tried to test as many languages as I could, but unfortunately, my time is limited.

@squidfunk
Copy link
Owner

Released as part of 5.2.3

@kevung
Copy link
Author

kevung commented Jun 7, 2020

@squidfunk Thank you so much for your help, and for your work!
According to search plugin doc page, the language chosen for the theme sets the language for the search.

I tested a minimal example on the last Mkdocs-material release (5.2.3) with:

sudo pip install mkdocs-material --upgrade

In this minimal example:

  • ./docs/index.md:
Cet été ensoleillé, nous irons à la plage.
  • mkdocs.yml:
site_name: My Docs
theme:
  name: material
  language: fr

plugins:
  - search

nav:
  - index.md

the word "nous" connot be found.

screenshot

@squidfunk
Copy link
Owner

This is because "nous" is considered a stopword in the French language and filtered out. See:
https://github.com/MihaiValentin/lunr-languages/blob/a62fec97fb1a62bb4581c9b69a5ddedf62f8f62f/lunr.fr.js#L699

@kevung
Copy link
Author

kevung commented Jun 7, 2020

Mmm, I closed mkdocs serve, refresh, did a lot of things... and in exactely the same config as #1745 (comment)
I can now find "nous" !
Haha I am a bit confused :)
screenshot

The search functionality is very important for a web doc, so maybe id it wiser to mark the multi-language search as experimental?

I think I will set the language as english by default as it might give the most stable results. Thank you again for help. If I can be of any support for testing, I'd be happy to help.

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