Closed openscript closed 8 months ago
Hmm, re-initializing isn't something I had considered, but I can see why it would be helpful here. I'll look at exposing something to allow this.
Part of the reason it doesn't exist is that there's a fairly high cost to doing so — not only is the index separated by language (so meta info will need to be re-fetched), the WebAssembly itself is loaded specific to a language, so re-initialization will be of the entire stack. Not necessarily a big deal, since changing language through a reload would do so anyway, but just FYI.
Will let you know when this is available!
@bglw Thank you so much! Not only for this, but your whole work on this project! :)
@openscript, are you using the JS search API directly, or the Default UI package?
In either case, this has been implemented in #498 and will go out with the next release 🙂
@openscript, are you using the JS search API directly, or the Default UI package?
I'm using the api and bring my own UI.
In either case, this has been implemented in #498 and will go out with the next release 🙂
Thank you so much. Looking forward trying it out!
Released in v1.0.4 🎉
Let me know if that works out for you! I have also included a test specifically for your case here: https://github.com/CloudCannon/pagefind/blob/971186cdd062995c14d2cc2bc711b09c850d086f/pagefind/features/multilingual.feature#L314-L318
I have a web app, where the language can be changed by the user without reloading the page. Pagefind doesn't get to know this change, so it will search in the wrong language.
Is it possible to reinitialize or change the Pagefinds language after it has been initialized?