Survey Creator Interface Localization
Localization is the adaptation of a product to the local language of its users. Survey Creator supports UI translation into over 30 languages out of the box. In this demo, the Survey Creator UI is translated into German.
Translated strings are shipped as dictionary files. The localization engine that works with the dictionaries is available as a separate script/module. This script/module imports dictionaries for all languages. Reference this script in the <head>
tag of your page or import this module into the component that renders Survey Creator:
<script src="https://unpkg.com/survey-creator-core/survey-creator-core.i18n.min.js"></script>
import "survey-creator-core/survey-creator-core.i18n";
Since Survey Creator v1.9.112, you may reference or import only the languages you need, as shown below:
<script src="https://unpkg.com/survey-creator-core/i18n/french.js"></script>
<script src="https://unpkg.com/survey-creator-core/i18n/german.js"></script>
<script src="https://unpkg.com/survey-creator-core/i18n/italian.js"></script>
import "survey-creator-core/i18n/french";
import "survey-creator-core/i18n/german";
import "survey-creator-core/i18n/italian";
The default language for UI elements is English. To select another language, set the currentLocale
property or Survey Creator's locale
property. This demo shows Survey Creator UI translated into German.
If you want to change individual UI translations, get an object with all translation strings for a specific locale using the getLocaleStrings(localeCode)
method and override the required properties in this object. You can find a full list of available properties in the English dictionary. Refer to the Code tab for a code example.
Call the setupLocale(localeConfig)
method with the following object as an argument:
import { setupLocale } from 'survey-core';
setupLocale({
localeCode: string, // A short code used as a locale identifier (for example, "en", "de", "fr")
strings: string[], // An array with custom translations
nativeName: string, // The locale name in native language
englishName: string, // The locale name in English
rtl: boolean // A flag that indicates whether the language is right-to-left
});
You can also introduce a custom locale to override multiple UI translations in a batch. The following code shows how to do it in a separate TypeScript translation file (dictionary):
// custom-locale.ts
import { setupLocale } from 'survey-creator-core';
const customLocaleStrings = {
ed: {
addNewQuestion: "New Question",
deletePage: "Remove Page"
}
};
setupLocale({
localeCode: "customlocale", // A short code used as a locale identifier (for example, "en", "de", "fr")
strings: customLocaleStrings, // An array with custom translations
nativeName: "Custom Locale", // The locale name in native language
englishName: "Custom Locale", // The locale name in English
rtl: false // A flag that indicates whether the language is right-to-left
});
import './localization/custom-locale.ts';
// ...
// Activate the custom locale
editorLocalization.currentLocale = "customlocale";
// ----- or -----
creator.locale = "customlocale";
If any translation strings or other settings are missing in your custom locale, they will be taken from the English locale. You can specify the defaultLocale
property to use another fallback locale:
editorLocalization.defaultLocale = "fr";