Hello!
In sorting form I have a custom field and Toolset added word "field". Please take a look at the picture.
There were also the words "Descending" and "Ascending".
I translated them using the filter in functions.php
Unfortunately, the "Field" is as stubborn as a donkey 😉
Is there any way to do it?
function my_text_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Descending' :
$translated_text = __( 'Malejąco');
break;
case 'Ascending' :
$translated_text = __( 'Rosnąco');
break;
case 'Field' :
$translated_text = __( 'Pole');
break;
}
return $translated_text;
}
add_filter( 'gettext', 'my_text_strings', 20, 3 );
Hi,
Thank you for contacting us and I'd be happy to assist.
During testing on my website, I couldn't translate that field option label in the sorting controls either.
I've shared this feedback with the concerned team and for now, a workaround can be to update line# 1000 in the file: wp-content/plugins/toolset-blocks/embedded/inc/wpv-filter-order-by-embedded.php, from:
$return .= $orderby_candidate_label;
To:
$return .= __($orderby_candidate_label);
After that, you'll be able to translate that label using the "gettext" filter, but, please make sure to use the complete text label and not just the "Field" part.
Example:
case 'Field - Field Name' :
Note: This is only a workaround and any changes that you'll add in the plugin files will be lost, when newer plugin updates will be applied and you'll have to add them again.
regards,
Waqar
Thanks a lot!
Now the translation in functions.php works great 🙂
Hi,
Just wanted to add that there is a better alternative available that doesn't involve adding change to the plugin's core file.
Before your translation function, please include a special filtering function:
add_filter( 'wpv_filter_wpv_deccode_arbitrary_shortcode_value', 'ts_translate_label' );
function ts_translate_label( $sorting_label ){
return __( $sorting_label );
}
After you've included this code, you won't have to make the change in the plugin's file, that I suggested earlier.
regards,
Waqar