Question T14220
Visible to All Users

Creator Translation Tab: "Used Strings Only" Includes Unused Strings

created a year ago

Hello,

When selecting the option "Used Strings Only" inside the translation tab of the creator, users are still seeing rows in the table for question titles, even if they are unused:

Clipboard-File-1.png

This furthermore applies to a custom property I defined as follows:

Code
Serializer.addProperty(SEARCH, { name: MAPPING, displayName: "Mapping", type: "itemvalues", category: "general", isRequired: true, isLocalizable: false, });

It is not even localizable, so I'm unsure why it's showing up in the first placeā€¦

Clipboard-File-2.png

My understanding of "Used Strings Only" would be any strings that are defined in at least on locale. Is there a way to achieve this behavior? This would greatly reduce the number of empty rows users have to scroll by when adding translations.

Thanks,

Lucas

Answers approved by surveyjs Support

created a year ago

Hello Lucas,
The islocalizable property is applied to properties of the 'text' type. The MAPPING property is of the itemvalues type. Therefore, it appears in a Translation tab regardless of the isLocalizable property value. If you wish to hide this property from the Translation tab, you can handle the creator.onTranslationStringVisibility event. Within this event, check the options.propertyName parameter and set the options.visible flag accordingly.

The Used Strings Only mode actually filters a list of translation strings and display only those that have been modified.
Nevertheless, the title property behaves differently. When question titles remain undefined, the corresponding question names are used as titles. Therefore, we imply that question titles are implicitly specified. This is why question titles appear in the Used Strings Only mode.
If your wish to eliminate the title and MAPPING properties from the Translation tab, the provided code accomplishes this task:

JavaScript
creator.onTranslationStringVisibility.add((sender, options) => { if ( options.propertyName === "MAPPING" || options.propertyName === "title" ) { options.visible = false; } });

Please feel free to reach out if you have any further queries or concerns.

Thanks

    Show previous comments (2)
    AT AT
    Andrew Telnov a year ago

      Hello Lucas,
      You can use the following code:

      JavaScript
      let translationModel; creator.onActiveTabChanged.add((sender, options) => { if (options.tabName === "translation") { translationModel = options.model; } else { translationModel = undefined; } }); creator.onTranslationStringVisibility.add((_, options) => { //If model is not define yet, then we are loading the translation tab and by default showAllStrings is false const showAllStrings =!!translationModel && translationModel.showAllStrings; const values = options.obj.localizableStrings?.[options.propertyName]?.values; if (typeof values !== "object" || Object.keys(values).length === 0) { options.visible = false; } });

      Thank you,
      Andrew
      SurveyJS Team

      LF LF
      Lucas Forster a year ago

        Hello Andrew,

        With your example I was able to fully implement the desired behavior.

        Thanks,

        Lucas

        AT AT
        Andrew Telnov a year ago

          Great and you are very welcome!

          Andrew
          SurveyJS Team