Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translation Tab: Add a paragraph by pressing Enter inside the comment… #5989

Merged
merged 6 commits into from
Nov 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -902,10 +902,12 @@ export class Translation extends Base implements ITranslationLocales {
const cellQuestion = <QuestionCommentModel>options.cell.question;
const item = getTransationItem(options.question, options.row.name);
this.setPlaceHolder(cellQuestion, item, options.columnName);
const isMultiLine = !!item ? item.locString.getIsMultiple() : false;
cellQuestion.acceptCarriageReturn = isMultiLine;
let isMultiLine = false;
if (!!item) {
cellQuestion.maxLength = item.maxLength;
const loc = item.locString;
isMultiLine = loc.getIsMultiple();
cellQuestion.acceptCarriageReturn = isMultiLine || (<LocalizableString>loc).allowLineBreaks;
}
if (!isMultiLine) {
cellQuestion.rows = 1;
Expand Down
27 changes: 27 additions & 0 deletions packages/survey-creator-core/tests/tabs/translation.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,33 @@ test("stringsSurvey - text question dataList property, several locales", () => {

settings.translation.sortByName = oldValue;
});
test("acceptCarriageReturn for text properties", () => {
const survey = new SurveyModel({
elements: [
{
type: "text",
name: "question1",
title: { default: "title-en", de: "title-de" },
placeholder: { default: "placeholder-en", de: "placeholder-de" }
}
]
});
const translation = new Translation(survey);
translation.reset();
expect(translation.stringsSurvey.pages).toHaveLength(1);
const page = translation.stringsSurvey.pages[0];
expect(page.elements).toHaveLength(1);
const pagePanel = <PanelModel>page.elements[0];
expect(pagePanel.elements).toHaveLength(1);
expect(pagePanel.elements[0].name).toEqual("question1");
const question1 = <PanelModel>pagePanel.elements[0];
let rows = (<QuestionMatrixDropdownModel>question1.elements[0]).visibleRows;
expect((<QuestionCommentModel>rows[0].cells[0].question).acceptCarriageReturn).toBeTruthy();
expect((<QuestionCommentModel>rows[0].cells[1].question).acceptCarriageReturn).toBeTruthy();
rows = (<QuestionMatrixDropdownModel>question1.elements[1]).visibleRows;
expect((<QuestionCommentModel>rows[0].cells[0].question).acceptCarriageReturn).toBeFalsy();
expect((<QuestionCommentModel>rows[0].cells[1].question).acceptCarriageReturn).toBeFalsy();
});
test("Respect property maxLength attrigute in stringsSurvey comment questions", () => {
Serializer.findProperty("question", "title").maxLength = 10;
Serializer.findProperty("page", "title").maxLength = 20;
Expand Down