facetwp translate labels

djrmom

{{gist file=”custom-hooks.php” lang=”php”}}
<?php
/** checks WPML current language if FWP()->facet->http_params[‘lang’] is not set
**/
add_filter( ‘facetwp_i18n’, function( $string ) {

if ( isset( FWP()->facet->http_params[‘lang’] ) ) {
$lang = FWP()->facet->http_params[‘lang’];
else {
$lang = apply_filters( ‘wpml_current_language’, null );
}

$translations = [];
$translations[‘es’][‘Products’] = ‘Productos’;
$translations[‘es’][‘Location’] = ‘UbicaciĆ³n’;

if ( isset( $translations[ $lang ][ $string ] ) ) {
return $translations[ $lang ][ $string ];
}

return $string;
}, 11 );
{{/gist}}