<?php
// Note: in FacetWP 4.3.2 the facetwp_i18n hook was added to the Button item, making it easier to translate the Button text.
// See: https://facetwp.com/help-center/listing-templates/listing-builder/#translate-the-button-item-text
// The solution below can still be used for older FacetWP versions and other items.
// Allows for string translation from pll_register_string in layout builder
add_filter( 'facetwp_builder_item_value', function( $value, $item ) {
if ( 'my-item' == $item['settings']['name'] ) {
$current = ( !empty( FWP()->facet->http_params['lang'] ) ) ? FWP()->facet->http_params['lang'] : pll_current_language();
$value = pll_translate_string( 'Read More', $current );
}
return $value;
}, 10, 2 );