docsy icon indicating copy to clipboard operation
docsy copied to clipboard

Lunr search with support for other languages than English

Open LarsAlmgren opened this issue 4 years ago • 3 comments

I've created a Hugo site with Docsy in Swedish and would like to change Lunr search language from English to Swedish. Is it possible to configure somehow? I've been looking around but not found anyone describing how one could do it.

Lunr support more languages than English and I've also found a Swedish stemmer

  • https://lunrjs.com/guides/language_support.html
  • https://github.com/MihaiValentin/lunr-languages/blob/master/lunr.sv.js

LarsAlmgren avatar May 11 '21 06:05 LarsAlmgren

@tekezo, do you know how users could configure this? Thanks!

LisaFC avatar May 11 '21 08:05 LisaFC

There is no configuration item at the moment, and I think you can get it to work by modifying the following part locally.

https://github.com/google/docsy/blob/0b5c79c76173088226a1951636d0f29d77165808/assets/js/offline-search.js#L47 https://github.com/google/docsy/blob/0b5c79c76173088226a1951636d0f29d77165808/layouts/partials/head.html#L34

It would be preferable if lunr-languages were automatically adapted from the content languages, so I would like to make such a modification in the future.

tekezo avatar May 12 '21 00:05 tekezo

Hmm. I didn't think of this when I added offline search in https://github.com/google/docsy/pull/142.

@tekezo Perhaps one way to deal with this could be to enable multilanguage support?

https://lunrjs.com/guides/language_support.html

theletterf avatar Jul 04 '21 16:07 theletterf