sanity-io / sanity-algolia

Utilities for indexing Sanity documents in Algolia
MIT License
67 stars 16 forks source link

i18n support #26

Open jleknes opened 2 years ago

jleknes commented 2 years ago

In our project we both use document level and field level internationalisation, however we mostly use field level. Currently we support two languages, but in the future there we might support several. We use Algolia for search, and because all content is translated the best way for us is to use multiple indices, one for each language. https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/how-to/multilingual-search/

This means that one document in Sanity should be indexed as several records in Algolia, one for each language. Different projections of the same document should be sufficient to build the individual records.

Example:

projection: `{
"title": title["${locale}"],
"path": slug.current,
"summary": summary["${locale}"]}`

I tried to solve this by creating two instances of indexer (one for each language) and trigger webhookSync successively for each of them. This did not work.

I guess an option is to create two webhooks and have one for each language? Are there any other workarounds?

Will this be resolved by PR #14? If so, it might be a good idea to use i18n as a use case for documentation. I believe that I might not be the only one struggling with this.