→ facetwp_i18n

Overview

This filter allows you to translate the handful of *dynamic* strings that are otherwise not translatable using __() or _e().

For example, Dropdown facets have a “Default Label” database setting.

Parameters

  • $string | string | The string to translate

Usage

// Add to your theme's functions.php file
function custom_facetwp_i18n( $string ) {
    $lang = FWP()->facet->http_params['lang'];

    // manual translations
    $translations = array();
    $translations['es']['Any'] = 'Cualquier';
    $translations['de']['Any'] = 'Jeder';
    $translations['es']['Enter keywords'] = 'Introduzca las palabras clave';
    $translations['de']['Enter keywords'] = 'Geben Sie Schlüsselwörter';

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

    return $string;
}
add_filter( 'facetwp_i18n', 'custom_facetwp_i18n');