SurveysTypeScript SDK
Localization and right-to-left layout
Author localized definition content, replace runtime strings, and switch direction safely.
Author localized content
Localizable definition properties accept either a string or an object with default and locale keys. Resolution falls back from a regional locale to its base language and then to the default value.
const definition: SurveyDefinition = {
locale: 'en',
textDirection: 'auto',
pages: [{
name: 'contact',
elements: [{
type: 'text',
name: 'name',
title: { default: 'Your name', fr: 'Votre nom', ar: 'اسمك' },
}],
}],
};
survey.strings.register('cy', {
nextPage: 'Nesaf',
prevPage: 'Blaenorol',
complete: 'Gorffen',
});
survey.setLocale('ar'); // React updates and the survey root becomes dir="rtl".Switch runtime locale
Call survey.setLocale for the respondent’s language. This changes displayed authored content and library strings without rewriting the definition’s authored locale.
Right-to-left layout
With textDirection: 'auto', Kajay derives direction from the locale and places dir on the survey root. Authors must still provide translated content; hosts must test custom components and surrounding layout in both directions.