We needed ?lang=[LANG_CODE] such as ?lang=de followed by the algolia stuff.
This is what we came up with: (note the constant ICL_LANGUAGE_CODE which is set to the current language by WPML (WordPress).
Keep in mind that it needs NOT to have the ending & sign when there are no parameters in search.
base:
routing: '.$routing.'
where $routing is defined as:
$routing = 'true'; // For base language
if( $needs_custom_routing ) {
$routing = '{
router: instantsearch.routers.history({
/*
parseURL({ qsModule, location }) { return qsModule.parse(location.search.slice(1)); },
*/
createURL({ qsModule, location, routeState }) {
const { origin, pathname, hash } = location;
const queryParameters = {};
if (routeState.query) {
queryParameters.query = encodeURIComponent(routeState.query);
}
if (routeState.categories) {
queryParameters.categories = routeState.categories.map(encodeURIComponent);
}
if (routeState.page !== 1) {
queryParameters.page = routeState.page;
}
const queryString = qsModule.stringify(routeState);
if( queryString ) {
return `${origin}${pathname}?lang='.ICL_LANGUAGE_CODE.'&${queryString}`;
} else {
return `${origin}${pathname}?lang='.ICL_LANGUAGE_CODE.'`;
}
},
})
} /* /routing */';
} // /needs_custom_routing