Question T14031
Visible to All Users

Control which languages are selected in the Translation tab

created 2 years ago

Supporting more than 8 translations in our surveys, we want to control which languages are being selected when the Translation tab is activated in the Creator. The behavior appears to be that 'default' and the first seven languages, ordered by language code, are chosen.

Also, regardless of what the user may choose, the selected languages reset to default plus first seven when tabbing between Designer and Translation.

How can we control the initial selected languages list, and maintain the user's choices when switching between tabs?

Here, we see Français not selected to be in the first 8 because its language code is ninth in an alphabetic list of languages present in the json ( I think )
Clipboard-File-2.png

The current survey-creator-react in our code is version 1.9.74.

Thanks

Answers approved by surveyjs Support

created 2 years ago

Hello Jeff,
You can use the following code:

JavaScript
creator.onActiveTabChanged.add((sender, options) => {     if(options.tabName === "translation") {         options.model.setSelectedLocales(["fr""es"]);     } });

Here is the example.

Thank you,
Andrew
SurveyJS Team

    Show previous comments (2)

      Hello Jeff,
      Sure, here is the code:

      JavaScript
      creator.onActiveTabChanging.add((sender, options) => {     if(creator.activeTab === "translation") {         const model = creator.getPlugin(creator.activeTab).model;         alert(model.getSelectedLocales());     } });

      Thank you,
      Andrew
      SurveyJS Team

        Thanks, very much, again. I found I needed to cast model as Translation to access getSelectedLocales(), but this is what I needed.

          You are very welcome!

          Andrew
          SurveyJS Team