Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Muliple languages in multi-select dropdown question

I have a multi-select drop down question. Everything works as it should, but our QC people realized that the text showing up in the drop down is in English only.
Working Code
    // Settings
    var searchable = false;
    var closeDropdownOnSelection = true;
    var hideInputElements = false;
    var closedDropdownSymbol = '▼';
    var openedDropdownSymbol = '▲';
    var placeholderDropdownText = 'Type to search';
    var noResultsDropdownText = 'No results found';
    var closedDropdownText = function(selectedItems) {
        // Good preset for checkboxes: shows "X options selected" if an item is selected, or "Select options."
        var numberOfSelectedItems = selectedItems.length;
        switch (numberOfSelectedItems) {
            case 0:
                return 'Select Route(s)';
            case 1:
                return '1 option selected';
                return numberOfSelectedItems + ' options selected';

I am interested in the return whosn on lines 17 and 20.  We have translated text for those, bu tI'm not sure how to incorporate it.  I have tried the following

                return '<div class="language" data-language="1">
                        Select Route(s)
                        <div class="language" data-language="2">
                        Something other than English

but when I test it, the question does not appear.  We need to replicate this for a total of eight (8) langauges.  I'm pretty sure it's a simple oversight on my part cause I no know how to code.

Can you please help
asked Aug 3 by Nwiggin Bronze (1,850 points)

1 Answer

0 votes
Assuming your Custom Dropdown will continue to stay non-searchable, we should be able to fix this with two changes.

First, the multi-line string you've created is not valid JavaScript.  We need to either remove the new lines in the string, replace the apostrophes with backticks (`), or concatenate multiple strings together like this:

return 'abc' +
'def' +

Second, seek out this line in the code:

$('#[% QuestionName() %]_div .customdropdown_nonsearchablediv').text(text);

and replace it with this:

$('#[% QuestionName() %]_div .customdropdown_nonsearchablediv').html(text);
answered Aug 3 by Zachary Platinum Sawtooth Software, Inc. (212,550 points)

Thanks! This did it.