Indexing multiple indexes for translations

Hello there,

I am following up on this thread: https://github.com/algolia/algoliasearch-rails/issues/283

Basically, I have 3 different indexes, 1 for each language.
The following method indexes my 3 indexes in english and I am really not sure why, maybe you can help me out.

DEFAULT_ATTRIBUTES = [:name, :description, :pricing]

algoliasearch  do
  I18n.available_locales.each do |locale|
    add_index "ProductTest#{locale.capitalize}", if: :indexable? do
      Globalize.with_locale(locale) do
        attribute(*DEFAULT_ATTRIBUTES)
      end
    end
  end
end

Have a great day!

Hey Julien,

Out-of-the-box our gem doesn’t support multiple indices per language. What you can do is use multiple attributes per language. As described in this example:

algoliasearch do
  [:en, :fr, :de].each do |lang|
    add_attribute "title_#{lang}" do
      Globalize.with_locale(lang) do
          title
      end
    end
  end
end

What do you think? :face_with_monocle:

Hi there!

Thanks for the hint!

I thought about this some time ago. Unfortunately, I would have to re-create my entire logic, also I am unsure about passing rails locals as props and how the build in react components will behave.
Anyhow, I will have to give it a try some time, just hoped there could be an easy fix for it.

Thanks!