Question T1321
Visible to All Users

Multi languages survey with dynamic surveyStrings

created 6 years ago (modified 6 years ago)

Hello everyone,

Is it possible to define a generic custom string in .ds files and use it dynamically in the survey to retrieve the appropriate translated text ?

Example :

./localization/english.ds

TypeScript
import { surveyLocalization } from "../surveyStrings"; export var englishSurveyStrings = { customString: "This string is in english"; }; surveyLocalization.locales["en"] = englishSurveyStrings; surveyLocalization.localeNames["en"]="english";

./localization/french.ds

TypeScript
import { surveyLocalization } from "../surveyStrings"; export var frenchSurveyStrings = { customString: "Cette chaine de caractères est en français"; }; surveyLocalization.locales["fr"] = frenchSurveyStrings; surveyLocalization.localeNames["fr"]="français";

survey.jquery.d.ts

TypeScript
import "./localization/french"; import "./localization/english";

Survey.js

JavaScript
var jsonSurvey = { title: customString; pages: [{ ... }] }

This way if my customString is used multiple times in my survey and I need to change the translation I only need to change it one time in the .ds files.

Comments (2)

    Hello,

    SurveyJS doesn't support such a feature for survey JSON.

    Thanks, Serge
    SurveyJS Team

      Hello Serge T,

      Thanks for your quick feedback.

      Is it something that would be available some point in near future ?

      Because sometimes we have to repeat some elements in our surveys and this feature would help to avoid repeating the texts in the JSON file.

      Regards,

      Answers

      created 6 years ago (modified 6 years ago)

      Hello,

      We discussed this question with the team and I prepared a plunker for you - https://plnkr.co/edit/cwNMbgQ5eTqvZqOmn2cw?p=preview
      The onTextMarkdown event is used for titles text processing.
      Hope this fit your scenario.

      Thanks, Serge
      SurveyJS Team