Question T18473
Visible to All Users

Merge the default translation with a custom one

created 8 months ago

Hi SurveyJs team,

We have a found issue, relate default language for multi-language at survey creator. When we set default language is bahasa indonesia and second language is english. After than gw switch default language into english and the translations will be like this Clipboard-File-1.png default english and second language english. That should be Default(english) and second is Bahasa Indonesia and then the content will switch it. You can look at the value of default(english), there is a Bahasa Indonesia content.

So, can we set automatically on these?

Thanks

Answers approved by surveyjs Support

created 8 months ago

Hello,
If you haven't upgraded your SurveyJS libraries, I would recommend doing so. In recent versions, the 'Merge English with default locale' button appears allowing users to merge the default (English) locale with a custom (English) translation (View Demo):
Clipboard-File-1.png

Also, you can handle this from code. To merge locales from code, access a translation plugin and call the mergeLocaleWithDefault public function to merge the current locale with the default one.

JavaScript
creator.onActiveTabChanged.add((sender, options) => { if (options.tabName === "translation") { const translationPlugin = creator.getPlugin("translation"); translationPlugin.model.mergeLocaleWithDefault(); } });

The code will update a locale when a user activates the Translation tab. If you wish to merge the current locale with a default when a SurveyJS Creator appears, you can instantiate a Translation object and call the mergeLocaleWithDefault function.

JavaScript
import { Translation } from "survey-creator-core"; const translation = new Translation(creator.survey); translation.reset(); translation.mergeLocaleWithDefault();

Please let me know if any questions remain.

    Comments (2)

      Thanks, that's also what I was just looking for.

        You're always welcome. Please feel free to reach out if you require further assistance.