Question T6873
Visible to All Users

changing default locale non-ambiguously

created 4 years ago (modified 4 years ago)

Hi,

First of all how to add defaultValues to json.
Like setting

Code
SurveyKnockout.surveyLocalization.defaultLocale = 'en'

doesn't give locale: 'en' in json output for defaultLocale
and
I have not found any solution for changing the default locale from dropdown-
Clipboard-File-1.png
to
Clipboard-File-3.png
after I select french from english.
and which should change the json from-
{ "locale": "en", "title": { "default": "title", "fr": "frTitle" }, // here default is 'en' to
{ "locale": "fr", "title": { "default": "frTitle", "en": "title" }, // here default is 'fr'

or can we simply remove the 'Default()' from default language-
when 'en' default-Clipboard-File-4.png
when 'fr' default- Clipboard-File-2.png
and include the localeName in place of default in json-
{ "locale": "fr", "title": { "fr": "frTitle", "en": "title" }, // here default is 'fr'
can this be done?

Thanks for providing support.

Answers approved by surveyjs Support

created 4 years ago (modified 4 years ago)

The code you use, should change the default localization

JavaScript
Survey.surveyLocalization.defaultLocale = "fr";

Here is the example.

It doesn't convert "fr" strings into "default". You can do it in "Translation" tab.

Thank you,
Andrew
SurveyJS Team

    Show previous comments (6)

      How do you want your users to work with your SurveyJS Creator?
      Typically, you choose one default locale: "en" or "fr" or what ever and they work with it. If they need a new language to support in their surveys, then all others strings store with locale names as a key. It works perfectly for all our customers so far.
      We add into translation object creator.translation.mergeLocaleWithDefault(); this function. It will move "fr" to "default", if for some reason "fr" was not a default locale from the beginning.
      Commonly the survey default locale is the same as Creator locale, so French speaking users can see French translation.

      What is your scenario? I mean from the end-user point of view?

      Thank you,
      Andrew
      SurveyJS Team

        How to add the properties with defaultValues to the JSON?

        If defaultLocale is 'fr' and 'fr' is selected in default language dropdown then how to get "locale": "fr" in JSON?

        will creator.translation.mergeLocaleWithDefault() work here-
        creator.addEventListener('onPropertyValueChanging', (_creator, options) => {
        options.propertyName === 'locale' && _creator.translation.mergeLocaleWithDefault(options.newValue) })

          Hello,
          You need to use additionally options.obj and check if it is survey or not:
          options.obj.getType() === "survey".

          Thank you,
          Andrew
          SurveyJS Team