Forums › Forums › Search & Filter Pro › Chosen script strings translation
- This topic has 2 replies, 2 voices, and was last updated 9 years, 4 months ago by Ross.
-
Anonymous(Private) July 13, 2015 at 5:33 pm #21340
Hello
I observed that strings which are coming from Chosen jQuery script are always displayed in English language.
For example, when you search in combobox and there are no results on the list you will see “No results match” string ( http://imgur.com/Ro8sR8e ).
I checked language strings in your plugin via Poedit app, but I didn’t find similiar string. I checked Chosen jQuery source code and these strings are hardcoded there.
After small research I found this topic on StackOverflow – http://stackoverflow.com/questions/16669592/how-to-change-the-language-for-alerts-in-chosen-js I tried to add this code:
$(“.postform”).chosen({no_results_text: “Testing no results text”});
to my template JS file, but I’m getting “Uncaught TypeError: Cannot read property ‘length’ of undefined” message in Console. Unfortunatelly I’m stuck here. Do you have any recommendations how to handle this problem?
Regards
Anonymous(Private) July 13, 2015 at 7:10 pm #21347Well I fixed this problem by adding this code to my template JS file:
// Pass language variable to chosen script var $chosen = $('form.searchandfilter').find("select[data-combobox=1]"); if($chosen.length>0) { if (typeof $chosen.chosen != "undefined") { $chosen.chosen('destroy').chosen({ no_results_text: LG_no_results }); } }
I’m destroying chosen instance from Search & Filter plugin and initializing it again with my custom string.
Probably it’s not the best solution, but it’s working.
If you know better method to handle it, please advice.
Regards
Ross Moderator(Private) July 14, 2015 at 11:19 am #21404Hi there
Its strange, no one has mentioned this until now – thanks for the update and info, I take a look further into this and see if its something I can add in to the plugin 🙂
Thanks!
-
AuthorPosts