Skip Navigation

[Resolved] Translate word "field" in select

This support ticket is created 3 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 4 replies, has 2 voices.

Last updated by tomaszB-4 3 years, 1 month ago.

Assisted by: Waqar.

Author
Posts
#2208635
field.jpg

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 );

#2209753

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

#2210619

Thanks a lot!

Now the translation in functions.php works great 🙂

#2212793

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

#2212843

Thanks a lot again! 🙂