Skip Navigation

[Resolved] Customize select combobox options and translations

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to customize and translate the text strings shown in a CRED select combobox / select2 field.

Solution: These strings are currently not customizable, so I have filed a feature request for this improvement.

This support ticket is created 6 years, 7 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.

Our next available supporter will start replying to tickets in about 1.72 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 replies, has 2 voices.

Last updated by Christian Cox 6 years, 7 months ago.

Assisted by: Christian Cox.

Author
Posts
#628057

Thanks, that worked perfectly. 🙂

Just two minor follow up questions: Currently I see no way to translate the part "Please enter 1 or more characters" since it is not yet included in the messages box of the CRED form as an optin. I tried to change it with a Jquery but I fear it fires too late. This did not work:

jQuery(document).ready(function(){
  jQuery('.toolset_select2-results__message').text('ICH BIN EINE NEUER TEXT');  
});

Furthermore. I dont want to reveal the whole list too easily. WI want the user to type in at least 4 characters to trigger the search process. Which file sets this so I can adapt it even if I have to hardcode it.

Thanks in advance 🙂

#628058

From the previous ticket:

Ok i found the hardcoded text in this file:
/wp-content/plugins/cred-frontend-editor/vendor/toolset/toolset-common/res/lib/select2/select2.js in line 4484

var message = 'Please enter ' + remainingChars + ' or more characters';

I also found the variable minimumInputLength which seems to be crucial for this. It is set in line 3745:

this.minimumInputLength = options.get('minimumInputLength');

When i hardcode this as well it already works:

this.minimumInputLength = 4;

But where can I set it generally since it seems like this value is stored somewhere?

Thanks in advance ?

I use the CRED beta.

#628061

I tried to change it with a Jquery but I fear it fires too late.
In general, you should use a window load event handler instead of the document ready event handler to trigger your JS:

jQuery(window).bind('load', function(){
  jQuery('.toolset_select2-results__message').text('ICH BIN EINE NEUER TEXT');  
});

As far as customizing the minimumInputLength, the value is set in the code when each select2 object is initialized as part of that initial config. I can't recommend making changes to core code, but I can reach out to the team to see if it's possible to control this value with a shortcode attribute or other filter. I'll check on the translation of this string as well, please stand by and I will update you soon.

#628460

After discussion with the team, our developers decided that neither the text translation nor the minimum number of characters in the autosuggest field are currently manageable, so I should file these two suggestions as feature requests. I've started that process now, but I can't say for sure when the developers will decide to implement them. If I receive any additional information about those, I'll let you know here.