survey-creator-core
Version:
A framework-independent core package of the SurveyJS Survey Creator component. With Survey Creator, you can visually design complex, interactive JSON forms and surveys in a drag-and-drop interface.
275 lines (274 loc) • 11.2 kB
TypeScript
import { Base, SurveyModel, JsonObjectProperty, PageModel, ILocalizableString, Action, IAction, QuestionMatrixDynamicModel } from "survey-core";
import { ISurveyCreatorOptions } from "../../creator-settings";
import "./translation.scss";
export declare class TranslationItemBase extends Base {
name: string;
protected translation: ITranslationLocales;
constructor(name: string, translation: ITranslationLocales);
get isGroup(): boolean;
fillLocales(locales: Array<string>): void;
mergeLocaleWithDefault(loc: string): void;
makeObservable(): void;
deleteLocaleStrings(locale: string): void;
applyEditLocale(locale: string): void;
protected fireOnObjCreating(obj?: Base): void;
}
export declare class TranslationItemString extends Base {
locString: ILocalizableString;
locale: string;
constructor(locString: ILocalizableString, locale: string);
isReadOnly: boolean;
text: string;
placeholder: string;
protected onPropertyValueChanged(name: string, oldValue: any, newValue: any): void;
getLocText(loc: string): string;
getType(): string;
}
export declare class TranslationItem extends TranslationItemBase {
name: string;
locString: ILocalizableString;
defaultValue: string;
context: any;
private property;
private hashValues;
customText: string;
afterRender: any;
constructor(name: string, locString: ILocalizableString, defaultValue: string, translation: ITranslationLocales, context: any, property?: JsonObjectProperty);
get maxLength(): number;
makeObservable(): void;
getType(): string;
readOnly: boolean;
get text(): string;
get localizableName(): string;
getLocText(loc: string): string;
setLocText(loc: string, newValue: string): void;
applyEditLocale(locale: string): void;
values(loc: string): TranslationItemString;
fillLocales(locales: Array<string>): void;
toJSON(): any;
private correctJSON;
private getKeys;
mergeLocaleWithDefault(loc: string): void;
deleteLocaleStrings(locale: string): void;
getDefaultLocaleText(ignorePlaceHolder?: boolean): string;
getPlaceholder(locale: string, ignorePlaceHolder?: boolean): string;
private getPlaceHolderCore;
getTextForExport(loc: string): string;
getPlaceholderText(loc: string): string;
private getRootDialect;
private getItemValuePlaceholderText;
}
export interface ITranslationLocales {
locales: Array<string>;
showAllStrings: boolean;
readOnly: boolean;
getLocaleName(loc: string): string;
availableTranlationsChangedCallback: () => void;
tranlationChangedCallback: (locale: string, name: string, value: string, context: any) => void;
translateItemAfterRender(item: TranslationItem, el: any, locale: string): any;
fireOnObjCreating(obj: Base): any;
removeLocale(loc: string): void;
canShowProperty(obj: Base, prop: JsonObjectProperty, isEmpty: boolean, isShowing: boolean): boolean;
getEditLocale(): string;
getProcessedTranslationItemText(locale: string, name: ILocalizableString, newValue: string, context: any): string;
}
export declare class TranslationGroup extends TranslationItemBase {
name: any;
obj: any;
text: string;
hasIndent: boolean;
private isRootValue;
private itemValues;
private parentValue;
constructor(name: any, obj: any, translation?: ITranslationLocales, text?: string, hasIndent?: boolean);
getType(): string;
showHeader: boolean;
get items(): Array<TranslationItemBase>;
get locItems(): Array<TranslationItem>;
get allLocItems(): Array<TranslationItem>;
private fillLocItems;
get isRoot(): boolean;
setAsRoot(): void;
setParent(parent: TranslationGroup): void;
get parent(): TranslationGroup;
get fullName(): string;
protected getNameForChild(): string;
protected get isFinalNameObj(): boolean;
getItemByName(name: string): TranslationItemBase;
get groups(): Array<TranslationGroup>;
get isGroup(): boolean;
get locales(): string[];
get removeLocaleText(): string;
get localeCount(): number;
get locWidth(): string;
getLocaleName(loc: string): string;
removeLocale: (loc: string) => void;
reset(): void;
fillLocales(locales: Array<string>): void;
makeObservable(): void;
get showAllStrings(): boolean;
get hasItems(): boolean;
mergeLocaleWithDefault(loc: string): void;
deleteLocaleStrings(locale: string): void;
applyEditLocale(locale: string): void;
private fillItems;
private createMatrixCellsGroup;
private createMatrixCellsGroupCore;
private sortItems;
private getLocalizedProperties;
private getArrayProperties;
private canShowProperty;
private createTranslationItem;
private getDefaultValue;
private isItemValueArray;
private createGroups;
private addNewGroup;
private createItemValuesLocale;
private addCustomPropertiesForItemValue;
}
export declare class Translation extends Base implements ITranslationLocales {
private options;
private hasUI;
static csvDelimiter: string;
static newLineDelimiter: string;
exportToCSVFileUI: any;
importFromCSVFileUI: any;
importItemCallback: (name: string, locale: string, text: string) => string;
importFinishedCallback: () => void;
translateItemAfterRenderCallback: (item: TranslationItem, el: any, locale: string) => void;
availableTranlationsChangedCallback: () => void;
tranlationChangedCallback: (locale: string, name: string, value: string, context: any) => void;
translationStringVisibilityCallback: (obj: Base, propertyName: string, visible: boolean) => boolean;
localeInitialVisibleCallback: (locale: string) => boolean;
private surveyValue;
private settingsSurveyValue;
private onBaseObjCreatingCallback;
private addLanguageAction;
chooseLanguageActions: Array<IAction>;
constructor(survey: SurveyModel, options?: ISurveyCreatorOptions, hasUI?: boolean);
getProcessedTranslationItemText(locale: string, locString: ILocalizableString, newText: string, context: any): string;
getType(): string;
locales: Array<string>;
canMergeLocaleWithDefault: boolean;
mergeLocaleWithDefaultText: string;
readOnly: boolean;
root: TranslationGroup;
showAllStrings: boolean;
filteredPage: PageModel;
stringsSurvey: SurveyModel;
stringsHeaderSurvey: SurveyModel;
isEmpty: boolean;
private editLocale;
getEditLocale(): string;
setEditMode(locale: string): void;
get isEditMode(): boolean;
applyEditLocale(): void;
makeObservable(onBaseObjCreating: (obj: Base) => void): void;
fireOnObjCreating(obj: Base): void;
get settingsSurvey(): SurveyModel;
get localesQuestion(): QuestionMatrixDynamicModel;
deleteLocaleStrings(locale: string): void;
private removingLocale;
protected createSettingsSurvey(): SurveyModel;
private isChooseLanguageEnabled;
private calcIsChooseLanguageEnabled;
private refreshAddLanguageActionListModel;
private updateLocales;
private getSettingsSurveyJSON;
getSurveyLocales(): any[];
importFromCSVFileDOM(): void;
private updateSettingsSurveyLocales;
private resetStringsSurvey;
protected getSurveyStringsArea(): string;
protected getSurveyStringsHeaderArea(): string;
protected onSurveyStringsCreated(survey: SurveyModel): void;
protected onSurveyStringsHeaderCreated(survey: SurveyModel): void;
private createStringsSurvey;
private setPlaceHolder;
private createStringsHeaderSurvey;
private addTranslationGroupIntoStringsSurvey;
private addLocaleColumns;
private getStringsSurveyData;
updateStringsSurveyData(): void;
private getStringsQuestionData;
private updateHeaderStringsSurveyColumns;
private updateStringsSurveyColumns;
private addLocaleIntoChoices;
private addLocaleIntoValue;
private isLocaleVisible;
private setupToolbarItems;
protected onPropertyValueChanged(name: string, oldValue: any, newValue: any): void;
private getMergeLocaleWithDefaultText;
get survey(): SurveyModel;
set survey(val: SurveyModel);
reset(alwaysReset?: boolean): void;
private updateReadOnly;
canShowProperty(obj: Base, prop: JsonObjectProperty, isEmpty: boolean, isShowing?: boolean): boolean;
get defaultLocale(): string;
getLocaleName(loc: string, inEnglish?: boolean): string;
removeLocale(locale: string): void;
hasLocale(locale: string): boolean;
addLocale(locale: string): void;
private updateChooseLanguageActions;
resetLocales(): void;
getSelectedLocales(): Array<string>;
setSelectedLocales(selectedLocales: Array<string>): void;
getVisibleLocales(): Array<string>;
setVisibleLocales(locales: Array<string>): void;
private getSelectedLocalesCore;
private setSelectedAndVisibleLocales;
get noStringsText(): string;
get placeholderTitleText(): string;
get placeholderDescriptionText(): string;
exportToCSV(): string;
importFromNestedArray(rows: string[][]): void;
exportToSCVFile(fileName: string): void;
importFromCSVFile(file: File): void;
mergeLocaleWithDefault(): void;
createTranslationEditor(locale: string): TranslationEditor;
showTranslationEditor(locale: string): void;
translateItemAfterRender(item: TranslationItem, el: any, locale: string): void;
/**
* Update a translation item with given values
*/
private updateItemWithStrings;
private fillItemsHash;
dispose(): void;
}
export declare class TranslationForEditor extends Translation {
private surveyStringsHeaderCreatedCallback;
constructor(survey: SurveyModel, options: ISurveyCreatorOptions, surveyStringsHeaderCreatedCallback: (survey: SurveyModel) => void);
protected getSurveyStringsArea(): string;
protected getSurveyStringsHeaderArea(): string;
protected onSurveyStringsHeaderCreated(survey: SurveyModel): void;
}
export declare class TranslationEditor {
fromLocales: Array<string>;
private survey;
private translationValue;
private options;
private fromLocale;
private locale;
onApply: () => void;
constructor(survey: SurveyModel, locale: string, options: ISurveyCreatorOptions, translationStringVisibilityCallback?: (obj: Base, propertyName: string, visible: boolean) => boolean);
get translation(): Translation;
showDialog(): void;
doMachineTranslation(): void;
apply(): void;
cancel(): void;
dispose(): void;
setFromLocale(locale: string): void;
private updateMatricesColumns;
private updateHeaderMatrixColumns;
private updateMatrixColumns;
private getHeaderTitle;
private fillFromLocales;
private setupNavigationButtons;
private createStringsToTranslate;
private getTextToTranslate;
private createLocaleFromAction;
private updateFromLocaleAction;
private getActionTranslateFromText;
}
export declare function createImportCSVAction(action: () => void, needSeparator: boolean, isInEditor?: boolean): Action;
export declare function createExportCSVAction(action: () => void, isInEditor?: boolean): Action;