Skip to content

Instantly share code, notes, and snippets.

@djrmom
Created November 19, 2019 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djrmom/04a69aee9199816d417a257e2b81e6de to your computer and use it in GitHub Desktop.
Save djrmom/04a69aee9199816d417a257e2b81e6de to your computer and use it in GitHub Desktop.
facetwp translate labels
<?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 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment